You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(games): PR-P G-37 — shuffle AI client items + options per session
User reports: 'v tej novej hre boli všetky správne odpovede na
jednom mieste, a u niektorých typoch hier sa pozície správnych
odpovedí nemenia'.
Two compounding causes:
1. The Sonnet generator's correctIndex distribution is lopsided
— for quiz / chart-read it picks index 0 disproportionately
often, so several questions in a row showed the right answer
in the same position.
2. AI specs are deterministic by content-hash. Replaying the
same envelope (the spec lives in Redis until rotation) showed
the same item sequence + same option arrangement every time,
training pattern-matching instead of comprehension.
Fix per AI client: shuffle on mount via `useState` initializer
(runs ONCE per mount, NOT on every re-render — re-shuffling mid-
question would be jarring). Same Fisher-Yates from `lib/shuffle.ts`
the evergreen `pickRound` helper uses on /games/finance-quiz.
Per-client treatment:
- `ai-quiz-client.tsx` — shuffle items + each item's 4 options +
recompute `correctIndex` to track the new option position.
This is the most user-visible fix (multi-question, multi-option).
- `ai-truefalse-client.tsx` — items only (statement order); the
T/F answer itself is binary so option-position bias doesn't
apply.
- `ai-price-guess-client.tsx` — items only (each item has a free-
form numeric answer, no options).
- `ai-fillblank-client.tsx` — items only (free-form string answer).
- `ai-calcsprint-client.tsx` — items only; calc cycles through
problems repeatedly via `index % length`, so shuffling at mount
also reshuffles each cycle relative to a vanilla replay.
- `ai-chartread-client.tsx` — single question, but 4 multiple-
choice options. Shuffle options + recompute correctIndex.
`ai-order-client.tsx` already has its own internal shuffle (the
gameplay IS to put items in correct order). `ai-matchpairs-client`
and `ai-memory-client` randomise via card draw inherently. `ai-
budget-client.tsx` and `ai-whatif-client.tsx` have no positional
options to shuffle.
Validation:
- pnpm typecheck → 0 errors
- pnpm test → 719/719
Open follow-up: a Sonnet system-prompt nudge in
`lib/ai-pipeline/generate.ts` could ask the generator to
distribute correctIndex evenly across items at generation time
(belt-and-braces with the client shuffle). Sprint H polish.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments