Skip to content

fix(P1): score or 0.0 idiom (#71) + distinct MEDIUM word list (#69)#76

Merged
FlorentPoinsaut merged 4 commits intomainfrom
fix/p1-score-idiom-and-medium-wordlist
May 4, 2026
Merged

fix(P1): score or 0.0 idiom (#71) + distinct MEDIUM word list (#69)#76
FlorentPoinsaut merged 4 commits intomainfrom
fix/p1-score-idiom-and-medium-wordlist

Conversation

@FlorentPoinsaut
Copy link
Copy Markdown
Member

Summary

Fixes two P1 issues identified during code review.


Fix #71score or 0.0 is a semantically incorrect idiom

Files: game/state.py, bot/bot.py

score or 0.0 uses Python truthiness (bool(0.0) == False), not a None-guard. top_guesses() already filters entries with score is None before returning, so the fallback was unreachable dead code in all three locations. Replaced with direct attribute access (e.score, best.score).

Reviewed by: [Tech] Reviewer agent


Fix #69 — MEDIUM and HARD use the same word list

Files: bot/bot.py, data/interest_words_m.txt (new), tests/test_commands.py

  • Added data/interest_words_m.txt: 34 semi-concrete French nouns (no OOV risk in frWac, zero overlap with EASY/HARD lists) designed by the [Tech] NLP/Data agent.
  • _WORD_LIST_FILES[Difficulty.MEDIUM] now points to interest_words_m.txt.
  • _validate_difficulty now derives valid values dynamically from Difficulty enum — future enum additions are automatically covered.
  • setdifficulty now accepts medium in addition to easy and hard.
  • Updated tests: test_medium_is_invalidtest_medium_is_valid, test_invalid_difficulty_rejected uses a genuinely invalid value, added test_valid_medium_accepted.

Reviewed by: [Tech] NLP/Data agent


Tests

268 passed, 0 failed — coverage 92 %

Closes #71
Closes #69

- Add `SemanticEngine.is_in_vocab(word)` method for explicit vocabulary lookup
- Add `is_in_vocab` to `Scorer` protocol so implementors expose it
- Expose `GameState.scorer` property so bot can access the scorer
- Filter OOV words in `start_game` using `is_in_vocab()` before
  `random.choice()`; sends a clear error message if no playable words remain
- Add tests: `TestSemanticEngineIsInVocab` and `TestStartOovFiltering`
'score or 0.0' uses Python truthiness, not a None check.
top_guesses() already filters out None scores, so the fallback
was unreachable dead code. Replace with direct attribute access
in all three locations.

Closes #71
MEDIUM and HARD both pointed to interest_words_d.txt, making the
two difficulty levels indistinguishable. Add data/interest_words_m.txt
with 34 semi-concrete French nouns that sit between the easy and hard
registers (no overlap with either list, all in-vocabulary for frWac).

Also accept 'medium' in setdifficulty (previously only easy/hard were
accepted there), and update _validate_difficulty to derive the valid
set dynamically from the Difficulty enum so future additions are
automatically covered.

Closes #69
@FlorentPoinsaut FlorentPoinsaut force-pushed the fix/p1-score-idiom-and-medium-wordlist branch from 5150a1a to 8bd7f23 Compare May 4, 2026 12:41
Co-authored-by: Copilot <copilot@github.com>
@FlorentPoinsaut FlorentPoinsaut merged commit c79079f into main May 4, 2026
2 checks passed
@FlorentPoinsaut FlorentPoinsaut deleted the fix/p1-score-idiom-and-medium-wordlist branch May 4, 2026 12:46
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.

score or 0.0 is a semantically incorrect idiom in bot and game state MEDIUM and HARD difficulties use the same word list

1 participant