Skip to content

Commit 138b32d

Browse files
committed
Update Python version and rcrs_core dependency in pyproject.toml
- Bump Python version from 3.12 to 3.13 - Change rcrs_core dependency to point to the "improve" branch of the repository
1 parent 404cf0b commit 138b32d

File tree

99 files changed

+1199
-1221
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+1199
-1221
lines changed

adf_core_python/cli/template/src/team_name/module/complex/sample_human_detector.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
from typing import Optional, cast
22

3-
from rcrs_core.connection.URN import Entity as EntityURN
4-
from rcrs_core.entities.civilian import Civilian
5-
from rcrs_core.entities.entity import Entity
6-
from rcrs_core.entities.human import Human
7-
from rcrs_core.worldmodel.entityID import EntityID
3+
from rcrscore.entities import Civilian, Entity, EntityID, Human
4+
from rcrscore.urn import EntityURN
85

96
from adf_core_python.core.agent.develop.develop_data import DevelopData
107
from adf_core_python.core.agent.info.agent_info import AgentInfo
@@ -46,7 +43,7 @@ def __init__(
4643
def calculate(self) -> HumanDetector:
4744
transport_human: Optional[Human] = self._agent_info.some_one_on_board()
4845
if transport_human is not None:
49-
self._result = transport_human.get_id()
46+
self._result = transport_human.get_entity_id()
5047
return self
5148

5249
if self._result is not None:
@@ -72,44 +69,45 @@ def _select_target(self) -> Optional[EntityID]:
7269
cluster_valid_human_entities: list[Entity] = [
7370
entity
7471
for entity in cluster_entities
75-
if self._is_valid_human(entity.get_id()) and isinstance(entity, Civilian)
72+
if self._is_valid_human(entity.get_entity_id())
73+
and isinstance(entity, Civilian)
7674
]
7775
if len(cluster_valid_human_entities) != 0:
7876
nearest_human_entity = cluster_valid_human_entities[0]
7977
nearest_distance = self._world_info.get_distance(
8078
self._agent_info.get_entity_id(),
81-
nearest_human_entity.get_id(),
79+
nearest_human_entity.get_entity_id(),
8280
)
8381
for entity in cluster_valid_human_entities:
8482
distance = self._world_info.get_distance(
8583
self._agent_info.get_entity_id(),
86-
entity.get_id(),
84+
entity.get_entity_id(),
8785
)
8886
if distance < nearest_distance:
8987
nearest_distance = distance
9088
nearest_human_entity = entity
91-
return nearest_human_entity.get_id()
89+
return nearest_human_entity.get_entity_id()
9290

9391
world_valid_human_entities: list[Entity] = [
9492
entity
9593
for entity in self._world_info.get_entities_of_types([Civilian])
96-
if self._is_valid_human(entity.get_id())
94+
if self._is_valid_human(entity.get_entity_id())
9795
]
9896
if len(world_valid_human_entities) != 0:
9997
nearest_human_entity = world_valid_human_entities[0]
10098
nearest_distance = self._world_info.get_distance(
10199
self._agent_info.get_entity_id(),
102-
nearest_human_entity.get_id(),
100+
nearest_human_entity.get_entity_id(),
103101
)
104102
for entity in world_valid_human_entities:
105103
distance = self._world_info.get_distance(
106104
self._agent_info.get_entity_id(),
107-
entity.get_id(),
105+
entity.get_entity_id(),
108106
)
109107
if distance < nearest_distance:
110108
nearest_distance = distance
111109
nearest_human_entity = entity
112-
return nearest_human_entity.get_id()
110+
return nearest_human_entity.get_entity_id()
113111

114112
return None
115113

@@ -126,6 +124,8 @@ def _is_valid_human(self, target_entity_id: EntityID) -> bool:
126124
if buriedness is None:
127125
return False
128126
myself = self._agent_info.get_myself()
127+
if myself is None:
128+
return False
129129
if myself.get_urn() == EntityURN.FIRE_BRIGADE and buriedness == 0:
130130
return False
131131
if myself.get_urn() == EntityURN.AMBULANCE_TEAM and buriedness > 0:

adf_core_python/cli/template/src/team_name/module/complex/sample_road_detector.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
from typing import Optional, cast
22

3-
from rcrs_core.entities.building import Building
4-
from rcrs_core.entities.gasStation import GasStation
5-
from rcrs_core.entities.refuge import Refuge
6-
from rcrs_core.entities.road import Road
7-
from rcrs_core.worldmodel.entityID import EntityID
3+
from rcrscore.entities import Building, EntityID, GasStation, Refuge, Road
84

95
from adf_core_python.core.agent.communication.message_manager import MessageManager
106
from adf_core_python.core.agent.develop.develop_data import DevelopData
@@ -59,7 +55,7 @@ def resume(self, precompute_data: PrecomputeData) -> RoadDetector:
5955
for entity in entities:
6056
if not isinstance(entity, Building):
6157
continue
62-
for entity_id in entity.get_neighbours():
58+
for entity_id in entity.get_neighbors():
6359
neighbor = self._world_info.get_entity(entity_id)
6460
if isinstance(neighbor, Road):
6561
self._target_areas.add(entity_id)
@@ -68,7 +64,7 @@ def resume(self, precompute_data: PrecomputeData) -> RoadDetector:
6864
for entity in self._world_info.get_entities_of_types([Refuge]):
6965
if not isinstance(entity, Building):
7066
continue
71-
for entity_id in entity.get_neighbours():
67+
for entity_id in entity.get_neighbors():
7268
neighbor = self._world_info.get_entity(entity_id)
7369
if isinstance(neighbor, Road):
7470
self._priority_roads.add(entity_id)
@@ -86,15 +82,15 @@ def prepare(self) -> RoadDetector:
8682
)
8783
for entity in entities:
8884
building: Building = cast(Building, entity)
89-
for entity_id in building.get_neighbours():
85+
for entity_id in building.get_neighbors():
9086
neighbor = self._world_info.get_entity(entity_id)
9187
if isinstance(neighbor, Road):
9288
self._target_areas.add(entity_id)
9389

