Commit b49be03
feat(games): /games — a six-game arcade in the pit (#364)
`/games` lists the cabinet, `/games <game>` plays one. Six games — tetris,
snake, pac-man, tic-tac-toe, chess and hangman — sharing one frame, one key
decoder and one driver, so the arcade looks like an arcade rather than six
weekend projects.
No menus and no options screens: `/games tetris` is already playing when the
frame lands, and every game reads arrows, quits on q and restarts on r, with
its controls written along the bottom of the game itself.
The games are pure — create a state, hand it a key, hand it a tick, ask it for
rows — and everything touching a terminal lives in runGame(). That is what
makes test/games.test.mjs able to finish real games of tetris and pac-man,
prove the tic-tac-toe opponent cannot be beaten in 40 games of random play,
and check chess's castling, en passant, promotion and mate detection without a
TTY anywhere near it.
Chess plays by the real rules against an alpha-beta search. Its reply runs on
the clock rather than inside the keypress, so your own move is drawn before it
starts thinking.
Also available as `moshcode games` from a shell; listing works in a pipe,
playing needs a real terminal and says so.
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent c8778ed commit b49be03
13 files changed
Lines changed: 2196 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
581 | 582 | | |
582 | 583 | | |
583 | 584 | | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
584 | 626 | | |
585 | 627 | | |
586 | 628 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
398 | 399 | | |
399 | 400 | | |
400 | 401 | | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
401 | 407 | | |
402 | 408 | | |
403 | 409 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
392 | 393 | | |
393 | 394 | | |
394 | 395 | | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
395 | 417 | | |
396 | 418 | | |
397 | 419 | | |
| |||
907 | 929 | | |
908 | 930 | | |
909 | 931 | | |
| 932 | + | |
| 933 | + | |
910 | 934 | | |
911 | 935 | | |
912 | 936 | | |
| |||
0 commit comments