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):
- penguins_sent_to = []
- """
- 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 game.get_neutral_icebergs():
- if not my_iceberg in penguins_sent_to:
- # Target a neutral iceberg.
- destination = game.get_neutral_icebergs()[0] # type: Iceberg
- else:
- # Target a neutral iceberg.
- destination = game.get_eneemy_icebergs()[0] # type: Iceberg
- # Target an enemy iceberg.
- # The amount of penguins the target has.
- destination_penguin_amount = destination.penguin_amount # type: int
- if my_iceberg.can_upgrade():
- my_iceberg.upgrade()
- # If my iceberg has more penguins than the target iceberg.
- elif my_penguin_amount > destination_penguin_amount:
- # Send penguins to the target.
- print my_iceberg, "sends", (destination_penguin_amount + 1), "penguins to", destination
- my_iceberg.send_penguins(destination, destination_penguin_amount + 1)
- penguins_sent_to.append(game.get_my_icebergs.index(my_iceberg))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement