feat(offline): local game engine (Phase B1) #191
Reference in New Issue
Block a user
Delete Branch "feature/offline-localgame-engine"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Phase B1 of PWA offline mode, on top of #188/#189/#190. The offline vs_ai game engine — a faithful TS port of
backend/internal/enginethat drives a whole local game with no backend. Composes with the Phase-A move generator + robot strategy; not wired into the UI yet (B2/B3).ruleset.ts: static per-variant tile values / bag counts / blanks, mirrored fromrules.go(offline scoring self-contained); pinned byruleset.parity.test.tsagainst a Go fixture.bag.ts: tile bag (fill / draw-from-end / return+reshuffle) on a deterministic in-house PRNG — replays from the seed, not bit-identical to a server game (per plan).board.ts: mutable board satisfying the validator/generator read view +set().engine.ts:LocalGame— deal / play (reusingvalidate.ts) / pass / exchange / resign, scoreless(6) + out-of-tiles end, end-of-game rack penalties, winner; mirrorsgame.go. End-game math exported as pure functions, pinned vs the Go engine (engine.parity.test.ts, 9 constructed positions).engine.test.ts: a full-loop smoke — two robots play a whole vs_ai game to completion viagenerateMoves+decide, reproducible from the seed.movegennow dumps the per-variant rulesets; a new in-package engine emitter (endfixture_test.go, env-gated) produces the end-game golden.Pure additive library code; no runtime behavior change (unused at runtime, bundle unchanged). Local verify green: backend build/vet/gofmt/test; UI check + test:unit (450 passed) + build.