Spaces:
Sleeping
Sleeping
Fix bug in state update with mask
Browse filesFix import in wordle game simulator
- wordle_env/state.py +4 -5
- wordle_game.py +1 -1
wordle_env/state.py
CHANGED
@@ -62,7 +62,6 @@ def update_from_mask(state: WordleState, word: str, mask: List[int]) -> WordleSt
|
|
62 |
for i, c in enumerate(word):
|
63 |
cint = ord(c) - ord(WORDLE_CHARS[0])
|
64 |
offset = 1 + cint * WORDLE_N * 3
|
65 |
-
state[1 + cint] = 1
|
66 |
if mask[i] == YES:
|
67 |
prior_yes.append(c)
|
68 |
# char at position i = yes, all other chars at position i == no
|
@@ -79,9 +78,9 @@ def update_from_mask(state: WordleState, word: str, mask: List[int]) -> WordleSt
|
|
79 |
prior_maybe.append(c)
|
80 |
# Char at position i = no, and in other positions maybe except it had a value before, other chars stay as they are
|
81 |
for char_idx in range(0, WORDLE_N * 3, 3):
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
state[offset + 3 * i:offset + 3 * i + 3] = [1, 0, 0]
|
86 |
elif mask[i] == NO:
|
87 |
# Need to check this first in case there's prior maybe + yes
|
@@ -96,7 +95,7 @@ def update_from_mask(state: WordleState, word: str, mask: List[int]) -> WordleSt
|
|
96 |
state[offset + 3 * j:offset + 3 * j + 3] = [1, 0, 0]
|
97 |
else:
|
98 |
# Just straight up no
|
99 |
-
state[offset:offset+3*WORDLE_N] = [1, 0, 0]*WORDLE_N
|
100 |
return state
|
101 |
|
102 |
|
|
|
62 |
for i, c in enumerate(word):
|
63 |
cint = ord(c) - ord(WORDLE_CHARS[0])
|
64 |
offset = 1 + cint * WORDLE_N * 3
|
|
|
65 |
if mask[i] == YES:
|
66 |
prior_yes.append(c)
|
67 |
# char at position i = yes, all other chars at position i == no
|
|
|
78 |
prior_maybe.append(c)
|
79 |
# Char at position i = no, and in other positions maybe except it had a value before, other chars stay as they are
|
80 |
for char_idx in range(0, WORDLE_N * 3, 3):
|
81 |
+
char_offset = offset + char_idx
|
82 |
+
if tuple(state[char_offset: char_offset + 3]) == (0, 0, 0):
|
83 |
+
state[char_offset: char_offset + 3] = [0, 1, 0]
|
84 |
state[offset + 3 * i:offset + 3 * i + 3] = [1, 0, 0]
|
85 |
elif mask[i] == NO:
|
86 |
# Need to check this first in case there's prior maybe + yes
|
|
|
95 |
state[offset + 3 * j:offset + 3 * j + 3] = [1, 0, 0]
|
96 |
else:
|
97 |
# Just straight up no
|
98 |
+
state[offset:offset + 3 * WORDLE_N] = [1, 0, 0] * WORDLE_N
|
99 |
return state
|
100 |
|
101 |
|
wordle_game.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
from rich.prompt import Prompt
|
2 |
from rich.console import Console
|
3 |
from random import choice
|
4 |
-
from words import target_vocabulary, complete_vocabulary
|
5 |
|
6 |
SQUARES = {
|
7 |
'correct_place': '🟩',
|
|
|
1 |
from rich.prompt import Prompt
|
2 |
from rich.console import Console
|
3 |
from random import choice
|
4 |
+
from wordle_env.words import target_vocabulary, complete_vocabulary
|
5 |
|
6 |
SQUARES = {
|
7 |
'correct_place': '🟩',
|