Skip to content

Instantly share code, notes, and snippets.

@Raagh
Created April 14, 2020 18:27

Revisions

  1. Raagh created this gist Apr 14, 2020.
    9 changes: 9 additions & 0 deletions snake.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    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)
    )