Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- This is an example for a bot.
- """
- from penguin_game import *
- def do_turn(game):
- d=0
- i=-1
- s=-1
- """
- Makes the bot run a single turn.
- :param game: the current game state.
- :type game: Game
- """
- # Go over all of my icebergs.
- for my_iceberg in game.get_my_icebergs():
- # The amount of penguins in my iceberg.
- my_penguin_amount = my_iceberg.penguin_amount # type: int
- # If there are any neutral icebergs.
- if len(game.get_my_icebergs()) < 3:
- for ice in game.get_neutral_icebergs():
- i+=1
- if d<ice.get_turns_till_arrival:
- d=ice.get_turns_till_arrival
- nearest_iceberg=game.get_neutral_icebergs()[i]
- else:
- d=0
- s=0
- for ice in game.get_enemy_icebergs():
- if d<ice.get_turns_till_arrival:
- print s
- d=ice.get_turns_till_arrival
- nearest_iceberg2=game.get_enemy_icebergs()[s]
- s+=1
- """
- if game.get_neutral_icebergs()>0:
- # Target a neutral iceberg.
- destination = game.get_neutral_icebergs()[0] # type: Iceberg
- else:
- # Target an enemy iceberg.
- destination = game.get_enemy_icebergs()[0] # type: Iceberg
- """
- # The amount of penguins the target has.
- if len(game.get_my_icebergs()) < 3:
- destination_penguin_amount = nearest_iceberg.penguin_amount # type: int
- else:
- destination_penguin_amount = nearest_iceberg2.penguin_amount # type: int
- # If my iceberg has more penguins than the target iceberg.
- if my_penguin_amount > destination_penguin_amount:
- # Send penguins to the target.
- if len(game.get_my_icebergs()) < 3:
- my_iceberg.send_penguins(nearest_iceberg, destination_penguin_amount + 1)
- else:
- my_iceberg.send_penguins(nearest_iceberg2, destination_penguin_amount + 1)
- """
- gili hamelech
- """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement