snek-js

snake game

Stars
1

Snake Game Library

MVP Goals

  1. Simple state
  2. ASCII output
  3. Generator pattern

Simple state

Track the snake's direction and most recent coordinates. (snake.direction and snake.head.x|y)

Store nested arrays for game board grid[x][y].

ASCII output

The ASCII output makes the tests feel like this is the exact situation snapshot tests were made for!

Generator pattern

One key simplification with generators is a pull-based design. Here the client requests each 'turn' as needed.

This eliminates the need for additional boilerplate associated with push-based designs (usually with events or timers coordinating state updates.)