santit96 commited on
Commit
b1caebb
·
1 Parent(s): d9e6245

Fix complex case test and update state updater

Browse files
Files changed (2) hide show
  1. wordle_env/state.py +5 -1
  2. wordle_env/test_wordle.py +2 -3
wordle_env/state.py CHANGED
@@ -171,7 +171,11 @@ def update(state: WordleState, word: str, goal_word: str) -> Tuple[WordleState,
171
  # Char at all positions = no
172
  state[offset:offset + 3 * WORDLE_N] = [1, 0, 0] * WORDLE_N
173
  else: # goal_word.count(c) <= processed_letters.count(c) and goal in word
174
- # Only information at this point is that char at position i = no
175
  state[offset + 3 * i:offset + 3 * i + 3] = [1, 0, 0]
 
 
 
 
176
  processed_letters.append(c)
177
  return state, reward
 
171
  # Char at all positions = no
172
  state[offset:offset + 3 * WORDLE_N] = [1, 0, 0] * WORDLE_N
173
  else: # goal_word.count(c) <= processed_letters.count(c) and goal in word
174
+ # At i and in every position which is not set = no
175
  state[offset + 3 * i:offset + 3 * i + 3] = [1, 0, 0]
176
+ for char_idx in range(0, WORDLE_N * 3, 3):
177
+ char_offset = offset + char_idx
178
+ if tuple(state[char_offset: char_offset + 3]) == (0, 0, 0):
179
+ state[char_offset: char_offset + 3] = [1, 0, 0]
180
  processed_letters.append(c)
181
  return state, reward
wordle_env/test_wordle.py CHANGED
@@ -161,7 +161,6 @@ def test_step(wordleEnv):
161
  1, 0, 0,
162
  0, 0, 1,
163
  0, 1, 0)
164
- print(new_state, letter_state)
165
  letter_test('A', new_state, letter_state)
166
 
167
  # Expect P to be right in position 1 2 no in 3 and maybe in 4
@@ -288,6 +287,6 @@ def test_special_step_cases(wordleEnv):
288
  letter_state = (1, 0, 0,
289
  0, 0, 1,
290
  1, 0, 0,
291
- 0, 0, 0,
292
- 0, 0, 0)
293
  letter_test('P', new_state, letter_state)
 
161
  1, 0, 0,
162
  0, 0, 1,
163
  0, 1, 0)
 
164
  letter_test('A', new_state, letter_state)
165
 
166
  # Expect P to be right in position 1 2 no in 3 and maybe in 4
 
287
  letter_state = (1, 0, 0,
288
  0, 0, 1,
289
  1, 0, 0,
290
+ 1, 0, 0,
291
+ 1, 0, 0)
292
  letter_test('P', new_state, letter_state)