Open woctezuma opened 1 year ago
Wordle keeps track of two lists: (i) a list of possible correct answers and (ii) a much bigger list of valid words that the user can enter. The first call will try to find a good guess from list (i), but in case there are still many options, it might be better to guess a word from list (ii) to have better outcomes for the next round.
There are indeed two lists:
words.txt
, which corresponds to (i),all_words.txt
, which corresponds to (ii).Here:
DICT_FILE
corresponds to (i),DICT_FILE_all
corresponds to (ii).Here:
dictionary
corresponds to (i),all_dictionary
corresponds to (ii).And here, we have all_dictionary
which corresponds to (ii), not to (i).
Regarding the all_words
variable:
all_words
variable is initialized with all_dictionary
, so it should not matter:intersection()
, so it should be a subset of all_dictionary
in the end:Regarding the dictionary
variable, it is only used once, in the for-loop to evaluate the bot.
I wonder whether what you wanted to do would have been:
candidates = all_words
entropies = calculate_entropies(candidates, all_words, pattern_dict, all_patterns)
if max(entropies.values()) < 0.1:
candidates = all_dictionary
entropies = calculate_entropies(candidates, all_words, pattern_dict, all_patterns)
Ok yes, you are correct! This logic seems to indeed be switched up & the calculations in the if-block are redundant. I think it should indeed be switched as you suggested, but we could bench the code to be sure the results are the same (or better)? We could iterate over every possible word and calculate how many guesses the bot needs on average.
I will merge your PRs later this week. Once again, many thanks for your contributions!
No problem. I agree it is better to test before merging:
I don't understand the double call to
calculate_entropies()
. Could you clarify the reason behind it?https://github.com/GillesVandewiele/Wordle-Bot/blob/f6334959105549745300ff2c1fc7f80e7c8d7a07/wordle.py#L112-L117
Indeed:
all_words
is a subset ofall_dictionary
,entropies
is a dictionary whose keys arecandidates
by design.So the second call to
calculate_entropies()
recomputes entropy values which were already computed by the first call.If the objective is to decrease the number of items fed to
max()
, it could be done by filteringentropies
returned by the first call.https://github.com/GillesVandewiele/Wordle-Bot/blob/f6334959105549745300ff2c1fc7f80e7c8d7a07/wordle.py#L119-L120