Created
September 28, 2019 01:02
-
-
Save colinjfw/1f15cf4d582d1fe10d0502bf49388822 to your computer and use it in GitHub Desktop.
This file contains 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
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