-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
58 lines (50 loc) · 1.31 KB
/
test.py
File metadata and controls
58 lines (50 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import mesa
print(f"Mesa version: {mesa.__version__}")
from mesa.visualization import SolaraViz, make_plot_component, make_space_component
# Import the local MoneyModel.py
from MoneyModel import MoneyModel
def agent_portrayal(agent):
size = 10
color = "tab:red"
if agent.wealth > 0:
size = 50
color = "tab:blue"
return {"size": size, "color": color}
model_params = {
"n": {
"type": "SliderInt",
"value": 50,
"label": "Number of agents:",
"min": 10,
"max": 100,
"step": 1,
},
"width": {
"type": "SliderInt",
"value": 10,
"label": "Grid width:",
"min": 5,
"max": 20,
"step": 1,
},
"height": {
"type": "SliderInt",
"value": 10,
"label": "Grid height:",
"min": 5,
"max": 20,
"step": 1,
},
}
# Create initial model instance
# money_model = MoneyModel(n=50, width=10, height=10) #keyword arguments
SpaceGraph = make_space_component(agent_portrayal)
GiniPlot = make_plot_component("Gini")
page = SolaraViz(
MoneyModel, # Pass the class, not an instance
components=[SpaceGraph, GiniPlot],
model_params=model_params,
name="Boltzmann Wealth Model",
)
# This is required to render the visualization in the Jupyter notebook
page