1414from adf_core_python .core .component .module .algorithm .clustering import Clustering
1515from adf_core_python .core .component .module .algorithm .path_planning import PathPlanning
1616from adf_core_python .core .component .module .complex .search import Search
17+ from adf_core_python .core .logger .logger import get_agent_logger
1718
1819
1920class DefaultSearch (Search ):
@@ -29,7 +30,7 @@ def __init__(
2930 agent_info , world_info , scenario_info , module_manager , develop_data
3031 )
3132
32- self ._unsearched_building_ids : set [EntityID ] = set ()
33+ self ._unreached_building_ids : set [EntityID ] = set ()
3334 self ._result : Optional [EntityID ] = None
3435
3536 self ._clustering : Clustering = cast (
@@ -48,6 +49,11 @@ def __init__(
4849 ),
4950 )
5051
52+ self ._logger = get_agent_logger (
53+ f"{ self .__class__ .__module__ } .{ self .__class__ .__qualname__ } " ,
54+ self ._agent_info ,
55+ )
56+
5157 self .register_sub_module (self ._clustering )
5258 self .register_sub_module (self ._path_planning )
5359
@@ -56,18 +62,22 @@ def update_info(self, message_manager: MessageManager) -> Search:
5662 if self .get_count_update_info () > 1 :
5763 return self
5864
65+ self ._logger .debug (
66+ f"unreached_building_ids: { [str (id ) for id in self ._unreached_building_ids ]} "
67+ )
68+
5969 searched_building_id = self ._agent_info .get_position_entity_id ()
60- self ._unsearched_building_ids .discard (searched_building_id )
70+ self ._unreached_building_ids .discard (searched_building_id )
6171
62- if len (self ._unsearched_building_ids ) == 0 :
63- self ._unsearched_building_ids = self ._get_search_targets ()
72+ if len (self ._unreached_building_ids ) == 0 :
73+ self ._unreached_building_ids = self ._get_search_targets ()
6474
6575 return self
6676
6777 def calculate (self ) -> Search :
6878 nearest_building_id : Optional [EntityID ] = None
6979 nearest_distance : Optional [float ] = None
70- for building_id in self ._unsearched_building_ids :
80+ for building_id in self ._unreached_building_ids :
7181 distance = self ._world_info .get_distance (
7282 self ._agent_info .get_entity_id (), building_id
7383 )
0 commit comments