Skip to content

Commit 6504c31

Browse files
pre-commit-ci[bot]JadeKim042386
authored andcommitted
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 0aed998 commit 6504c31

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

Diff for: graphs/greedy_best_first.py

+13-10
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
TEST_GRIDS = [
1111
[
1212
[0, 0, 0, 0, 0, 0, 0],
13-
[0, 1, 0, 0, 0, 0, 0],
13+
[0, 1, 0, 0, 0, 0, 0],
1414
[0, 0, 0, 0, 0, 0, 0],
1515
[0, 0, 1, 0, 0, 0, 0],
1616
[1, 0, 1, 0, 0, 0, 0],
@@ -23,16 +23,16 @@
2323
[0, 0, 0, 1, 1, 0, 0],
2424
[0, 1, 0, 0, 1, 0, 0],
2525
[1, 0, 0, 1, 1, 0, 1],
26-
[0, 0, 0, 0, 0, 0, 0]
26+
[0, 0, 0, 0, 0, 0, 0],
2727
],
2828
[
2929
[0, 0, 1, 0, 0],
3030
[0, 1, 0, 0, 0],
3131
[0, 0, 1, 0, 1],
3232
[1, 0, 0, 1, 1],
33-
[0, 0, 0, 0, 0]
34-
]
35-
]
33+
[0, 0, 0, 0, 0],
34+
],
35+
]
3636

3737
delta = ([-1, 0], [0, -1], [1, 0], [0, 1]) # up, left, down, right
3838

@@ -82,7 +82,7 @@ def calculate_heuristic(self) -> float:
8282

8383
def __lt__(self, other) -> bool:
8484
return self.f_cost < other.f_cost
85-
85+
8686
def __eq__(self, other):
8787
return self.pos == other.pos
8888

@@ -104,7 +104,9 @@ class GreedyBestFirst:
104104
(4, 4)]
105105
"""
106106

107-
def __init__(self, grid: list[list[int]], start: tuple[int, int], goal: tuple[int, int]):
107+
def __init__(
108+
self, grid: list[list[int]], start: tuple[int, int], goal: tuple[int, int]
109+
):
108110
self.grid = grid
109111
self.start = Node(start[1], start[0], goal[1], goal[0], 0, None)
110112
self.target = Node(goal[1], goal[0], goal[1], goal[0], 99999, None)
@@ -151,10 +153,11 @@ def get_successors(self, parent: Node) -> list[Node]:
151153
pos_x = parent.pos_x + action[1]
152154
pos_y = parent.pos_y + action[0]
153155

154-
if (0 <= pos_x <= len(self.grid[0]) - 1
156+
if (
157+
0 <= pos_x <= len(self.grid[0]) - 1
155158
and 0 <= pos_y <= len(self.grid) - 1
156-
and self.grid[pos_y][pos_x] == 0):
157-
159+
and self.grid[pos_y][pos_x] == 0
160+
):
158161
successors.append(
159162
Node(
160163
pos_x,

0 commit comments

Comments
 (0)