Skip to content

Conversation

@coderbeta1
Copy link
Contributor

Changes Made:

  1. ReadMe: Added another way to run the program (via python run.py)
  2. Unique Id: Added a unique id for each agent
  3. Doc Strings: Added doc string for explaining model class
  4. General Cleaning: Made the code more readable for beginners

@coderbeta1 coderbeta1 marked this pull request as ready for review February 24, 2024 14:59
agent_type: Indicator for the agent's type (minority=1, majority=0)
"""
super().__init__(pos, model)
self.unique_id = unique_id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Member

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.

@coderbeta1 coderbeta1 requested a review from rht February 25, 2024 12:27
@coderbeta1
Copy link
Contributor Author

pre-commit.ci autofix


self.schedule = mesa.time.RandomActivation(self)
self.grid = mesa.space.SingleGrid(width, height, torus=True)
self.grid = mesa.space.SingleGrid(height, width, torus=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder for width first.

# its contents. (coord_iter)
for cell in self.grid.coord_iter():
x, y = cell[1]
for _cont, pos in self.grid.coord_iter():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_ instead of _cont.

@coderbeta1 coderbeta1 requested a review from rht February 26, 2024 11:30
@rht rht merged commit 64b43d2 into projectmesa:main Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants