feat(offline): robot move-choice strategy in TS (parity-pinned) #189
Reference in New Issue
Block a user
Delete Branch "feature/offline-robot-strategy"
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 A (2/2) of PWA offline mode, on top of #188. The offline robot picks its move exactly as the server does, so a local vs_ai game plays the same. Not wired into a game loop yet (Phase B).
ui/src/lib/robot/strategy.ts: port ofbackend/internal/robot/strategy.go's move-choice slice —mix(FNV-1a, via BigInt for bit-exact uint64),playToWin(~40%),deviates(the fading off-strategy wobble) andselectMove(pick the candidate whose resulting margin lands closest to the ±[1,30] band, conservative tie-break), composed bydecide(). The generator's ranked moves feed straight in. Think-time/sleep/nudge scheduling is server-only and not ported.backend/internal/robot/strategyfixture_test.go: an in-package, env-gated emitter (EMIT_STRATEGY_FIXTURES=1) writing golden fixtures from the real Go strategy (reaches the unexportedmix/playToWin/deviates/selectMove).strategy.parity.test.ts: 21 mix + 56 decision cases match Go exactly (play/exchange/pass, the deviate flip, tie-break, band overshoot).Pure additive library code; no runtime behavior change (unused at runtime, so the bundle is unchanged). Local verification green: backend build/vet/gofmt/test; UI check + test:unit (432 passed) + build.