Skip to content

Instantly share code, notes, and snippets.

@jespada
Created December 21, 2013 18:22
Show Gist options
  • Select an option

  • Save jespada/8072905 to your computer and use it in GitHub Desktop.

Select an option

Save jespada/8072905 to your computer and use it in GitHub Desktop.
test robot
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