Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_owner(iceberg):
- if iceberg.owner_id == -1:
- return DataKeys.NEUTRAL
- if iceberg.owner_id == 1:
- return DataKeys.ENEMY
- return DataKeys.MY
- def simulate(data, n):
- my_icebergs = [
- {
- 'amount': iceberg.penguin_amount,
- 'penguins_per_turn': iceberg.penguins_per_turn,
- 'owner': DataKeys.MY
- } for iceberg in data[DataKeys.MY][DataKeys.ICEBERGS]
- ]
- enemy_icebergs = [
- {
- 'amount': iceberg.penguin_amount,
- 'penguins_per_turn': iceberg.penguins_per_turn,
- 'owner': DataKeys.ENEMY
- } for iceberg in data[DataKeys.ENEMY][DataKeys.ICEBERGS]
- ]
- neutral_icebergs = [
- {
- 'amount': iceberg.penguin_amount,
- 'penguins_per_turn': iceberg.penguins_per_turn,
- 'owner': DataKeys.NEUTRAL
- } for iceberg in data[DataKeys.NEUTRAL][DataKeys.ICEBERGS]
- ]
- my_penguin_groups = [
- {
- 'amount': penguin_group.penguin_amount,
- 'destination': penguin_group.destination.id,
- 'destination_owner': get_owner(penguin_group.destination),
- 'turns_till_arrival': penguin_group.turns_till_arrival,
- 'owner': DataKeys.MY
- } for penguin_group in data[DataKeys.MY][DataKeys.PENGUIN_GROUPS]
- ]
- enemy_penguin_groups = [
- {
- 'amount': penguin_group.penguin_amount,
- 'destination': penguin_group.destination.id,
- 'destination_owner': get_owner(penguin_group.destination),
- 'turns_till_arrival': penguin_group.turns_till_arrival,
- 'owner': DataKeys.ENEMY
- } for penguin_group in data[DataKeys.ENEMY][DataKeys.PENGUIN_GROUPS]
- ]
- turn = 0
- while turn != n:
- for iceberg in my_icebergs + enemy_icebergs:
- iceberg['amount'] += iceberg['penguins_per_turn']
- for penguin_group in my_penguin_groups:
- penguin_group['turns_till_arrival'] -= 1
- if penguin_group['turns_till_arrival'] == 0:
- if penguin_group['destination_owner'] == DataKeys.MY:
- pass
- if penguin_group['destination_owner'] == DataKeys.ENEMY:
- pass
- if penguin_group['destination_owner'] == DataKeys.NEUTRAL:
- pass
- turn += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement