Advertisement
Guest User

Untitled

a guest
Dec 16th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. """
  2. This is an example for a bot.
  3. """
  4. from penguin_game import *
  5.  
  6. def do_turn(game):
  7. d=0
  8. i=-1
  9. s=-1
  10. """
  11. Makes the bot run a single turn.
  12.  
  13. :param game: the current game state.
  14. :type game: Game
  15. """
  16. # Go over all of my icebergs.
  17. for my_iceberg in game.get_my_icebergs():
  18. # The amount of penguins in my iceberg.
  19. my_penguin_amount = my_iceberg.penguin_amount # type: int
  20.  
  21. # If there are any neutral icebergs.
  22. if len(game.get_my_icebergs()) < 3:
  23. for ice in game.get_neutral_icebergs():
  24. i+=1
  25. if d<ice.get_turns_till_arrival:
  26. d=ice.get_turns_till_arrival
  27. nearest_iceberg=game.get_neutral_icebergs()[i]
  28. else:
  29. d=0
  30. s=0
  31. for ice in game.get_enemy_icebergs():
  32. if d<ice.get_turns_till_arrival:
  33. print s
  34. d=ice.get_turns_till_arrival
  35. nearest_iceberg2=game.get_enemy_icebergs()[s]
  36. s+=1
  37.  
  38.  
  39.  
  40. """
  41. if game.get_neutral_icebergs()>0:
  42. # Target a neutral iceberg.
  43. destination = game.get_neutral_icebergs()[0] # type: Iceberg
  44. else:
  45. # Target an enemy iceberg.
  46. destination = game.get_enemy_icebergs()[0] # type: Iceberg
  47. """
  48. # The amount of penguins the target has.
  49. if len(game.get_my_icebergs()) < 3:
  50. destination_penguin_amount = nearest_iceberg.penguin_amount # type: int
  51. else:
  52. destination_penguin_amount = nearest_iceberg2.penguin_amount # type: int
  53. # If my iceberg has more penguins than the target iceberg.
  54. if my_penguin_amount > destination_penguin_amount:
  55. # Send penguins to the target.
  56. if len(game.get_my_icebergs()) < 3:
  57. my_iceberg.send_penguins(nearest_iceberg, destination_penguin_amount + 1)
  58. else:
  59. my_iceberg.send_penguins(nearest_iceberg2, destination_penguin_amount + 1)
  60.  
  61. """
  62. gili hamelech
  63. """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement