-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsolution_tester.py
36 lines (31 loc) · 1.12 KB
/
solution_tester.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from wordle_dictionary import Hint
import wordle_dictionary as wd
import solver
def main():
ALL_WORDS = wd.get_presentables()
cracked_on = [0] * 7
default_possibles = {word : solver.weigh_word(word) for word in wd.get_guessables()}
# Test all words
for windex, w in enumerate(ALL_WORDS):
print(f"{windex:4}/{len(ALL_WORDS):4}") if windex % 100 == 0 else ...
# Initialize
best_guess = ""
hints = []
possibles = {k : v for k, v in default_possibles.items()}
for i in range(6):
# Provide guess
best_guess, possibles = solver.solve_step(best_guess, hints, possibles)
# Get results of best guess
if best_guess == w:
cracked_on[i+1] += 1
break
hints = wd.validate_guess(best_guess, w)
else:
cracked_on[0] += 1
for turn, solutions in enumerate(cracked_on):
if turn == 0:
print(f"Unsolved:\t{solutions}")
else:
print(f"Turn {turn}:\t\t{solutions}")
if __name__ == "__main__":
main()