Skip to content

Commit 02ad860

Browse files
committed
Consolidate code to mesa 2.4 state
1 parent 7e73f30 commit 02ad860

File tree

5 files changed

+104
-1949
lines changed

5 files changed

+104
-1949
lines changed

mesa/examples/basic/ships_hybrid_algorithm/agents/obstacle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class Obstacle(Agent):
44
def __init__(self, model, shape):
5-
super().__init__(model)
5+
super().__init__(self, model)
66
self.shape = shape # Store the obstacle as a polygon
77

88
def step(self):

mesa/examples/basic/ships_hybrid_algorithm/agents/port.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class Port(Agent):
44
def __init__(self, model):
5-
super().__init__(model)
5+
super().__init__(self, model)
66

77
def step(self):
88
"""Ports remain static."""

mesa/examples/basic/ships_hybrid_algorithm/agents/ship.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
from dynamic_window_approach import dwa_control, motion
99

1010
class Ship(Agent):
11-
def __init__(self, model, start_port, all_ports, dwa_config):
12-
super().__init__(model)
11+
def __init__(self, model, id, start_port, all_ports, dwa_config):
12+
super().__init__(self, model)
13+
self.unique_id = id
1314
self.destination_port = self.assign_destination(all_ports, start_port)
1415
self.global_path = self.calculate_global_path(start_port.pos, self.destination_port.pos)
1516
self.dwa_config = dwa_config

mesa/examples/basic/ships_hybrid_algorithm/model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ def create_ports(self, ports):
7171

7272
def create_ships(self, num_ships, port_agents):
7373
"""Create ship agents and assign them a start and destination port."""
74-
for _ in range(num_ships):
74+
for id in range(num_ships):
7575
start_port = random.choice(port_agents)
76-
ship = Ship(self, start_port, port_agents, self.dwa_config)
76+
ship = Ship(self, id, start_port, port_agents, self.dwa_config)
7777
self.space.place_agent(ship, start_port.pos)
7878
self.schedule.add(ship)
7979

0 commit comments

Comments
 (0)