# Calculator game previews

Games are adapted from JGN1722/CalculatorGames, revision
`dc3f66393276ec230e871879242869b0f3d75eea`, under the MIT license in
`GAMES-LICENSE.txt`. Original source hashes are recorded in `provenance.json`.
The `.py` files here are both the downloadable programs and the browser inputs.

Changes to Snake: arrow directions now match movement, bounds are checked after
movement, and food/tail detection recognizes colors in both full RGB and RGB565 form.
Connect Four retains the upstream gameplay code. Game of Life is an interactive adaptation described below.

Skulpt 1.2.0 is vendored from its npm release. The tarball SHA-512 integrity was
verified before extracting `skulpt.min.js`, `skulpt-stdlib.js`, and the complete
license. Runtime checksums and release URL are in `provenance.json`.
Preserve `vendor/LICENSE.txt`, including its Python Software Foundation notice.

`worker.js` runs the curated Python in a disposable Web Worker. Its `kandinsky`,
`ion`, and `time` bridge implements only the functions used by this collection.
An OffscreenCanvas supplies a 320 x 222 RGB screen. Frames are sent at up to
30 fps; the native drawing/key bridge yields periodically so the worker can
receive input. Compiler time-slice yields are disabled because Skulpt 1.2.0 can
incorrectly exit nested Python loops when resuming them. Stopping
or switching games terminates the worker. No ROM or calculator firmware is used.
This is a game preview, not hardware emulation or an arbitrary Python editor.

The builder copies `data/` unchanged into production, keeping worker-relative
runtime URLs and Python downloads stable. The page loads a worker only on Play.
When updating upstream games, pin the new revision, update the hashes, review
the game changes, and check play with keyboard and touch before release.

## Additional NumWorks games

`falling_blocks.py` adapts `tetris.py` at the same JGN1722 revision above.
It keeps the upstream piece variants, fixes spawn/collision bounds and rotation
rollback, and ends a run when a new piece cannot spawn.

`minesweeper.py` adapts Maëlan Gallais's `Code`, revision
`500324e8ce7502291fc0eeba50bb9dc6b7d018f6`, under the MIT license in
`MINESWEEPER-LICENSE.txt`. Changes translate the result screens, use an integer
mine count for Python 3, debounce flag/reveal, and make pause suspend gameplay.
Arrows move; EXP (F in browser) flags; LN (R) reveals; OK pauses; SHIFT, ALPHA,
and XNT select Easy, Medium, and Hard. Browser buttons also expose these keys.
Hardware execution has not been tested by AgentCalc.

## Snake pacing and controls

Snake now waits for an arrow press before starting. Movement is clocked at
one cell per 0.18 seconds (about 5.6 cells/second, previously up to 20), with
input polled every 0.01 seconds. Up to two valid turns are buffered so brief
taps register between movement ticks; immediate reversal is rejected. Pausing
is edge-triggered, held pause keys do not repeatedly toggle it, and resuming
gives a full movement interval. Replays use an outer loop instead of recursion.
Food is chosen only from free cells, and filling the board wins the game.
These changes apply to the downloadable NumWorks script and browser preview.

## Browser accessibility and action pacing

`playback.js` supplies an isolated virtual clock for the Python and TI players.
Snake and falling blocks offer Relaxed (65%) or Normal browser speed. Keyboard
polling stays responsive between movement ticks. Falling blocks now uses a
0.9-second gravity interval and limits held Down to one row per 0.12 seconds;
these base defaults also apply to its calculator download. Falling blocks and
Game of Life can be paused from the player without losing the current run.

The shared clock freezes during a player pause and caps stalled-frame catch-up.
A restart clears paused state; speed can be changed without restarting a game.
Turn-based puzzles keep their own timing. Normal browser speed uses each
adapted script's base timing, rather than restoring Snake's former fast delay.

## Game of Life sandbox

The downloadable NumWorks program and browser preview share a 32 x 20 board
with fixed dead edges. The status line shows generation and live population.
XNT (X in the browser) runs or pauses; while paused, arrows move the cursor
and OK toggles a cell. SHIFT (1) advances one generation, ALPHA (2) cycles
through glider, blinker, lightweight spaceship, R-pentomino, and pulsar;
EXP (F) clears and LN (R) randomizes. Loading a pattern or a new board
pauses it for editing. Hardware execution has not been tested by AgentCalc.