9490
self._priority_roads = set()
9591
for entity in self._world_info.get_entities_of_types([Refuge]):
9692
refuge: Refuge = cast(Refuge, entity)
97-
for entity_id in refuge.get_neighbours():
93+
for entity_id in refuge.get_neighbors():
9894
neighbor = self._world_info.get_entity(entity_id)
9995
if isinstance(neighbor, Road):
10096
self._priority_roads.add(entity_id)

adf_core_python/cli/template/src/team_name/module/complex/sample_search.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
from typing import Optional, cast
22

3-
from rcrs_core.entities.building import Building
4-
from rcrs_core.entities.entity import Entity
5-
from rcrs_core.entities.refuge import Refuge
6-
from rcrs_core.worldmodel.entityID import EntityID
3+
from rcrscore.entities import Building, Entity, EntityID, Refuge
74

85
from adf_core_python.core.agent.communication.message_manager import MessageManager
96
from adf_core_python.core.agent.develop.develop_data import DevelopData
@@ -98,7 +95,7 @@ def _get_search_targets(self) -> set[EntityID]:
9895
cluster_index
9996
)
10097
building_entity_ids: list[EntityID] = [
101-
entity.get_id()
98+
entity.get_entity_id()
10299
for entity in cluster_entities
103100
if isinstance(entity, Building) and not isinstance(entity, Refuge)
104101
]

adf_core_python/core/agent/action/action.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from abc import ABC, abstractmethod
22

3-
from rcrs_core.commands.Command import Command
4-
from rcrs_core.worldmodel.entityID import EntityID
3+
from rcrscore.commands import Command
4+
from rcrscore.entities import EntityID
55

66

77
class Action(ABC):

adf_core_python/core/agent/action/ambulance/action_load.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1-
from typing import TYPE_CHECKING
2-
3-
from rcrs_core.commands.AKLoad import AKLoad
4-
from rcrs_core.commands.Command import Command
5-
from rcrs_core.worldmodel.entityID import EntityID
1+
from rcrscore.commands import AKLoad, Command
2+
from rcrscore.entities import EntityID
63

74
from adf_core_python.core.agent.action.action import Action
85

9-
if TYPE_CHECKING:
10-
from rcrs_core.commands.Command import Command
11-
from rcrs_core.worldmodel.entityID import EntityID
12-
136

147
class ActionLoad(Action):
158
def __init__(self, target_id: EntityID) -> None:

adf_core_python/core/agent/action/ambulance/action_rescue.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1-
from typing import TYPE_CHECKING
2-
3-
from rcrs_core.commands.AKRescue import AKRescue
4-
from rcrs_core.commands.Command import Command
5-
from rcrs_core.worldmodel.entityID import EntityID
1+
from rcrscore.commands import AKRescue, Command
2+
from rcrscore.entities import EntityID
63

74
from adf_core_python.core.agent.action.action import Action
85

9-
if TYPE_CHECKING:
10-
from rcrs_core.commands.Command import Command
11-
from rcrs_core.worldmodel.entityID import EntityID
12-
136

147
class ActionRescue(Action):
158
def __init__(self, target_id: EntityID) -> None:

adf_core_python/core/agent/action/ambulance/action_unload.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1-
from typing import TYPE_CHECKING
2-
3-
from rcrs_core.commands.AKUnload import AKUnload
4-
from rcrs_core.commands.Command import Command
5-
from rcrs_core.worldmodel.entityID import EntityID
1+
from rcrscore.commands import AKUnload, Command
2+
from rcrscore.entities import EntityID
63

74
from adf_core_python.core.agent.action.action import Action
85

9-
if TYPE_CHECKING:
10-
from rcrs_core.commands.Command import Command
11-
from rcrs_core.worldmodel.entityID import EntityID
12-
136

147
class ActionUnload(Action):
158
def get_command(self, agent_id: EntityID, time: int) -> Command:

adf_core_python/core/agent/action/common/action_move.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
from typing import TYPE_CHECKING, Optional
1+
from typing import Optional
22

3-
from rcrs_core.commands.AKMove import AKMove
4-
from rcrs_core.commands.Command import Command
5-
from rcrs_core.worldmodel.entityID import EntityID
3+
from rcrscore.commands import AKMove, Command
4+
from rcrscore.entities import EntityID
65

76
from adf_core_python.core.agent.action.action import Action
87

9-
if TYPE_CHECKING:
10-
from rcrs_core.commands.Command import Command
11-
from rcrs_core.worldmodel.entityID import EntityID
12-
138

149
class ActionMove(Action):
1510
def __init__(
@@ -32,11 +27,12 @@ def get_destination_y(self) -> Optional[int]:
3227
return self.destination_y
3328

3429
def get_command(self, agent_id: EntityID, time: int) -> Command:
35-
path: list[int] = [p.get_value() for p in self.path]
3630
if self.destination_x is not None and self.destination_y is not None:
37-
return AKMove(agent_id, time, path, self.destination_x, self.destination_y)
31+
return AKMove(
32+
agent_id, time, self.path, self.destination_x, self.destination_y
33+
)
3834
else:
39-
return AKMove(agent_id, time, path)
35+
return AKMove(agent_id, time, self.path)
4036

4137
def __str__(self) -> str:
4238
path: str = ", ".join([str(p) for p in self.path])

adf_core_python/core/agent/action/common/action_rest.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1-
from typing import TYPE_CHECKING
2-
3-
from rcrs_core.commands.AKRest import AKRest
4-
from rcrs_core.commands.Command import Command
5-
from rcrs_core.worldmodel.entityID import EntityID
1+
from rcrscore.commands import AKRest, Command
2+
from rcrscore.entities import EntityID
63

74
from adf_core_python.core.agent.action.action import Action
85

9-
if TYPE_CHECKING:
10-
from rcrs_core.commands.Command import Command
11-
from rcrs_core.worldmodel.entityID import EntityID
12-
136

147
class ActionRest(Action):
158
def get_command(self, agent_id: EntityID, time: int) -> Command:

adf_core_python/core/agent/action/fire/action_extinguish.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,16 @@
1-
from typing import TYPE_CHECKING
2-
3-
from rcrs_core.commands.AKExtinguish import AKExtinguish
4-
from rcrs_core.commands.Command import Command
5-
from rcrs_core.worldmodel.entityID import EntityID
1+
from rcrscore.commands import AKExtinguish, Command
2+
from rcrscore.entities import EntityID
63

74
from adf_core_python.core.agent.action.action import Action
85

9-
if TYPE_CHECKING:
10-
from rcrs_core.commands.Command import Command
11-
from rcrs_core.worldmodel.entityID import EntityID
12-
136

147
class ActionExtinguish(Action):
158
def __init__(self, target_id: EntityID, max_power: int) -> None:
169
self.target_id = target_id
1710
self.max_power = max_power
1811

1912
def get_command(self, agent_id: EntityID, time: int) -> Command:
20-
# TODO: Implement AKEExtinguish
21-
return AKExtinguish()
13+
return AKExtinguish(agent_id, time, self.target_id, self.max_power)
2214

2315
def __str__(self) -> str:
2416
return (

0 commit comments

Comments
 (0)