Created
November 19, 2013 19:30
-
-
Save anonymous/7551078 to your computer and use it in GitHub Desktop.
Template for cooperative strategy in robotgames
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Game: | |
def __init__(self, data, player_id): | |
self.player_id = player_id | |
self.update(data) | |
def update(self, data): | |
self.turn = data['turn'] | |
self.robots = data['robots'] | |
self.onNewTurn() | |
pass | |
# called in the beginning of each turn | |
def onNewTurn(self): | |
pass | |
# should return action for bot at given location | |
def act(self, loc): | |
return ['guard'] | |
# useful info is stored in self.player_id, self.turn and self.robots preprties | |
class Robot: | |
game = None | |
def act(self, data): | |
if self.game == None: | |
self.game = Game(data, self.player_id) | |
elif self.game.turn != data['turn']: | |
self.game.update(data) | |
return self.game.act(self.location) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment