Skip to content

Commit 89f3718

Browse files
authored
Merge pull request #56 from adf-python/refactor_55
一部型でエラーが出ている部分の修正と整理
2 parents 533157a + 2b77855 commit 89f3718

File tree

8 files changed

+61
-77
lines changed

8 files changed

+61
-77
lines changed

adf_core_python/core/agent/agent.py

Lines changed: 0 additions & 30 deletions
This file was deleted.

adf_core_python/core/agent/config/module_config.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,12 @@ def _flatten(
7979
dict[str, Any]
8080
Flattened dictionary
8181
"""
82-
flatten_data = {}
82+
flatten_data: dict[str, Any] = {}
8383
for key, value in data.items():
8484
new_key = f"{parent_key}{sep}{key}" if parent_key else key
8585
if isinstance(value, dict):
86-
flatten_data.update(self._flatten(value, new_key, sep=sep))
86+
v: dict[str, Any] = value
87+
flatten_data.update(self._flatten(v, new_key, sep=sep))
8788
else:
8889
flatten_data[new_key] = value
8990
return flatten_data

adf_core_python/core/agent/info/agent_info.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
from typing import Any
33

44
from rcrs_core.agents.agent import Agent
5+
from rcrs_core.entities.entity import Entity
56
from rcrs_core.entities.human import Human
6-
from rcrs_core.worldmodel.worldmodel import ChangeSet, Entity, EntityID, WorldModel
7+
from rcrs_core.worldmodel.changeSet import ChangeSet
8+
from rcrs_core.worldmodel.entityID import EntityID
9+
from rcrs_core.worldmodel.worldmodel import WorldModel
710

811
from adf_core_python.core.agent.action.action import Action
912

@@ -97,7 +100,7 @@ def get_position_entity_id(self) -> EntityID:
97100
"""
98101
entity = self._world_model.get_entity(self.get_entity_id())
99102
if isinstance(entity, Human):
100-
return entity.get_position_property()
103+
return entity.get_position()
101104
else:
102105
return entity.get_id()
103106

adf_core_python/implement/tactics/default_tactics_ambulance_team.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -111,21 +111,23 @@ def think(
111111
entity_id = agent_info.get_entity_id() # noqa: F841
112112

113113
target_entity_id = self._human_detector.calculate().get_target_entity_id()
114-
action = (
115-
self._action_transport.set_target_entity_id(target_entity_id)
116-
.calc()
117-
.get_action()
118-
)
119-
if action is not None:
120-
return action
114+
if target_entity_id is not None:
115+
action = (
116+
self._action_transport.set_target_entity_id(target_entity_id)
117+
.calc()
118+
.get_action()
119+
)
120+
if action is not None:
121+
return action
121122

122123
target_entity_id = self._search.calculate().get_target_entity_id()
123-
action = (
124-
self._action_ext_move.set_target_entity_id(target_entity_id)
125-
.calc()
126-
.get_action()
127-
)
128-
if action is not None:
129-
return action
124+
if target_entity_id is not None:
125+
action = (
126+
self._action_ext_move.set_target_entity_id(target_entity_id)
127+
.calc()
128+
.get_action()
129+
)
130+
if action is not None:
131+
return action
130132

131133
return ActionRest()

adf_core_python/implement/tactics/default_tactics_fire_brigade.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,21 +110,23 @@ def think(
110110
entity_id = agent_info.get_entity_id() # noqa: F841
111111

112112
target_entity_id = self._human_detector.calculate().get_target_entity_id()
113-
action = (
114-
self._action_fire_rescue.set_target_entity_id(target_entity_id)
115-
.calc()
116-
.get_action()
117-
)
118-
if action is not None:
119-
return action
113+
if target_entity_id is not None:
114+
action = (
115+
self._action_fire_rescue.set_target_entity_id(target_entity_id)
116+
.calc()
117+
.get_action()
118+
)
119+
if action is not None:
120+
return action
120121

121122
target_entity_id = self._search.calculate().get_target_entity_id()
122-
action = (
123-
self._action_ext_move.set_target_entity_id(target_entity_id)
124-
.calc()
125-
.get_action()
126-
)
127-
if action is not None:
128-
return action
123+
if target_entity_id is not None:
124+
action = (
125+
self._action_ext_move.set_target_entity_id(target_entity_id)
126+
.calc()
127+
.get_action()
128+
)
129+
if action is not None:
130+
return action
129131

130132
return ActionRest()

adf_core_python/implement/tactics/default_tactics_police_force.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -114,21 +114,23 @@ def think(
114114
entity_id = agent_info.get_entity_id() # noqa: F841
115115

116116
target_entity_id = self._road_detector.calculate().get_target_entity_id()
117-
action = (
118-
self._action_ext_clear.set_target_entity_id(target_entity_id)
119-
.calc()
120-
.get_action()
121-
)
122-
if action is not None:
123-
return action
117+
if target_entity_id is not None:
118+
action = (
119+
self._action_ext_clear.set_target_entity_id(target_entity_id)
120+
.calc()
121+
.get_action()
122+
)
123+
if action is not None:
124+
return action
124125

125126
target_entity_id = self._search.calculate().get_target_entity_id()
126-
action = (
127-
self._action_ext_clear.set_target_entity_id(target_entity_id)
128-
.calc()
129-
.get_action()
130-
)
131-
if action is not None:
132-
return action
127+
if target_entity_id is not None:
128+
action = (
129+
self._action_ext_clear.set_target_entity_id(target_entity_id)
130+
.calc()
131+
.get_action()
132+
)
133+
if action is not None:
134+
return action
133135

134136
return ActionRest()

poetry.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyrightconfig.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"typeCheckingMode": "standard",
3+
"exclude": ["**/site-packages"]
4+
}

0 commit comments

Comments
 (0)