From 44c4ee6ca77e17e4ae9ba7a9d9829e8fbd70eb43 Mon Sep 17 00:00:00 2001 From: ToB213 Date: Thu, 17 Sep 2026 20:10:41 +0900 Subject: [PATCH] fix: return infinity when no A* path exists --- .../implement/module/algorithm/a_star_path_planning.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/adf_core_python/implement/module/algorithm/a_star_path_planning.py b/src/adf_core_python/implement/module/algorithm/a_star_path_planning.py index 8b2741a..120aacf 100644 --- a/src/adf_core_python/implement/module/algorithm/a_star_path_planning.py +++ b/src/adf_core_python/implement/module/algorithm/a_star_path_planning.py @@ -84,6 +84,9 @@ def reconstruct_path( def get_distance(self, from_entity_id: EntityID, to_entity_id: EntityID) -> float: path: list[EntityID] = self.get_path(from_entity_id, to_entity_id) + if not path: + return float("inf") + distance: float = 0.0 for i in range(len(path) - 1): distance += self.distance(path[i], path[i + 1])