Created
February 24, 2019 02:23
-
-
Save colinjfw/b664be1934ab0a374aad21851ef2f833 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
function move(state) { | |
const head = state.you.body[0]; | |
const neck = state.you.body[1]; | |
const moves = ['up', 'down', 'left', 'right']; | |
for (const move of moves) { | |
const coord = moveAsCoord(move, head); | |
if (!offBoard(state, coord) && !coordEqual(coord, neck)) { | |
return {move: move}; | |
} | |
} | |
return {move: 'up'}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment