Skip to content

fix(wordgame): correct scoring, game-end on correct guess, and concurrent guess race#189

Merged
psykzz merged 2 commits into
mainfrom
fix/wordgame-bugs
Jun 23, 2026
Merged

fix(wordgame): correct scoring, game-end on correct guess, and concurrent guess race#189
psykzz merged 2 commits into
mainfrom
fix/wordgame-bugs

Conversation

@psykzz

@psykzz psykzz commented Jun 23, 2026

Copy link
Copy Markdown
Owner

Fixes #188

Summary

Three bugs in the wordgame cog:

  1. Game continued after correct guess — a player who guessed the word correctly had bonus_guess_at set, so they received a bonus guess DM 5 minutes later and could keep guessing.
  2. Double position points — concurrent guesses both read a stale snapshot of claimed_positions, so two players could each earn position bonus for the same (letter, position) pair.
  3. Letter dedup blocked position bonus — the seen_letters continue also skipped the position-bonus check for repeated letters in the same guess (e.g. the second p in poppy would neither earn a letter bonus nor a position bonus, losing 1 pt).

Changes

  • wordgame/game.py — decouple letter bonus dedup from position bonus check; both are now evaluated independently per character
  • wordgame/wordgame.py — add per-thread asyncio.Lock; _process_guess now acquires the lock and re-reads fresh Config state before scoring; skip bonus_guess_at when word is guessed correctly

Testing

  • Syntax validated: python -m py_compile wordgame/game.py wordgame/wordgame.py
  • Scoring verified: 5-letter all-unique-correct = 12 pts (5 letter + 5 pos + 2 word), repeated-letter word like poppy = 10 pts max

psykzz added 2 commits June 23, 2026 08:12
- fix: letter bonus dedup no longer blocks position bonus for repeated letters
- fix: guessing the word no longer sets bonus_guess_at (game is won, no bonus needed)
- fix: add per-thread asyncio locks so concurrent guesses re-read fresh Config state,
  preventing double-scoring on claimed_positions
- refactor: _process_guess now reads game state fresh under lock instead of using
  caller-provided snapshot
@psykzz psykzz merged commit b8451fa into main Jun 23, 2026
3 checks passed
@psykzz psykzz deleted the fix/wordgame-bugs branch June 23, 2026 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wordgame bug

1 participant