From 0dde3ad8c9180c0fe0c302eb420de7a9dd64ea4e Mon Sep 17 00:00:00 2001 From: dietcoke-17 <274327299+dietcoke-17@users.noreply.github.com> Date: Wed, 17 Jun 2026 04:04:47 +0530 Subject: [PATCH 1/2] fix(hex_ant) --- examples/hex_ant/app.py | 4 ++-- examples/hex_ant/model.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/hex_ant/app.py b/examples/hex_ant/app.py index 952f391f9..57b638514 100644 --- a/examples/hex_ant/app.py +++ b/examples/hex_ant/app.py @@ -3,8 +3,8 @@ from mesa.visualization import SolaraViz, make_space_component from mesa.visualization.components import PropertyLayerStyle -from .agent import AntState -from .model import AntForaging +from agent import AntState +from model import AntForaging plt.rcParams["figure.figsize"] = (10, 10) diff --git a/examples/hex_ant/model.py b/examples/hex_ant/model.py index 96998d22b..96809d780 100644 --- a/examples/hex_ant/model.py +++ b/examples/hex_ant/model.py @@ -1,7 +1,7 @@ import mesa from mesa.discrete_space import HexGrid -from .agent import Ant +from agent import Ant class AntForaging(mesa.Model): @@ -57,9 +57,9 @@ def _init_environment(self): # Create the Nest in the center center = (self.grid.width // 2, self.grid.height // 2) # Spike the 'home' pheromone at the nest so ants can find it initially - self.grid.pheromone_home[center] = 1.0 + self.grid.pheromone_home.data[center] = 1.0 # Mark the home location - self.grid.home[center] = 1 + self.grid.home.data[center] = 1 # Scatter some Food Sources # Create 3 big clusters of food @@ -101,7 +101,7 @@ def _update_pheromone_layer(self, layer_name): """ Apply evaporation to a pheromone layer. """ - np_layer = self.grid.property_layers[layer_name] + np_layer = getattr(self.grid, layer_name).data np_layer *= 1.0 - self.evaporation_rate # Clamp to 0 to prevent negative values From 4ace5012c5dfc67a9704be355b78e7b38376bc18 Mon Sep 17 00:00:00 2001 From: dietcoke-17 <274327299+dietcoke-17@users.noreply.github.com> Date: Wed, 17 Jun 2026 04:58:17 +0530 Subject: [PATCH 2/2] update after codex review --- examples/hex_ant/app.py | 8 ++++++-- examples/hex_ant/model.py | 5 ++++- rl/wolf_sheep/agents.py | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/examples/hex_ant/app.py b/examples/hex_ant/app.py index 57b638514..05cdef0c3 100644 --- a/examples/hex_ant/app.py +++ b/examples/hex_ant/app.py @@ -3,8 +3,12 @@ from mesa.visualization import SolaraViz, make_space_component from mesa.visualization.components import PropertyLayerStyle -from agent import AntState -from model import AntForaging +try: + from .agent import AntState + from .model import AntForaging +except ImportError: + from agent import AntState + from model import AntForaging plt.rcParams["figure.figsize"] = (10, 10) diff --git a/examples/hex_ant/model.py b/examples/hex_ant/model.py index 96809d780..8ec0319f3 100644 --- a/examples/hex_ant/model.py +++ b/examples/hex_ant/model.py @@ -1,7 +1,10 @@ import mesa from mesa.discrete_space import HexGrid -from agent import Ant +try: + from .agent import Ant +except ImportError: + from agent import Ant class AntForaging(mesa.Model): diff --git a/rl/wolf_sheep/agents.py b/rl/wolf_sheep/agents.py index 1bb79db5d..0d5d2325e 100644 --- a/rl/wolf_sheep/agents.py +++ b/rl/wolf_sheep/agents.py @@ -51,7 +51,7 @@ def step(self): self.energy -= 1 # If there are sheep present, eat one - x, y = self.pos + _x, _y = self.pos this_cell = self.model.grid.get_cell_list_contents([self.pos]) sheep = [obj for obj in this_cell if isinstance(obj, Sheep)] if len(sheep) > 0: