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 check_if_sent(Game(game), int(id):
- for pg in game.get_my_penguin_groups():
- if pg.destination.id == id:
- print "sent groups to this enemy"
- return False
- situation = 1
- def do_turn(game):
- penguins_sent = []
- ze_penguin = 0
- low = 10000
- """
- 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():
- # Target a neutral iceberg.
- for berg in game.get_neutral_icebergs():
- if berg.penguin_amount < low:
- low = berg.penguin_amount
- ze_penguin = game.get_neutral_icebergs().index(berg)
- destination = game.get_neutral_icebergs()[ze_penguin] # type: Iceberg
- situation = 1
- else:
- # Target an enemy iceberg.
- for berg in game.get_enemy_icebergs():
- if berg.penguin_amount < low:
- low = berg.penguin_amount
- ze_penguin = game.get_enemy_icebergs().index(berg)
- destination = game.get_enemy_icebergs()[0] # type: Iceberg
- situation = 2
- # 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:
- if (situation == 1):
- if check_if_sent(game.get_neutral_icebergs().index[destination]):
- # 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)
- elif(situation = 2):
- if check_if_sent(game.get_enemy_icebergs().index[destination]):
- # 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)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement