A terminal Snake game in pure Python (stdlib curses — no runtime dependencies).
make run # normal speed
make fast # 20 moves/sec
make wrap # walls wrap instead of killing you
make run SPEED=6 # custom speedControls: arrow keys / wasd / hjkl, p to pause, q to quit.
make check # lint + tests
make test # pytest
make test-nodeps # same tests, stdlib only, no venv needed
make lint
make fmt
make clean
make help # list all targetsmake creates a .venv on first use for pytest and ruff. The game itself needs
nothing but Python 3.10+.
| File | Purpose |
|---|---|
snake.py |
Game class (pure logic) + curses front end |
test_snake.py |
Unit tests for the game rules |
Makefile |
run / test / lint / format / clean |
The game state lives in Game, which has no UI dependencies — that's what makes
the rules (collisions, growth, wrapping, no-reversal) testable without a terminal.