Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6d229ce

Browse files
committed
simplified condition in search.py
1 parent c74933a commit 6d229ce

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

search.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,8 +738,7 @@ def actions(self, state):
738738
allowed_actions = []
739739
for action in self.defined_actions:
740740
next_state = vector_add(state, self.defined_actions[action])
741-
if next_state[0] >= 0 and next_state[1] >= 0 and next_state[0] <= self.n - 1 and next_state[
742-
1] <= self.m - 1:
741+
if 0 <= next_state[0] <= self.n - 1 and 0 <= next_state[1] <= self.m - 1:
743742
allowed_actions.append(action)
744743

745744
return allowed_actions

tests/test_search.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ def manhattan(node):
162162
index_goal = {0: [2, 2], 1: [0, 0], 2: [0, 1], 3: [0, 2], 4: [1, 0], 5: [1, 1], 6: [1, 2], 7: [2, 0], 8: [2, 1]}
163163
index_state = {}
164164
index = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2]]
165-
x, y = 0, 0
166165

167166
for i in range(len(state)):
168167
index_state[state[i]] = index[i]

0 commit comments

Comments
 (0)