From 4373991fcceda5076d807facf793f4a08962c4d7 Mon Sep 17 00:00:00 2001 From: shima004 Date: Thu, 12 Feb 2026 11:23:32 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=96=E7=95=8C=E6=83=85=E5=A0=B1?= =?UTF-8?q?=E3=81=AB=E3=82=A8=E3=83=B3=E3=83=86=E3=82=A3=E3=83=86=E3=82=A3?= =?UTF-8?q?=E3=81=8A=E3=82=88=E3=81=B3URN=E3=81=AB=E5=9F=BA=E3=81=A5?= =?UTF-8?q?=E3=81=8F=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/agent/info/world_info.py | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/src/adf_core_python/core/agent/info/world_info.py b/src/adf_core_python/core/agent/info/world_info.py index 0fce3a7..cc74d83 100644 --- a/src/adf_core_python/core/agent/info/world_info.py +++ b/src/adf_core_python/core/agent/info/world_info.py @@ -5,6 +5,7 @@ from rcrscore.entities.blockade import Blockade from rcrscore.entities.entity import Entity from rcrscore.entities.human import Human +from rcrscore.urn import EntityURN from rcrscore.worldmodel import ChangeSet, WorldModel @@ -54,6 +55,28 @@ def get_entity(self, entity_id: EntityID) -> Optional[Entity]: """ return self._world_model.get_entity(entity_id) + def get_entities(self) -> list[Entity]: + """ + Get all entities + + Returns + ------- + list[Entity] + Entities + """ + return self._world_model.get_entities() + + def get_entity_ids(self) -> list[EntityID]: + """ + Get all entity IDs + + Returns + ------- + list[EntityID] + Entity IDs + """ + return [entity.get_entity_id() for entity in self._world_model.get_entities()] + def get_entity_ids_of_types(self, entity_types: list[type[Entity]]) -> list[EntityID]: """ Get the entity IDs of the specified types @@ -96,6 +119,45 @@ def get_entities_of_types(self, entity_types: list[type[Entity]]) -> list[Entity return entities + def get_entity_ids_of_urns(self, urns: list[EntityURN]) -> list[EntityID]: + """ + Get the entity IDs of the specified URNs + + Parameters + ---------- + urns : list[EntityURN] + List of entity URNs + + Returns + ------- + list[EntityID] + Entity IDs + """ + entity_ids: list[EntityID] = [] + for entity in self._world_model.get_entities(): + if entity.get_urn() in urns: + entity_ids.append(entity.get_entity_id()) + + return entity_ids + + def get_entities_of_urns(self, urns: list[EntityURN]) -> list[Entity]: + """ + Get the entities of the specified URNs + Parameters + ---------- + urns : list[EntityURN] + List of entity URNs + Returns + ------- + list[Entity] + Entities + """ + entities: list[Entity] = [] + for entity in self._world_model.get_entities(): + if entity.get_urn() in urns: + entities.append(entity) + return entities + def get_distance(self, entity_id1: EntityID, entity_id2: EntityID) -> float: """ Get the distance between two entities