diff --git a/project_constants.py b/project_constants.py index 4c62b9c..232efa8 100644 --- a/project_constants.py +++ b/project_constants.py @@ -72,8 +72,8 @@ class Coords(Enum): class Terrain(Enum): CONCRETE = 2 - GRASS = 10 - MUD = 20 + GRASS = 5 + MUD = 8 # =============== # diff --git a/resources/minefields/fourthmap.json b/resources/minefields/fourthmap.json index 6fb4e11..6bcec3c 100644 --- a/resources/minefields/fourthmap.json +++ b/resources/minefields/fourthmap.json @@ -173,7 +173,7 @@ "mine": null }, "3,5": { - "terrain": "MUD", + "terrain": "GRASS", "mine": null }, "3,6": { diff --git a/searching_algorithms/a_star.py b/searching_algorithms/a_star.py index 2925330..c87ed90 100644 --- a/searching_algorithms/a_star.py +++ b/searching_algorithms/a_star.py @@ -152,7 +152,7 @@ def graphsearch(initial_state: State, fringe_states.add((new_node.state.row, new_node.state.column, new_node.state.direction)) # update weight if it's lower - elif successor_state in fringe and entry_finder[successor_state][0] > priority: + elif successor_state in fringe_states and entry_finder[successor_state][0] > priority: update_priority(fringe, new_node, priority) else: @@ -184,7 +184,7 @@ counter = itertools.count() # unique sequence count def add_node(heap, node: Node, priority): count = next(counter) entry = [priority, count, node] - entry_finder[node.state] = entry + entry_finder[(node.state.row, node.state.column, node.state.direction)] = entry heappush(heap, entry) @@ -192,12 +192,12 @@ def pop_node(heap): while heap: priority, count, node = heappop(heap) if node is not REMOVED: - del entry_finder[node.state] + del entry_finder[(node.state.row, node.state.column, node.state.direction)] return node return None def update_priority(heap, new_node, new_priority): - old_entry = entry_finder.pop(new_node.state) + old_entry = entry_finder.pop((new_node.state.row, new_node.state.column, new_node.state.direction)) old_entry[-1] = REMOVED add_node(heap, new_node, new_priority)