Skip to content

Merge Grid, SingleGrid, and MultiGrid into one class #625

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

Closed
wants to merge 16 commits into from
Closed
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
3 changes: 2 additions & 1 deletion examples/Schelling/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class SchellingAgent(Agent):
'''
Schelling segregation agent
'''

def __init__(self, pos, model, agent_type):
'''
Create a new Schelling agent.
Expand Down Expand Up @@ -72,7 +73,7 @@ def __init__(self, height=20, width=20, density=0.8, minority_pc=0.2, homophily=
agent_type = 0

agent = SchellingAgent((x, y), self, agent_type)
self.grid.position_agent(agent, (x, y))
self.grid.position_agent(agent, x, y)
self.schedule.add(agent)

self.running = True
Expand Down
17 changes: 15 additions & 2 deletions mesa/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,24 @@


class Agent:
""" Base class for a model agent. """
""" Base class for a model agent.

Properties:
unique_id: Unique identifer for the agent
model: Model that the agent is situated in
pos: Position of the agent in the parameter space (if exists)
"""

def __init__(self, unique_id, model):
""" Create a new agent. """
""" Create a new agent.

Args:
unique_id: Unique identifer for the agent
model: Model that the agent is situated in
"""
self.unique_id = unique_id
self.model = model
self.pos = None

def step(self):
""" A single step of the agent. """
Expand Down
Loading