Created
December 21, 2013 18:22
-
-
Save jespada/8072905 to your computer and use it in GitHub Desktop.
test robot
This file contains hidden or 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
| import rg | |
| class Robot: | |
| def act(self, game): | |
| # if we're in the center, stay put | |
| if self.location == rg.CENTER_POINT: | |
| return ['guard'] | |
| # if there are enemies around, attack them | |
| for loc, bot in game.robots.iteritems(): | |
| if bot.player_id != self.player_id: | |
| if rg.dist(loc, self.location) <= 1: | |
| return ['attack', loc] | |
| # move toward the center | |
| return ['move', rg.toward(self.location, rg.CENTER_POINT)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment