Skip to content

Instantly share code, notes, and snippets.

@smunilla
Last active March 7, 2017 15:08
Show Gist options
  • Save smunilla/18c3d381d8d51001e1ae33828e6ac144 to your computer and use it in GitHub Desktop.
Save smunilla/18c3d381d8d51001e1ae33828e6ac144 to your computer and use it in GitHub Desktop.
import random
from roborally.api import *
def move():
vision = sight()
in_front = list(vision[4][5], vision[3][5], vision[2][5], vision[1][5], vision[0][5])
if any(space.content and space.content[TYPE] == ROBOT for space in in_front):
return FORWARD
to_the_right = list(vision[5][6], vision[5][7], vision[5][8], vision[5][9], vision[5][10])
if any(space.content and space.content[TYPE] == ROBOT for space in to_the_right):
return TURN_RIGHT
to_the_left = list(vision[5][0], vision[5][1], vision[5][2], vision[5][3], vision[5][4])
if any(space.content and space.content[TYPE] == ROBOT for space in to_the_lef):
return TURN_LEFT
return FORWARD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment