Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates examples to explicitly set random on new style grid spaces #235

Merged
merged 4 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/caching_and_replay/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def __init__(
self.homophily = homophily
self.radius = radius

self.grid = OrthogonalMooreGrid((width, height), torus=True)
self.grid = OrthogonalMooreGrid((width, height), torus=True, random=self.random)

self.happy = 0
self.datacollector = mesa.DataCollector(
Expand Down
4 changes: 3 additions & 1 deletion examples/charts/charts/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ def __init__(
self.width = width
self.init_people = init_people

self.grid = OrthogonalMooreGrid((self.width, self.height), torus=True)
self.grid = OrthogonalMooreGrid(
(self.width, self.height), torus=True, random=self.random
)
# rich_threshold is the amount of savings a person needs to be considered "rich"
self.rich_threshold = rich_threshold
self.reserve_percent = reserve_percent
Expand Down
2 changes: 1 addition & 1 deletion examples/color_patches/color_patches/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def __init__(self, width=20, height=20):
"""
super().__init__()
self._grid = mesa.experimental.cell_space.OrthogonalMooreGrid(
(width, height), torus=False
(width, height), torus=False, random=self.random
)

# self._grid.coord_iter()
Expand Down
2 changes: 1 addition & 1 deletion examples/forest_fire/forest_fire/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, width=100, height=100, density=0.65, seed=None):

# Set up model objects

self.grid = OrthogonalMooreGrid((width, height), capacity=1)
self.grid = OrthogonalMooreGrid((width, height), capacity=1, random=self.random)
self.datacollector = mesa.DataCollector(
{
"Fine": lambda m: self.count_type(m, "Fine"),
Expand Down
6 changes: 3 additions & 3 deletions examples/hex_snowflake/hex_snowflake/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ class HexSnowflake(mesa.Model):
of cells with adjacency rules specific to hexagons.
"""

def __init__(self, width=50, height=50):
def __init__(self, width=50, height=50, seed=None):
"""
Create a new playing area of (width, height) cells.
"""
super().__init__()
super().__init__(seed=seed)
# Use a hexagonal grid, where edges wrap around.
self.grid = HexGrid((width, height), capacity=1, torus=True)
self.grid = HexGrid((width, height), capacity=1, torus=True, random=self.random)

# Place a dead cell at each location.
for entry in self.grid.all_cells:
Expand Down
4 changes: 2 additions & 2 deletions examples/hotelling_law/hotelling_law/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ def __init__(
# Initialize the spatial grid based on the specified environment type.
if environment_type == "grid":
self.grid = OrthogonalMooreGrid(
(width, height), True
(width, height), torus=True, random=self.random
) # A grid where multiple agents can occupy the same cell.
elif environment_type == "line":
self.grid = OrthogonalMooreGrid(
(1, height), True
(1, height), torus=True, random=self.random
) # A grid representing a line (single occupancy per cell).

self._initialize_agents()
Expand Down
2 changes: 1 addition & 1 deletion examples/shape_example/shape_example/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def __init__(self, N=2, width=20, height=10):
super().__init__()
self.N = N # num of agents
self.headings = ((1, 0), (0, 1), (-1, 0), (0, -1)) # tuples are fast
self.grid = OrthogonalMooreGrid((width, height), torus=True)
self.grid = OrthogonalMooreGrid((width, height), torus=True, random=self.random)

self.make_walker_agents()
self.running = True
Expand Down
Loading