From c22e86e22b840e824b4891a3b04c68f3751200fa Mon Sep 17 00:00:00 2001 From: Pawel Felcyn Date: Sat, 22 Apr 2023 18:06:50 +0200 Subject: [PATCH] fix bfs --- bfs.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bfs.py b/bfs.py index 6c1afb7..9373df7 100644 --- a/bfs.py +++ b/bfs.py @@ -16,19 +16,19 @@ class Succ: def find_path_to_nearest_can(startState: AgentState, grid: Dict[Tuple[int, int], GridCellType]) -> list[AgentActionType]: q: Queue[list[Succ]] = Queue() - visited: list[Tuple[int, int]] = [] + visited: list[AgentState] = [] startStates: list[Succ] = [Succ(startState, AgentActionType.UNKNOWN)] q.put(startStates) while not q.empty(): currently_checked = q.get() - visited.append(currently_checked[-1].state.position) + visited.append(currently_checked[-1].state) if is_state_success(currently_checked[-1].state, grid): return extract_actions(currently_checked) successors = succ(currently_checked[-1].state) for s in successors: already_visited = False for v in visited: - if v[0] == s.state.position[0] and v[1] == s.state.position[1]: + if v.position[0] == s.state.position[0] and v.position[1] == s.state.position[1] and s.state.orientation == v.orientation: already_visited = True break if already_visited: