Added the wordle game to the program
This commit is contained in:
Binary file not shown.
BIN
__pycache__/wordle_tester.cpython-39.pyc
Normal file
BIN
__pycache__/wordle_tester.cpython-39.pyc
Normal file
Binary file not shown.
@@ -10900,8 +10900,6 @@ sonse
|
||||
sonsy
|
||||
sooey
|
||||
sooks
|
||||
sooky
|
||||
soole
|
||||
sools
|
||||
sooms
|
||||
soops
|
||||
|
||||
27
user_wordle.py
Normal file
27
user_wordle.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import wordle_solver
|
||||
import wordle_tester
|
||||
from random import randint
|
||||
|
||||
input_file_path = 'cleaned_wordle_words.txt'
|
||||
dictionary = open(input_file_path, 'r')
|
||||
words = wordle_solver.read_in_dict(dictionary)
|
||||
dictionary.close()
|
||||
|
||||
word = words[randint(0, len(words) - 1)]
|
||||
|
||||
not_letters = ""
|
||||
has_letters = ""
|
||||
position_letters = "_____"
|
||||
not_position_letters = {}
|
||||
|
||||
for i in range(7):
|
||||
print(wordle_solver.wordle_guess(not_letters, has_letters, position_letters, not_position_letters)[:10])
|
||||
user_input = ""
|
||||
while len(user_input) != 5 and not user_input.isalpha():
|
||||
user_input = input("Guess a word ({}/6): ".format(i+1))
|
||||
if user_input == word:
|
||||
print("You win! The word is {}!".format(word))
|
||||
exit()
|
||||
not_letters, has_letters, position_letters, not_position_letters = wordle_tester.check_guess(user_input, word, not_letters, has_letters, position_letters, not_position_letters)
|
||||
print("Current state: " + position_letters)
|
||||
|
||||
@@ -139,10 +139,14 @@ def wordle_guess(not_letters, has_letters, position_letters, not_position_letter
|
||||
return guesses
|
||||
|
||||
if __name__ == "__main__":
|
||||
not_letters = ""
|
||||
has_letters = ""
|
||||
position_letters = "_____"
|
||||
not_letters = "asfld"
|
||||
has_letters = "rote"
|
||||
position_letters = "o__er"
|
||||
not_position_letters = {
|
||||
'r' : [False, True, False, False, False],
|
||||
'o' : [False, True, True, False, False],
|
||||
'e' : [False, True, False, False, True],
|
||||
't' : [False, False, True, False, False],
|
||||
}
|
||||
|
||||
print(wordle_guess(not_letters, has_letters, position_letters, not_position_letters)[:10])
|
||||
@@ -1,5 +1,4 @@
|
||||
import wordle_solver
|
||||
import multiprocessing as mul
|
||||
|
||||
def wordle_guess(not_letters, has_letters, position_letters, not_position_letters, guesses = None):
|
||||
if guesses == None:
|
||||
@@ -85,8 +84,11 @@ def get_word_stats(word, dictionary_path):
|
||||
break
|
||||
return total_num_guesses
|
||||
|
||||
from time import time
|
||||
|
||||
if __name__ == "__main__":
|
||||
import multiprocessing as mul
|
||||
from time import time
|
||||
|
||||
alphabet = list("ab")
|
||||
input_file_path = 'cleaned_wordle_words.txt'
|
||||
dictionary = open(input_file_path, 'r')
|
||||
|
||||
Reference in New Issue
Block a user