Skip to content

Instantly share code, notes, and snippets.

@Raagh
Created April 14, 2020 18:27
Show Gist options
  • Save Raagh/b398f98d25be2fcb7b4cb4979a70ca2c to your computer and use it in GitHub Desktop.
Save Raagh/b398f98d25be2fcb7b4cb4979a70ca2c to your computer and use it in GitHub Desktop.
Functional Snake Game - Part 2 - eat crash
const willEat = r.equals
const willCrash = (cols, rows, state) =>
r.find(r.equals(nextHead(cols, rows, state)))(state.snake)
const nextHead = (cols, rows, { move, snake }) =>
point(
modulo(cols)(r.head(snake).x + move.x),
modulo(rows)(r.head(snake).y + move.y)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment