Skip to content

Commit

Permalink
Sync Mesa and Mesa-examples repos
Browse files Browse the repository at this point in the history
  • Loading branch information
EwoutH committed Oct 15, 2024
2 parents 9c8a581 + bd16878 commit 6a60350
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion codecov.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ coverage:
threshold: 1%

ignore:
- "**experimental/"
- "benchmarks/**"
- "mesa/experimental/**"
- "mesa/visualization/**"

comment: off
4 changes: 2 additions & 2 deletions docs/tutorials/MoneyModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ def step(self):
class MoneyModel(mesa.Model):
"""A model with some number of agents."""

def __init__(self, N, width, height):
def __init__(self, N, width, height, seed=None):
"""Initialize a MoneyModel instance.
Args:
N: The number of agents.
width: width of the grid.
height: Height of the grid.
"""
super().__init__()
super().__init__(seed=seed)
self.num_agents = N
self.grid = mesa.space.MultiGrid(width, height, True)
self.schedule = mesa.time.RandomActivation(self)
Expand Down
8 changes: 5 additions & 3 deletions mesa/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __init__(self, model: Model, agents: Iterable[Agent] | None = None) -> None:
if agents is None:
agents = []

self._agents: AgentSet = AgentSet(agents, model)
self._agents: AgentSet = AgentSet(agents, model.random)

self._remove_warning_given = False
self._agents_key_warning_given = False
Expand Down Expand Up @@ -312,7 +312,9 @@ def __init__(self, model: Model, agents: Iterable[Agent] | None = None) -> None:
try:
self._agents_by_type[type(agent)].add(agent)
except KeyError:
self._agents_by_type[type(agent)] = AgentSet([agent], self.model)
self._agents_by_type[type(agent)] = AgentSet(
[agent], self.model.random
)

def add(self, agent: Agent) -> None:
"""Add an Agent object to the schedule.
Expand All @@ -325,7 +327,7 @@ def add(self, agent: Agent) -> None:
try:
self._agents_by_type[type(agent)].add(agent)
except KeyError:
self._agents_by_type[type(agent)] = AgentSet([agent], self.model)
self._agents_by_type[type(agent)] = AgentSet([agent], self.model.random)

def remove(self, agent: Agent) -> None:
"""Remove all instances of a given agent from the schedule.
Expand Down

0 comments on commit 6a60350

Please sign in to comment.