From ca400cacf04955fb3d9d7c9726e9d1a23e05a0a2 Mon Sep 17 00:00:00 2001 From: shima004 Date: Fri, 16 Oct 2026 15:32:06 +0900 Subject: [PATCH] Fix search target selection to use path planning distance --- .../src/team_name/module/complex/sample_search.py | 13 ++++++++----- .../implement/module/complex/default_search.py | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/adf_core_python/cli/template/src/team_name/module/complex/sample_search.py b/src/adf_core_python/cli/template/src/team_name/module/complex/sample_search.py index 9da8af33..55aa4bdb 100644 --- a/src/adf_core_python/cli/template/src/team_name/module/complex/sample_search.py +++ b/src/adf_core_python/cli/template/src/team_name/module/complex/sample_search.py @@ -73,13 +73,16 @@ def update_info(self, message_manager: MessageManager) -> Search: return self def calculate(self) -> Search: + position = self._agent_info.get_position_entity_id() + if position is None: + self._result = None + return self + nearest_building_id: Optional[EntityID] = None - nearest_distance: Optional[float] = None + nearest_distance = float("inf") for building_id in self._unreached_building_ids: - distance = self._world_info.get_distance( - self._agent_info.get_entity_id(), building_id - ) - if nearest_distance is None or distance < nearest_distance: + distance = self._path_planning.get_distance(position, building_id) + if distance < nearest_distance: nearest_building_id = building_id nearest_distance = distance self._result = nearest_building_id diff --git a/src/adf_core_python/implement/module/complex/default_search.py b/src/adf_core_python/implement/module/complex/default_search.py index 9d303ed2..6dacaa3b 100644 --- a/src/adf_core_python/implement/module/complex/default_search.py +++ b/src/adf_core_python/implement/module/complex/default_search.py @@ -73,13 +73,16 @@ def update_info(self, message_manager: MessageManager) -> Search: return self def calculate(self) -> Search: + position = self._agent_info.get_position_entity_id() + if position is None: + self._result = None + return self + nearest_building_id: Optional[EntityID] = None - nearest_distance: Optional[float] = None + nearest_distance = float("inf") for building_id in self._unreached_building_ids: - distance = self._world_info.get_distance( - self._agent_info.get_entity_id(), building_id - ) - if nearest_distance is None or distance < nearest_distance: + distance = self._path_planning.get_distance(position, building_id) + if distance < nearest_distance: nearest_building_id = building_id nearest_distance = distance self._result = nearest_building_id