Skip to content

Instantly share code, notes, and snippets.

@colinjfw
Created February 24, 2019 02:20
Show Gist options
  • Save colinjfw/6922878bbe8d3de72f9a5b968a48be47 to your computer and use it in GitHub Desktop.
Save colinjfw/6922878bbe8d3de72f9a5b968a48be47 to your computer and use it in GitHub Desktop.
function move(state) {
const head = state.you.body[0];
const moves = ['up', 'down', 'left', 'right'];
for (const move of moves) {
const coord = moveAsCoord(move, head);
if (!offBoard(state, coord)) {
return {move: move};
}
}
return {move: 'up'};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment