Skip to content

Commit cfea3be

Browse files
committed
refactor: delete unnecessary continue
1 parent a0f78d5 commit cfea3be

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

Diff for: graphs/greedy_best_first.py

+10-15
Original file line numberDiff line numberDiff line change
@@ -136,22 +136,17 @@ def get_successors(self, parent: Node) -> list[Node]:
136136
pos_x = parent.pos_x + action[1]
137137
pos_y = parent.pos_y + action[0]
138138

139-
if not (0 <= pos_x <= len(grid[0]) - 1 and 0 <= pos_y <= len(grid) - 1):
140-
continue
141-
142-
if grid[pos_y][pos_x] != 0:
143-
continue
144-
145-
successors.append(
146-
Node(
147-
pos_x,
148-
pos_y,
149-
self.target.pos_x,
150-
self.target.pos_y,
151-
parent.g_cost + 1,
152-
parent,
139+
if 0 <= pos_x <= len(grid[0]) - 1 and 0 <= pos_y <= len(grid) - 1 and grid[pos_y][pos_x] == 0:
140+
successors.append(
141+
Node(
142+
pos_x,
143+
pos_y,
144+
self.target.pos_x,
145+
self.target.pos_y,
146+
parent.g_cost + 1,
147+
parent,
148+
)
153149
)
154-
)
155150
return successors
156151

157152
def retrace_path(self, node: Node | None) -> Path:

0 commit comments

Comments
 (0)