Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.39 KB | None | 0 0
  1. def get_owner(iceberg):
  2.     if iceberg.owner_id == -1:
  3.         return DataKeys.NEUTRAL
  4.  
  5.     if iceberg.owner_id == 1:
  6.         return DataKeys.ENEMY
  7.  
  8.     return DataKeys.MY
  9.  
  10. def simulate(data, n):
  11.     my_icebergs = [
  12.         {
  13.             'amount': iceberg.penguin_amount,
  14.             'penguins_per_turn': iceberg.penguins_per_turn,
  15.             'owner': DataKeys.MY
  16.         } for iceberg in data[DataKeys.MY][DataKeys.ICEBERGS]
  17.     ]
  18.  
  19.     enemy_icebergs = [
  20.         {
  21.             'amount': iceberg.penguin_amount,
  22.             'penguins_per_turn': iceberg.penguins_per_turn,
  23.             'owner': DataKeys.ENEMY
  24.         } for iceberg in data[DataKeys.ENEMY][DataKeys.ICEBERGS]
  25.     ]
  26.  
  27.     neutral_icebergs = [
  28.         {
  29.             'amount': iceberg.penguin_amount,
  30.             'penguins_per_turn': iceberg.penguins_per_turn,
  31.             'owner': DataKeys.NEUTRAL
  32.         } for iceberg in data[DataKeys.NEUTRAL][DataKeys.ICEBERGS]
  33.     ]
  34.  
  35.     my_penguin_groups = [
  36.         {
  37.             'amount': penguin_group.penguin_amount,
  38.             'destination': penguin_group.destination.id,
  39.             'destination_owner': get_owner(penguin_group.destination),
  40.             '‎turns_till_arrival': penguin_group.‎turns_till_arrival,
  41.             'owner': DataKeys.MY
  42.         } for penguin_group in data[DataKeys.MY][DataKeys.PENGUIN_GROUPS]
  43.     ]
  44.  
  45.     enemy_penguin_groups = [
  46.         {
  47.             'amount': penguin_group.penguin_amount,
  48.             'destination': penguin_group.destination.id,
  49.             'destination_owner': get_owner(penguin_group.destination),
  50.             '‎turns_till_arrival': penguin_group.‎turns_till_arrival,
  51.             'owner': DataKeys.ENEMY
  52.         } for penguin_group in data[DataKeys.ENEMY][DataKeys.PENGUIN_GROUPS]
  53.     ]
  54.  
  55.     turn = 0
  56.  
  57.     while turn != n:
  58.         for iceberg in my_icebergs + enemy_icebergs:
  59.             iceberg['amount'] += iceberg['penguins_per_turn']
  60.  
  61.         for penguin_group in my_penguin_groups:
  62.             penguin_group['turns_till_arrival'] -= 1
  63.  
  64.             if penguin_group['turns_till_arrival'] == 0:
  65.                 if penguin_group['destination_owner'] == DataKeys.MY:
  66.                     pass
  67.  
  68.                 if penguin_group['destination_owner'] == DataKeys.ENEMY:
  69.                     pass
  70.  
  71.                 if penguin_group['destination_owner'] == DataKeys.NEUTRAL:
  72.                     pass
  73.  
  74.         turn += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement