diff --git a/adf_core_python/core/agent/agent.py b/adf_core_python/core/agent/agent.py deleted file mode 100644 index ae19b1e..0000000 --- a/adf_core_python/core/agent/agent.py +++ /dev/null @@ -1,30 +0,0 @@ -from rcrs_core.entities.entity import Entity - -from adf_core_python.core.agent.config.module_config import ModuleConfig -from adf_core_python.core.agent.develop.develop_data import DevelopData -from adf_core_python.core.agent.info.scenario_info import Mode -from adf_core_python.core.agent.precompute.precompute_data import PrecomputeData - - -class Agent(Entity): - def __init__( - self, - team_name: str, - is_precompute: bool, - is_debug: bool, - data_storage_name: str, - module_config: ModuleConfig, - develop_data: DevelopData, - ): - self._tema_name = team_name - self._is_precompute = is_precompute - self._is_debug = is_debug - - if self._is_precompute: - # PrecomputeData.remove_data(data_storage_name) - self._mode = Mode.PRECOMPUTATION - - self._module_config: ModuleConfig = module_config - self._develop_data: DevelopData = develop_data - self._precompute_data: PrecomputeData = PrecomputeData(data_storage_name) - self._message_manager = None diff --git a/adf_core_python/core/agent/config/module_config.py b/adf_core_python/core/agent/config/module_config.py index 095cb50..72a292a 100644 --- a/adf_core_python/core/agent/config/module_config.py +++ b/adf_core_python/core/agent/config/module_config.py @@ -79,11 +79,12 @@ def _flatten( dict[str, Any] Flattened dictionary """ - flatten_data = {} + flatten_data: dict[str, Any] = {} for key, value in data.items(): new_key = f"{parent_key}{sep}{key}" if parent_key else key if isinstance(value, dict): - flatten_data.update(self._flatten(value, new_key, sep=sep)) + v: dict[str, Any] = value + flatten_data.update(self._flatten(v, new_key, sep=sep)) else: flatten_data[new_key] = value return flatten_data diff --git a/adf_core_python/core/agent/info/agent_info.py b/adf_core_python/core/agent/info/agent_info.py index d65070c..030de23 100644 --- a/adf_core_python/core/agent/info/agent_info.py +++ b/adf_core_python/core/agent/info/agent_info.py @@ -2,8 +2,11 @@ from typing import Any from rcrs_core.agents.agent import Agent +from rcrs_core.entities.entity import Entity from rcrs_core.entities.human import Human -from rcrs_core.worldmodel.worldmodel import ChangeSet, Entity, EntityID, WorldModel +from rcrs_core.worldmodel.changeSet import ChangeSet +from rcrs_core.worldmodel.entityID import EntityID +from rcrs_core.worldmodel.worldmodel import WorldModel from adf_core_python.core.agent.action.action import Action @@ -97,7 +100,7 @@ def get_position_entity_id(self) -> EntityID: """ entity = self._world_model.get_entity(self.get_entity_id()) if isinstance(entity, Human): - return entity.get_position_property() + return entity.get_position() else: return entity.get_id() diff --git a/adf_core_python/implement/tactics/default_tactics_ambulance_team.py b/adf_core_python/implement/tactics/default_tactics_ambulance_team.py index 45c7707..8666e14 100644 --- a/adf_core_python/implement/tactics/default_tactics_ambulance_team.py +++ b/adf_core_python/implement/tactics/default_tactics_ambulance_team.py @@ -111,21 +111,23 @@ def think( entity_id = agent_info.get_entity_id() # noqa: F841 target_entity_id = self._human_detector.calculate().get_target_entity_id() - action = ( - self._action_transport.set_target_entity_id(target_entity_id) - .calc() - .get_action() - ) - if action is not None: - return action + if target_entity_id is not None: + action = ( + self._action_transport.set_target_entity_id(target_entity_id) + .calc() + .get_action() + ) + if action is not None: + return action target_entity_id = self._search.calculate().get_target_entity_id() - action = ( - self._action_ext_move.set_target_entity_id(target_entity_id) - .calc() - .get_action() - ) - if action is not None: - return action + if target_entity_id is not None: + action = ( + self._action_ext_move.set_target_entity_id(target_entity_id) + .calc() + .get_action() + ) + if action is not None: + return action return ActionRest() diff --git a/adf_core_python/implement/tactics/default_tactics_fire_brigade.py b/adf_core_python/implement/tactics/default_tactics_fire_brigade.py index 11b38af..2af3378 100644 --- a/adf_core_python/implement/tactics/default_tactics_fire_brigade.py +++ b/adf_core_python/implement/tactics/default_tactics_fire_brigade.py @@ -110,21 +110,23 @@ def think( entity_id = agent_info.get_entity_id() # noqa: F841 target_entity_id = self._human_detector.calculate().get_target_entity_id() - action = ( - self._action_fire_rescue.set_target_entity_id(target_entity_id) - .calc() - .get_action() - ) - if action is not None: - return action + if target_entity_id is not None: + action = ( + self._action_fire_rescue.set_target_entity_id(target_entity_id) + .calc() + .get_action() + ) + if action is not None: + return action target_entity_id = self._search.calculate().get_target_entity_id() - action = ( - self._action_ext_move.set_target_entity_id(target_entity_id) - .calc() - .get_action() - ) - if action is not None: - return action + if target_entity_id is not None: + action = ( + self._action_ext_move.set_target_entity_id(target_entity_id) + .calc() + .get_action() + ) + if action is not None: + return action return ActionRest() diff --git a/adf_core_python/implement/tactics/default_tactics_police_force.py b/adf_core_python/implement/tactics/default_tactics_police_force.py index bd4f29d..3253aeb 100644 --- a/adf_core_python/implement/tactics/default_tactics_police_force.py +++ b/adf_core_python/implement/tactics/default_tactics_police_force.py @@ -114,21 +114,23 @@ def think( entity_id = agent_info.get_entity_id() # noqa: F841 target_entity_id = self._road_detector.calculate().get_target_entity_id() - action = ( - self._action_ext_clear.set_target_entity_id(target_entity_id) - .calc() - .get_action() - ) - if action is not None: - return action + if target_entity_id is not None: + action = ( + self._action_ext_clear.set_target_entity_id(target_entity_id) + .calc() + .get_action() + ) + if action is not None: + return action target_entity_id = self._search.calculate().get_target_entity_id() - action = ( - self._action_ext_clear.set_target_entity_id(target_entity_id) - .calc() - .get_action() - ) - if action is not None: - return action + if target_entity_id is not None: + action = ( + self._action_ext_clear.set_target_entity_id(target_entity_id) + .calc() + .get_action() + ) + if action is not None: + return action return ActionRest() diff --git a/poetry.lock b/poetry.lock index 2f0e6c9..d7a68ff 100644 --- a/poetry.lock +++ b/poetry.lock @@ -347,7 +347,7 @@ rtree = "*" type = "git" url = "https://github.com/adf-python/rcrs-core-python" reference = "HEAD" -resolved_reference = "7b0d4ef8d6c1205c00f9e197c5833a3939f482b2" +resolved_reference = "bd42a563fee818496ce4c020a7ec82c4b5c67042" [[package]] name = "rtree" diff --git a/pyrightconfig.json b/pyrightconfig.json new file mode 100644 index 0000000..8a1eb70 --- /dev/null +++ b/pyrightconfig.json @@ -0,0 +1,4 @@ +{ + "typeCheckingMode": "standard", + "exclude": ["**/site-packages"] +}