Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 1, 2024
1 parent a830b88 commit 13d1605
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions examples/schelling/model.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import mesa

class SchellingAgent(mesa.Agent):

class SchellingAgent(mesa.Agent):
def __init__(self, unique_id, model, agent_type):
"""
Create a new Schelling agent.
Expand All @@ -23,7 +23,9 @@ def step(self):

# If unhappy, decide whether to move:
if similar < self.model.homophily:
if self.random.random() < self.model.move_probability: # Add randomness to moving
if (
self.random.random() < self.model.move_probability
): # Add randomness to moving
self.model.grid.move_to_empty(self)
else:
# Agent decides to stay even if unhappy
Expand All @@ -32,7 +34,6 @@ def step(self):
self.model.happy += 1



class Schelling(mesa.Model):
"""
Model class for the Schelling segregation model.
Expand All @@ -56,7 +57,7 @@ def __init__(
self.minority_pc = minority_pc
self.homophily = homophily
self.radius = radius
self.move_probability = move_probability
self.move_probability = move_probability

self.grid = mesa.space.SingleGrid(width, height, torus=True)

Expand Down

0 comments on commit 13d1605

Please sign in to comment.