Skip to content

Instantly share code, notes, and snippets.

@colinjfw
Created September 28, 2019 01:02
Show Gist options
  • Save colinjfw/1f15cf4d582d1fe10d0502bf49388822 to your computer and use it in GitHub Desktop.
Save colinjfw/1f15cf4d582d1fe10d0502bf49388822 to your computer and use it in GitHub Desktop.
def move(state)
head = state[:you][:body][0]
neck = state[:you][:body][1]
moves = ['up', 'down', 'left', 'right']
moves.each do |move|
coord = move_as_coord(move, head)
if !off_board(state, coord) && !coord_equal(coord, neck)
return { move: move }
end
end
{ move: 'up' }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment