diff --git a/examples/charts/charts/agents.py b/examples/charts/charts/agents.py index 3bc481d8..1255bb08 100644 --- a/examples/charts/charts/agents.py +++ b/examples/charts/charts/agents.py @@ -9,8 +9,10 @@ Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL. """ + from mesa.spaces import CellAgent + class Bank: """Note that the Bank class is not a Mesa Agent, but just a regular Python class. This is because there is only one bank in this model, and it does not diff --git a/examples/color_patches/color_patches/model.py b/examples/color_patches/color_patches/model.py index a180e10c..c84c3a95 100644 --- a/examples/color_patches/color_patches/model.py +++ b/examples/color_patches/color_patches/model.py @@ -74,8 +74,7 @@ def __init__(self, width=20, height=20): # for (contents, col, row) in self._grid.coord_iter(): # replaced content with _ to appease linter for cell in self._grid.all_cells: - agent = ColorCell(self, ColorCell.OPINIONS[self.random.randrange(0, 16)] - ) + agent = ColorCell(self, ColorCell.OPINIONS[self.random.randrange(0, 16)]) agent.move_to(cell) self.running = True diff --git a/examples/epstein_civil_violence/epstein_civil_violence/agent.py b/examples/epstein_civil_violence/epstein_civil_violence/agent.py index 3d626990..f98a4db2 100644 --- a/examples/epstein_civil_violence/epstein_civil_violence/agent.py +++ b/examples/epstein_civil_violence/epstein_civil_violence/agent.py @@ -2,8 +2,8 @@ import mesa -class EpsteinAgent(mesa.spaces.CellAgent): +class EpsteinAgent(mesa.spaces.CellAgent): def update_neighbors(self): """ Look around and see who my neighbors are @@ -91,7 +91,6 @@ def step(self): new_cell = self.random.choice(self.empty_neighbors) self.move_to(new_cell) - def update_estimated_arrest_probability(self): """ Based on the ratio of cops to actives in my neighborhood, estimate the @@ -157,4 +156,3 @@ def step(self): if self.model.movement and self.empty_neighbors: new_pos = self.random.choice(self.empty_neighbors) self.move_to(new_pos) - diff --git a/examples/epstein_civil_violence/epstein_civil_violence/model.py b/examples/epstein_civil_violence/epstein_civil_violence/model.py index 017185c9..3b7d69b1 100644 --- a/examples/epstein_civil_violence/epstein_civil_violence/model.py +++ b/examples/epstein_civil_violence/epstein_civil_violence/model.py @@ -59,7 +59,9 @@ def __init__( self.max_iters = max_iters self.iteration = 0 - self.grid = mesa.spaces.OrthogonalMooreGrid((width, height), capacity=1,torus=True) + self.grid = mesa.spaces.OrthogonalMooreGrid( + (width, height), capacity=1, torus=True + ) model_reporters = { "Quiescent": lambda m: self.count_type_citizens(m, "Quiescent"), @@ -119,15 +121,22 @@ def count_type_citizens(model, condition, exclude_jailed=True): citizens = model.agents_by_type[Citizen] if exclude_jailed: - return len([c for c in citizens if (c.condition == condition) and (c.jail_sentence==0)]) + return len( + [ + c + for c in citizens + if (c.condition == condition) and (c.jail_sentence == 0) + ] + ) else: - return len([c for c in citizens if c.condition==condition]) + return len([c for c in citizens if c.condition == condition]) + @staticmethod def count_jailed(model): """ Helper method to count jailed agents. """ - return len([a for a in model.agents_by_type[Citizen] if a.jail_sentence > 0 ]) + return len([a for a in model.agents_by_type[Citizen] if a.jail_sentence > 0]) @staticmethod def count_cops(model):