From 0449271edc8f26d789c53db65fb99d7d6f7f46de Mon Sep 17 00:00:00 2001 From: Cynopolis Date: Tue, 3 May 2022 20:32:58 -0500 Subject: [PATCH] Added the wordle game to the program --- __pycache__/wordle_solver.cpython-39.pyc | Bin 3223 -> 3320 bytes __pycache__/wordle_tester.cpython-39.pyc | Bin 0 -> 2695 bytes cleaned_wordle_words.txt | 2 -- user_wordle.py | 27 +++++++++++++++++++++++ wordle_solver.py | 10 ++++++--- wordle_tester.py | 6 +++-- 6 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 __pycache__/wordle_tester.cpython-39.pyc create mode 100644 user_wordle.py diff --git a/__pycache__/wordle_solver.cpython-39.pyc b/__pycache__/wordle_solver.cpython-39.pyc index 9f78fa2ee90b7cf15c305f907cf0aa7c1468161c..a1a18fe6d8ef9300a9f6aad9cba6a8c7975a3657 100644 GIT binary patch delta 328 zcmbO(`9qQ~k(ZZ?0SMYI7bcw+n#d=^xND+ziTAb?i73Go$ta-|sVL!eh7{>Vj6hNb zOv-{uxkZdA@^e_CL{ddl`BMc`g;Ir6MVeVs6jBshnIsvS85tQ;6oMHvl{Q`w;b4rK z{FEbv(QdL8X9kd5%vr){KUsoHozZ2o1J_0%`H3q9s3x4-E6)e$m|Gn2@wthadGYa4 ztck^GIVn*rMfoMEQLOp#@u@|ctZpH0Zf+n7NJDrbKnf(P$x_4uG@!@;M5u!Z6CmOD z668lsu_%_@#FC66CXl!{h;W^Jf!kfv4#ac;5ira15_41IWr?FqqsH#NgnPLpqfH%FMU6tmA5$J<8u=;^Wx)gvBrad-%F5FG{vG=auZ83ikN_$ zA|DXpHd&L$UDF=KbOjMG-Fb<*sqyhe9w0GK5a9(PyeH4((PdPde4Iy(nURGV0Jgq5 A=Kufz diff --git a/__pycache__/wordle_tester.cpython-39.pyc b/__pycache__/wordle_tester.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..450915f8b76a7187497eab0c8780cb3464bcee6e GIT binary patch literal 2695 zcmZuyOK&8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0|Eu74({CEl65 zI7&W~)%i?U%lM`tX~6Sx`F+(cB&wB_;(qezTq!sx$*>n*dT`l!0%?(ue3yoa&Q4_U z;PTxk$MTg_f=C=lm6V6C;F7?v3Hc|PO%-K`Y+4csrXOc>(VDrBbC*Kc;PO6M2mg zJF;~!dU#rj^O^iPrCjv@By!?Wv>Clm0q;4hw}=OJ>;WX3_Em~dCLOc^-v%9l{~v%n Bu2}#8 literal 0 HcmV?d00001 diff --git a/cleaned_wordle_words.txt b/cleaned_wordle_words.txt index d737fc2..086e1a1 100644 --- a/cleaned_wordle_words.txt +++ b/cleaned_wordle_words.txt @@ -10900,8 +10900,6 @@ sonse sonsy sooey sooks -sooky -soole sools sooms soops diff --git a/user_wordle.py b/user_wordle.py new file mode 100644 index 0000000..ba86edb --- /dev/null +++ b/user_wordle.py @@ -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) + diff --git a/wordle_solver.py b/wordle_solver.py index 3f088f2..3ec9636 100644 --- a/wordle_solver.py +++ b/wordle_solver.py @@ -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]) \ No newline at end of file diff --git a/wordle_tester.py b/wordle_tester.py index 4f5d816..daf1260 100644 --- a/wordle_tester.py +++ b/wordle_tester.py @@ -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')