Created
April 14, 2020 18:27
-
-
Save Raagh/b398f98d25be2fcb7b4cb4979a70ca2c to your computer and use it in GitHub Desktop.
Functional Snake Game - Part 2 - eat crash
This file contains hidden or 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
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