Skip to content

Commit

Permalink
shift to use create_agents
Browse files Browse the repository at this point in the history
  • Loading branch information
quaquel authored and tpike3 committed Dec 12, 2024
1 parent 23db2e3 commit faa1948
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
3 changes: 2 additions & 1 deletion mesa/examples/advanced/pd_grid/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class PDAgent(CellAgent):
"""Agent member of the iterated, spatial prisoner's dilemma model."""

def __init__(self, model, starting_move=None):
def __init__(self, model, starting_move=None, cell=None):
"""
Create a new Prisoner's Dilemma agent.
Expand All @@ -15,6 +15,7 @@ def __init__(self, model, starting_move=None):
"""
super().__init__(model)
self.score = 0
self.cell = cell
if starting_move:
self.move = starting_move
else:
Expand Down
6 changes: 1 addition & 5 deletions mesa/examples/advanced/pd_grid/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ def __init__(
if payoffs is not None:
self.payoff = payoffs

# Create agents
for x in range(width):
for y in range(height):
agent = PDAgent(self)
agent.cell = self.grid[(x, y)]
PDAgent.create_agents(self, len(self.grid.all_cells.cells), cell=self.grid.all_cells.cells)

self.datacollector = mesa.DataCollector(
{
Expand Down

0 comments on commit faa1948

Please sign in to comment.