Changed the word list to the actual word list
This commit is contained in:
Binary file not shown.
12974
cleaned_wordle_words.txt
Normal file
12974
cleaned_wordle_words.txt
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
input_file_path = 'source_words.txt'
|
||||
output_file_path = 'cleaned_words.txt'
|
||||
input_file_path = 'wordle_words_source.txt'
|
||||
output_file_path = 'cleaned_wordle_words.txt'
|
||||
|
||||
input_file = open(input_file_path, 'r')
|
||||
output_file = open(output_file_path, 'w')
|
||||
@@ -12,9 +12,13 @@ def is_only_letters(word):
|
||||
|
||||
|
||||
for line in input_file:
|
||||
word = line.strip()
|
||||
if is_five_characters(word) and is_only_letters(word):
|
||||
output_file.write(word.lower() + '\n')
|
||||
words = line.split(",")
|
||||
print(len(words))
|
||||
for i, word in enumerate(words):
|
||||
word = ''.join(filter(str.isalpha, word))
|
||||
if is_five_characters(word):
|
||||
output_file.write(word + '\n')
|
||||
print(words)
|
||||
|
||||
input_file.close()
|
||||
output_file.close()
|
||||
output_file.close()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from math import log
|
||||
|
||||
input_file_path = 'cleaned_words.txt'
|
||||
input_file_path = 'cleaned_wordle_words.txt'
|
||||
|
||||
dictionary = open(input_file_path, 'r')
|
||||
|
||||
@@ -84,8 +84,8 @@ def words_letter_not_position(guess, dictionary):
|
||||
if word[i] == letter and value == True:
|
||||
match -= 1
|
||||
#print(word, word[i], letter, i, value, match)
|
||||
if match == 5:
|
||||
valid_words.append(word)
|
||||
if match == 5:
|
||||
valid_words.append(word)
|
||||
return valid_words
|
||||
|
||||
def get_dict_stats(dictionary):
|
||||
@@ -120,4 +120,29 @@ def get_entropy(guess, dict_stats):
|
||||
|
||||
def entropy_sort_list(dictionary, dict_stats):
|
||||
# sort valid_words according to entropy
|
||||
return dictionary.sort(key=lambda word: get_entropy(word, dict_stats))
|
||||
return dictionary.sort(key=lambda word: get_entropy(word, dict_stats))
|
||||
|
||||
|
||||
def wordle_guess(not_letters, has_letters, position_letters, not_position_letters):
|
||||
input_file_path = 'cleaned_wordle_words.txt'
|
||||
dictionary = open(input_file_path, 'r')
|
||||
guesses = read_in_dict(dictionary)
|
||||
guesses = words_without_letters(not_letters, guesses)
|
||||
guesses = words_with_letters(has_letters, guesses)
|
||||
guesses = words_with_letter_positions(position_letters, guesses)
|
||||
guesses = words_letter_not_position(not_position_letters, guesses)
|
||||
|
||||
dict_stats = get_dict_stats(guesses)
|
||||
entropy_sort_list(guesses, dict_stats)
|
||||
dictionary.close()
|
||||
|
||||
return guesses
|
||||
|
||||
if __name__ == "__main__":
|
||||
not_letters = ""
|
||||
has_letters = ""
|
||||
position_letters = "_____"
|
||||
not_position_letters = {
|
||||
}
|
||||
|
||||
print(wordle_guess(not_letters, has_letters, position_letters, not_position_letters)[:10])
|
||||
@@ -1,10 +1,13 @@
|
||||
import wordle_solver
|
||||
import multiprocessing as mul
|
||||
|
||||
def wordle_guess(not_letters, has_letters, position_letters, not_position_letters):
|
||||
input_file_path = 'cleaned_words.txt'
|
||||
dictionary = open(input_file_path, 'r')
|
||||
guesses = wordle_solver.read_in_dict(dictionary)
|
||||
def wordle_guess(not_letters, has_letters, position_letters, not_position_letters, guesses = None):
|
||||
if guesses == None:
|
||||
input_file_path = 'cleaned_wordle_words.txt'
|
||||
dictionary = open(input_file_path, 'r')
|
||||
guesses = wordle_solver.read_in_dict(dictionary)
|
||||
dictionary.close()
|
||||
|
||||
guesses = wordle_solver.words_without_letters(not_letters, guesses)
|
||||
guesses = wordle_solver.words_with_letters(has_letters, guesses)
|
||||
guesses = wordle_solver.words_with_letter_positions(position_letters, guesses)
|
||||
@@ -12,8 +15,6 @@ def wordle_guess(not_letters, has_letters, position_letters, not_position_letter
|
||||
|
||||
dict_stats = wordle_solver.get_dict_stats(guesses)
|
||||
wordle_solver.entropy_sort_list(guesses, dict_stats)
|
||||
dictionary.close()
|
||||
|
||||
return guesses
|
||||
|
||||
def check_guess(guess, word, not_letters, has_letters, position_letters, not_position_letters):
|
||||
@@ -38,7 +39,7 @@ def check_guess(guess, word, not_letters, has_letters, position_letters, not_pos
|
||||
|
||||
return not_letters, has_letters, position_letters, not_position_letters
|
||||
|
||||
def get_word_stats(word):
|
||||
def get_word_stats(word, dictionary_path):
|
||||
words =[word]
|
||||
total_num_guesses = 0
|
||||
not_letters = ""
|
||||
@@ -50,10 +51,14 @@ def get_word_stats(word):
|
||||
percentage = 0
|
||||
last_percentage = 0
|
||||
|
||||
dictionary = open(dictionary_path, 'r')
|
||||
guess = wordle_solver.read_in_dict(dictionary)
|
||||
dictionary.close()
|
||||
|
||||
for total_words, word in enumerate(words):
|
||||
for x in range(20):
|
||||
total_num_guesses += 1
|
||||
guess = wordle_guess(not_letters, has_letters, position_letters, not_position_letters)
|
||||
guess = wordle_guess(not_letters, has_letters, position_letters, not_position_letters, guesses=guess)
|
||||
if len(guess) == 0:
|
||||
print("No more guesses")
|
||||
exit()
|
||||
@@ -83,7 +88,7 @@ def get_word_stats(word):
|
||||
from time import time
|
||||
if __name__ == "__main__":
|
||||
alphabet = list("ab")
|
||||
input_file_path = 'cleaned_words.txt'
|
||||
input_file_path = 'cleaned_wordle_words.txt'
|
||||
dictionary = open(input_file_path, 'r')
|
||||
words = wordle_solver.read_in_dict(dictionary)
|
||||
dictionary.close()
|
||||
@@ -94,7 +99,7 @@ if __name__ == "__main__":
|
||||
results = []
|
||||
|
||||
for i, word in enumerate(words):
|
||||
results.append(testers.apply_async(get_word_stats, (word,)))
|
||||
results.append(testers.apply_async(get_word_stats, (word,input_file_path,)))
|
||||
if i % 100 == 0:
|
||||
print(i, "words tested")
|
||||
print("Recovering Results")
|
||||
@@ -107,4 +112,4 @@ if __name__ == "__main__":
|
||||
print("Timed out")
|
||||
|
||||
print("Time taken:", time() - timer)
|
||||
print("The average number of guesses per {} word is " + str(total_guesses/10))
|
||||
print("The average number of guesses per word is " + str(total_guesses/len(words)))
|
||||
3
wordle_words_source.txt
Normal file
3
wordle_words_source.txt
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user