-
-
Notifications
You must be signed in to change notification settings - Fork 186
Improve schelling model documentation #103
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
Conversation
examples/schelling/model.py
Outdated
| agent_type: Indicator for the agent's type (minority=1, majority=0) | ||
| """ | ||
| super().__init__(pos, model) | ||
| self.unique_id = unique_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first argument in L18 (pos) is the self.unique_id: https://github.com/projectmesa/mesa-examples/pull/101/files#diff-a04f58e21a9365b299c78a67c883c87286b877ef1f50fffce5534d3ec3eea566R54.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
examples/schelling/model.py
Outdated
| agent_type = 1 if self.random.random() < self.minority_pc else 0 | ||
|
|
||
| agent = SchellingAgent((x, y), self, agent_type) | ||
| agent = SchellingAgent(pos=(x, y), model=self, agent_type=agent_type, unique_id=agent_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Schelling model in the benchmark has a more concise way of generating the agent_id. Also, in general, the benchmark code for Flocking, Schelling, and WolfSheep, written by @quaquel, are more modern than the examples in this repo, and have yet to be synced/incorporated into this repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I work on syncing them to this repo? There is the model and agent class in the benchmark code but it still needs to be integrated with the visualization
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it would be great if the benchmark versions are integrated back into the example folder so they are again consistent.
|
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
examples/schelling/model.py
Outdated
|
|
||
| self.schedule = mesa.time.RandomActivation(self) | ||
| self.grid = mesa.space.SingleGrid(width, height, torus=True) | ||
| self.grid = mesa.space.SingleGrid(height, width, torus=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reminder for width first.
examples/schelling/model.py
Outdated
| # its contents. (coord_iter) | ||
| for cell in self.grid.coord_iter(): | ||
| x, y = cell[1] | ||
| for _cont, pos in self.grid.coord_iter(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_ instead of _cont.
Changes Made: