-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.py
42 lines (33 loc) · 990 Bytes
/
game.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
37
38
39
40
41
42
from unittest import result
from main import *
from utils import *
correctWord = "elder"
def getCombo(guess):
combo = ""
for i in range(len(guess)):
if guess[i] == correctWord[i]:
combo += "G"
elif guess[i] in correctWord and guess[i] != correctWord[i]:
combo += "Y"
else:
combo += "B"
return combo
def runGame():
guess = "adieu"
guessesLeft = 5
while guessesLeft > 0:
guess = guess.strip("\n")
print("GUESS: " + guess + " LENGTH: " + str(len(guess)))
comboIndex = comboToIndex(getCombo(guess))
results = getNewDict(comboIndex,guess)
changeDict(results)
print(len(results))
maxBit = 0
for word in results:
bit = (probDistribution(word))
if bit > maxBit:
maxBit = bit
guess = word
print("REMAINING WORDS:" + str(results))
guessesLeft-=1
runGame()