Skip to content

Instantly share code, notes, and snippets.

@colinjfw
Created September 28, 2019 01:00
Show Gist options
  • Save colinjfw/da7041be7eeb98e2c851e2951ebed3af to your computer and use it in GitHub Desktop.
Save colinjfw/da7041be7eeb98e2c851e2951ebed3af to your computer and use it in GitHub Desktop.
def move(state)
head = state[:you][:body][0]
moves = ['up', 'down', 'left', 'right']
moves.each do |move|
coord = move_as_coord(move, head)
unless off_board(state, coord)
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