-
Notifications
You must be signed in to change notification settings - Fork 896
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
examples: Clean-up Epstein Civil Violence
- Loading branch information
Showing
10 changed files
with
219 additions
and
164 deletions.
There are no files selected for viewing
186 changes: 145 additions & 41 deletions
186
examples/advanced/epstein_civil_violence/Epstein Civil Violence.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
from mesa.visualization import SolaraViz, Slider, make_space_matplotlib, make_plot_measure | ||
|
||
from agents import Citizen, Cop | ||
from model import EpsteinCivilViolence | ||
|
||
COP_COLOR = "#000000" | ||
AGENT_QUIET_COLOR = "#648FFF" | ||
AGENT_REBEL_COLOR = "#FE6100" | ||
JAIL_COLOR = "#808080" | ||
JAIL_SHAPE = "rect" | ||
|
||
|
||
def citizen_cop_portrayal(agent): | ||
if agent is None: | ||
return | ||
|
||
portrayal = { | ||
"shape": "circle", | ||
"x": agent.pos[0], | ||
"y": agent.pos[1], | ||
"filled": True, | ||
} | ||
|
||
if isinstance(agent, Citizen): | ||
color = AGENT_QUIET_COLOR if agent.condition == "Quiescent" else AGENT_REBEL_COLOR | ||
color = JAIL_COLOR if agent.jail_sentence else color | ||
shape = JAIL_SHAPE if agent.jail_sentence else "circle" | ||
portrayal["color"] = color | ||
portrayal["shape"] = shape | ||
if shape == "rect": | ||
portrayal["w"] = 0.9 | ||
portrayal["h"] = 0.9 | ||
else: | ||
portrayal["r"] = 0.5 | ||
portrayal["filled"] = False | ||
portrayal["layer"] = 0 | ||
|
||
elif isinstance(agent, Cop): | ||
portrayal["color"] = COP_COLOR | ||
portrayal["r"] = 0.9 | ||
portrayal["layer"] = 1 | ||
|
||
return portrayal | ||
|
||
|
||
model_params = { | ||
"height": 40, | ||
"width": 40, | ||
"citizen_density": Slider("Initial Agent Density", 0.7, 0.0, 0.9, 0.1), | ||
"cop_density": Slider("Initial Cop Density", 0.04, 0.0, 0.1, 0.01), | ||
"citizen_vision": Slider("Citizen Vision", 7, 1, 10, 1), | ||
"cop_vision": Slider("Cop Vision", 7, 1, 10, 1), | ||
"legitimacy": Slider("Government Legitimacy", 0.82, 0.0, 1, 0.01), | ||
"max_jail_term": Slider("Max Jail Term", 30, 0, 50, 1), | ||
} | ||
|
||
# space_component = make_space_matplotlib(citizen_cop_portrayal) | ||
chart_component = make_plot_measure(["Quiescent", "Active", "Jailed"]) | ||
|
||
epstein_model = EpsteinCivilViolence() | ||
|
||
page = SolaraViz( | ||
epstein_model, | ||
components=[ | ||
# space_component, | ||
chart_component], | ||
model_params=model_params, | ||
name="Epstein Civil Violence", | ||
) | ||
page # noqa |
Empty file.
33 changes: 0 additions & 33 deletions
33
examples/advanced/epstein_civil_violence/epstein_civil_violence/portrayal.py
This file was deleted.
Oops, something went wrong.
81 changes: 0 additions & 81 deletions
81
examples/advanced/epstein_civil_violence/epstein_civil_violence/server.py
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
..._violence/epstein_civil_violence/model.py → .../advanced/epstein_civil_violence/model.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.