-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
57 lines (48 loc) · 1.53 KB
/
main.py
File metadata and controls
57 lines (48 loc) · 1.53 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from random import choices
from turtle import color
from WordleSolver import WordleSolver
import json
def stringToColor(s):
res = ""
for num in s:
if num == '0':
res += '⬜️'
elif num == '1':
res += '🟩️'
else:
res += '🟨'
return res
def printGuess(guess, wordle, remain):
if guess and wordle:
print("Guess : {} {} There are {} remains".format(guess, wordle, remain))
else:
print("There are {} remains".format(remain))
def loadJson(jsonURL):
f = open(jsonURL)
choices = json.load(f)
f.close
return choices
def main():
choices = loadJson('./data/actualWords.json')
Solver = WordleSolver(choices)
print('If the guess pop Not in word list enter 99999')
guessWord, colors = "", ""
while True:
currentRemaining = Solver.getNumberOfChoices()
printGuess(guessWord, colors, currentRemaining)
guess = Solver.popOneGuess() # In number
guessWord = Solver.numToWord(guess) # In char
wordle = ""
while len(wordle) != 5 and not wordle.isdigit():
wordle = input("Guess : {} ".format(guessWord))
if wordle == '99999':
continue
print ('\033[1A''\033[F') # To clean print
colors = stringToColor(wordle)
Solver.calculateRemain(wordle, guess)
if wordle == '11111':
printGuess(guessWord, colors, currentRemaining)
print('Congratulations!')
break
if __name__ == "__main__":
main()