feat: implement nextGuess with a more complex strategy

possible guesses are now consistent with previously received feedback
This commit is contained in:
wi11-holdsworth 2025-10-02 11:33:13 +10:00
parent bca6ee723d
commit 5969470a70
2 changed files with 12 additions and 16 deletions

View file

@ -1,18 +1,5 @@
# Spec
## Tips to improve `nextGuess`
A better approach would be to only make guesses that are consistent with the
answers you have received for previous guesses. You can do this by computing
the list of possible targets, and removing elements that are inconsistent with
any answers you have received to previous guesses. A possible target is
inconsistent with an answer you have received for a previous guess if the
answer you would receive for that guess and that (possible) target is different
from the answer you actually received for that guess.
You can use your GameState type to store your previous guesses and the
corresponding answers. Or, more efficient and just as easy, store the list of
remaining possible targets in your GameState, and pare it down each time you
receive feedback for a guess.
The best results can be had by carefully choosing each guess so that it is most
likely to leave a small remaining list of possible targets. You can do this by
computing for each remaining possible target the maximum number of possible