Mesa 3.0.0b1__py3-none-any.whl → 3.0.0b2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of Mesa might be problematic. Click here for more details.
- mesa/__init__.py +1 -3
- mesa/agent.py +23 -8
- mesa/examples/__init__.py +21 -0
- {examples → mesa/examples}/advanced/epstein_civil_violence/Readme.md +3 -2
- mesa/examples/advanced/epstein_civil_violence/app.py +72 -0
- {examples/advanced/epstein_civil_violence → mesa/examples/advanced}/epstein_civil_violence/model.py +4 -4
- examples/advanced/pd_grid/readme.md → mesa/examples/advanced/pd_grid/Readme.md +4 -3
- mesa/examples/advanced/pd_grid/app.py +50 -0
- {examples/advanced/pd_grid → mesa/examples/advanced}/pd_grid/model.py +1 -2
- {examples → mesa/examples}/advanced/sugarscape_g1mt/Readme.md +6 -29
- examples/advanced/sugarscape_g1mt/sugarscape_g1mt/trader_agents.py → mesa/examples/advanced/sugarscape_g1mt/agents.py +26 -3
- {examples → mesa/examples}/advanced/sugarscape_g1mt/app.py +23 -14
- {examples/advanced/sugarscape_g1mt → mesa/examples/advanced}/sugarscape_g1mt/model.py +6 -6
- {examples → mesa/examples}/advanced/sugarscape_g1mt/tests.py +3 -6
- mesa/examples/advanced/wolf_sheep/app.py +77 -0
- {examples/advanced/wolf_sheep → mesa/examples/advanced}/wolf_sheep/model.py +9 -8
- mesa/examples/basic/boid_flockers/Readme.md +22 -0
- {examples → mesa/examples}/basic/boid_flockers/app.py +1 -2
- {examples → mesa/examples}/basic/boid_flockers/model.py +1 -2
- {examples → mesa/examples}/basic/boltzmann_wealth_model/Readme.md +1 -5
- mesa/examples/basic/boltzmann_wealth_model/__init__.py +0 -0
- {examples → mesa/examples}/basic/boltzmann_wealth_model/app.py +1 -2
- {examples → mesa/examples}/basic/boltzmann_wealth_model/model.py +3 -4
- {examples → mesa/examples}/basic/conways_game_of_life/Readme.md +11 -7
- mesa/examples/basic/conways_game_of_life/__init__.py +0 -0
- {examples → mesa/examples}/basic/conways_game_of_life/agents.py +8 -8
- mesa/examples/basic/conways_game_of_life/app.py +39 -0
- {examples → mesa/examples}/basic/conways_game_of_life/model.py +3 -4
- {examples → mesa/examples}/basic/conways_game_of_life/st_app.py +2 -1
- examples/basic/schelling/README.md → mesa/examples/basic/schelling/Readme.md +2 -9
- mesa/examples/basic/schelling/__init__.py +0 -0
- {examples → mesa/examples}/basic/schelling/app.py +1 -2
- {examples → mesa/examples}/basic/schelling/model.py +1 -2
- mesa/examples/basic/virus_on_network/__init__.py +0 -0
- {examples → mesa/examples}/basic/virus_on_network/app.py +5 -2
- {examples → mesa/examples}/basic/virus_on_network/model.py +4 -7
- mesa/experimental/cell_space/discrete_space.py +6 -0
- mesa/experimental/devs/eventlist.py +6 -0
- mesa/model.py +13 -0
- mesa/space.py +70 -5
- mesa/visualization/components/altair.py +87 -19
- mesa/visualization/components/matplotlib.py +55 -11
- {mesa-3.0.0b1.dist-info → mesa-3.0.0b2.dist-info}/METADATA +1 -3
- mesa-3.0.0b2.dist-info/RECORD +93 -0
- examples/advanced/epstein_civil_violence/epstein_civil_violence/portrayal.py +0 -33
- examples/advanced/epstein_civil_violence/epstein_civil_violence/server.py +0 -81
- examples/advanced/epstein_civil_violence/requirements.txt +0 -3
- examples/advanced/epstein_civil_violence/run.py +0 -3
- examples/advanced/pd_grid/pd_grid/portrayal.py +0 -19
- examples/advanced/pd_grid/pd_grid/server.py +0 -21
- examples/advanced/pd_grid/requirements.txt +0 -3
- examples/advanced/pd_grid/run.py +0 -3
- examples/advanced/sugarscape_g1mt/requirements.txt +0 -6
- examples/advanced/sugarscape_g1mt/run.py +0 -105
- examples/advanced/sugarscape_g1mt/sugarscape_g1mt/resource_agents.py +0 -26
- examples/advanced/sugarscape_g1mt/sugarscape_g1mt/server.py +0 -61
- examples/advanced/wolf_sheep/requirements.txt +0 -1
- examples/advanced/wolf_sheep/run.py +0 -3
- examples/advanced/wolf_sheep/wolf_sheep/resources/sheep.png +0 -0
- examples/advanced/wolf_sheep/wolf_sheep/resources/wolf.png +0 -0
- examples/advanced/wolf_sheep/wolf_sheep/server.py +0 -78
- examples/basic/__init__.py +0 -13
- examples/basic/boid_flockers/Readme.md +0 -43
- examples/basic/conways_game_of_life/portrayal.py +0 -18
- examples/basic/conways_game_of_life/requirements.txt +0 -1
- examples/basic/conways_game_of_life/server.py +0 -11
- mesa/cookiecutter-mesa/cookiecutter.json +0 -8
- mesa/cookiecutter-mesa/hooks/post_gen_project.py +0 -13
- mesa/cookiecutter-mesa/{{cookiecutter.snake}}/README.md +0 -4
- mesa/cookiecutter-mesa/{{cookiecutter.snake}}/app.pytemplate +0 -27
- mesa/cookiecutter-mesa/{{cookiecutter.snake}}/setup.pytemplate +0 -11
- mesa/cookiecutter-mesa/{{cookiecutter.snake}}/{{cookiecutter.snake}}/__init__.py +0 -1
- mesa/cookiecutter-mesa/{{cookiecutter.snake}}/{{cookiecutter.snake}}/model.pytemplate +0 -60
- mesa/examples.py +0 -3
- mesa/main.py +0 -65
- mesa-3.0.0b1.dist-info/RECORD +0 -114
- {examples → mesa/examples}/README.md +0 -0
- {examples → mesa/examples/advanced}/__init__.py +0 -0
- {examples → mesa/examples}/advanced/epstein_civil_violence/Epstein Civil Violence.ipynb +0 -0
- {examples/advanced → mesa/examples/advanced/epstein_civil_violence}/__init__.py +0 -0
- /examples/advanced/epstein_civil_violence/epstein_civil_violence/agent.py → /mesa/examples/advanced/epstein_civil_violence/agents.py +0 -0
- {examples/advanced/epstein_civil_violence/epstein_civil_violence → mesa/examples/advanced/pd_grid}/__init__.py +0 -0
- /examples/advanced/pd_grid/pd_grid/agent.py → /mesa/examples/advanced/pd_grid/agents.py +0 -0
- {examples → mesa/examples}/advanced/pd_grid/analysis.ipynb +0 -0
- {examples/advanced/pd_grid/pd_grid → mesa/examples/advanced/sugarscape_g1mt}/__init__.py +0 -0
- {examples/advanced/sugarscape_g1mt → mesa/examples/advanced}/sugarscape_g1mt/sugar-map.txt +0 -0
- {examples → mesa/examples}/advanced/wolf_sheep/Readme.md +0 -0
- {examples/advanced/sugarscape_g1mt/sugarscape_g1mt → mesa/examples/advanced/wolf_sheep}/__init__.py +0 -0
- {examples/advanced/wolf_sheep → mesa/examples/advanced}/wolf_sheep/agents.py +0 -0
- {examples/advanced/wolf_sheep → mesa/examples/basic}/__init__.py +0 -0
- {examples/advanced/wolf_sheep/wolf_sheep → mesa/examples/basic/boid_flockers}/__init__.py +0 -0
- {examples → mesa/examples}/basic/boid_flockers/agents.py +0 -0
- {examples → mesa/examples}/basic/boltzmann_wealth_model/agents.py +0 -0
- {examples → mesa/examples}/basic/boltzmann_wealth_model/st_app.py +0 -0
- {examples → mesa/examples}/basic/schelling/agents.py +0 -0
- {examples → mesa/examples}/basic/schelling/analysis.ipynb +0 -0
- /examples/basic/virus_on_network/README.md → /mesa/examples/basic/virus_on_network/Readme.md +0 -0
- {examples → mesa/examples}/basic/virus_on_network/agents.py +0 -0
- {mesa-3.0.0b1.dist-info → mesa-3.0.0b2.dist-info}/WHEEL +0 -0
- {mesa-3.0.0b1.dist-info → mesa-3.0.0b2.dist-info}/entry_points.txt +0 -0
- {mesa-3.0.0b1.dist-info → mesa-3.0.0b2.dist-info}/licenses/LICENSE +0 -0
- {mesa-3.0.0b1.dist-info → mesa-3.0.0b2.dist-info}/licenses/NOTICE +0 -0
|
@@ -11,7 +11,7 @@ from matplotlib.colors import LinearSegmentedColormap, Normalize, to_rgba
|
|
|
11
11
|
from matplotlib.figure import Figure
|
|
12
12
|
|
|
13
13
|
import mesa
|
|
14
|
-
from mesa.experimental.cell_space import VoronoiGrid
|
|
14
|
+
from mesa.experimental.cell_space import Grid, VoronoiGrid
|
|
15
15
|
from mesa.space import PropertyLayer
|
|
16
16
|
from mesa.visualization.utils import update_counter
|
|
17
17
|
|
|
@@ -52,16 +52,22 @@ def SpaceMatplotlib(
|
|
|
52
52
|
if space is None:
|
|
53
53
|
space = getattr(model, "space", None)
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
55
|
+
# https://stackoverflow.com/questions/67524641/convert-multiple-isinstance-checks-to-structural-pattern-matching
|
|
56
|
+
match space:
|
|
57
|
+
case mesa.space._Grid():
|
|
58
|
+
_draw_grid(space, space_ax, agent_portrayal, propertylayer_portrayal, model)
|
|
59
|
+
case mesa.space.ContinuousSpace():
|
|
60
|
+
_draw_continuous_space(space, space_ax, agent_portrayal, model)
|
|
61
|
+
case mesa.space.NetworkGrid():
|
|
62
|
+
_draw_network_grid(space, space_ax, agent_portrayal)
|
|
63
|
+
case VoronoiGrid():
|
|
64
|
+
_draw_voronoi(space, space_ax, agent_portrayal)
|
|
65
|
+
case Grid(): # matches OrthogonalMooreGrid, OrthogonalVonNeumannGrid, and Hexgrid
|
|
66
|
+
# fixme add a separate draw method for hexgrids in the future
|
|
67
|
+
_draw_discrete_space_grid(space, space_ax, agent_portrayal)
|
|
68
|
+
case None:
|
|
69
|
+
if propertylayer_portrayal:
|
|
70
|
+
draw_property_layers(space_ax, space, propertylayer_portrayal, model)
|
|
65
71
|
|
|
66
72
|
solara.FigureMatplotlib(
|
|
67
73
|
space_fig, format="png", bbox_inches="tight", dependencies=dependencies
|
|
@@ -291,6 +297,44 @@ def _draw_voronoi(space, space_ax, agent_portrayal):
|
|
|
291
297
|
space_ax.plot(*zip(*polygon), color="black") # Plot polygon edges in black
|
|
292
298
|
|
|
293
299
|
|
|
300
|
+
def _draw_discrete_space_grid(space: Grid, space_ax, agent_portrayal):
|
|
301
|
+
if space._ndims != 2:
|
|
302
|
+
raise ValueError("Space must be 2D")
|
|
303
|
+
|
|
304
|
+
def portray(g):
|
|
305
|
+
x = []
|
|
306
|
+
y = []
|
|
307
|
+
s = [] # size
|
|
308
|
+
c = [] # color
|
|
309
|
+
|
|
310
|
+
for cell in g.all_cells:
|
|
311
|
+
for agent in cell.agents:
|
|
312
|
+
data = agent_portrayal(agent)
|
|
313
|
+
x.append(cell.coordinate[0])
|
|
314
|
+
y.append(cell.coordinate[1])
|
|
315
|
+
if "size" in data:
|
|
316
|
+
s.append(data["size"])
|
|
317
|
+
if "color" in data:
|
|
318
|
+
c.append(data["color"])
|
|
319
|
+
out = {"x": x, "y": y}
|
|
320
|
+
out["s"] = s
|
|
321
|
+
if len(c) > 0:
|
|
322
|
+
out["c"] = c
|
|
323
|
+
|
|
324
|
+
return out
|
|
325
|
+
|
|
326
|
+
space_ax.set_xlim(0, space.width)
|
|
327
|
+
space_ax.set_ylim(0, space.height)
|
|
328
|
+
|
|
329
|
+
# Draw grid lines
|
|
330
|
+
for x in range(space.width + 1):
|
|
331
|
+
space_ax.axvline(x, color="gray", linestyle=":")
|
|
332
|
+
for y in range(space.height + 1):
|
|
333
|
+
space_ax.axhline(y, color="gray", linestyle=":")
|
|
334
|
+
|
|
335
|
+
space_ax.scatter(**portray(space))
|
|
336
|
+
|
|
337
|
+
|
|
294
338
|
def make_plot_measure(measure: str | dict[str, str] | list[str] | tuple[str]):
|
|
295
339
|
"""Create a plotting function for a specified measure.
|
|
296
340
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: Mesa
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.0b2
|
|
4
4
|
Summary: Agent-based modeling (ABM) in Python
|
|
5
5
|
Project-URL: homepage, https://github.com/projectmesa/mesa
|
|
6
6
|
Project-URL: repository, https://github.com/projectmesa/mesa
|
|
@@ -27,7 +27,6 @@ Requires-Dist: numpy
|
|
|
27
27
|
Requires-Dist: pandas
|
|
28
28
|
Requires-Dist: tqdm
|
|
29
29
|
Provides-Extra: all
|
|
30
|
-
Requires-Dist: cookiecutter; extra == 'all'
|
|
31
30
|
Requires-Dist: ipython; extra == 'all'
|
|
32
31
|
Requires-Dist: matplotlib; extra == 'all'
|
|
33
32
|
Requires-Dist: myst-nb; extra == 'all'
|
|
@@ -43,7 +42,6 @@ Requires-Dist: seaborn; extra == 'all'
|
|
|
43
42
|
Requires-Dist: solara; extra == 'all'
|
|
44
43
|
Requires-Dist: sphinx; extra == 'all'
|
|
45
44
|
Provides-Extra: dev
|
|
46
|
-
Requires-Dist: cookiecutter; extra == 'dev'
|
|
47
45
|
Requires-Dist: matplotlib; extra == 'dev'
|
|
48
46
|
Requires-Dist: networkx; extra == 'dev'
|
|
49
47
|
Requires-Dist: pytest; extra == 'dev'
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
mesa/__init__.py,sha256=Bld7cqsOkGY-bJUf3fuXBts9eH5TRlebkX8pZNI7l9M,659
|
|
2
|
+
mesa/agent.py,sha256=Ein1Ei7n1wZNKcv4L1NlP3iPu9q1pm-QGIL64dLC5Fw,24636
|
|
3
|
+
mesa/batchrunner.py,sha256=0AqTcvjWNPp1aqn7zuUKSovx6Rnkk4M-KouCZ4Guqy0,6419
|
|
4
|
+
mesa/datacollection.py,sha256=xyb07aBpd-HSDh5bk-XcVqGiDu5bfaLlxj5eDlGIwqY,16138
|
|
5
|
+
mesa/model.py,sha256=fojtI87UxDLnRB71CGUKbZWh0BrstBHoCU9xWcw-MsA,10406
|
|
6
|
+
mesa/space.py,sha256=f9TaLgb2nFPNiZn-Mgr5votcn80BBU_LnOm8fbLkEWw,65052
|
|
7
|
+
mesa/time.py,sha256=5yWubqst13MfjXpsYjY-MNdIQH3KWi373KRmRZT5BBo,15044
|
|
8
|
+
mesa/examples/README.md,sha256=-H6ECbl2bqkAK3PKz6ixlm9pN13f-CyKfNssm2Kbyw0,2810
|
|
9
|
+
mesa/examples/__init__.py,sha256=iJpTRiCJUwLVA253t5BIxoX3bFnPJ2_XPzET3ev5mxg,835
|
|
10
|
+
mesa/examples/advanced/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
+
mesa/examples/advanced/epstein_civil_violence/Epstein Civil Violence.ipynb,sha256=yh50ZAK2BVJyJIKsQTTxywnasqWn1IiQUVrwmZKue4w,29032
|
|
12
|
+
mesa/examples/advanced/epstein_civil_violence/Readme.md,sha256=IEU5IZTe5EbvAA2vkYxiIw8vK3O0MZcjbxzn8I2cQic,1874
|
|
13
|
+
mesa/examples/advanced/epstein_civil_violence/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
+
mesa/examples/advanced/epstein_civil_violence/agents.py,sha256=R1Nu-_c_qBPCvr1vl6GgamOP4AUV9GJdcF3V7frAgdY,5676
|
|
15
|
+
mesa/examples/advanced/epstein_civil_violence/app.py,sha256=GpfqVX6iu3EydsikrPT_JZKkXpb-WHHuwBYP_NZqivY,2062
|
|
16
|
+
mesa/examples/advanced/epstein_civil_violence/model.py,sha256=HFA6hsxHVXwjqSlTA7EB9-kctiuzIWWod0zdbEv7y84,5193
|
|
17
|
+
mesa/examples/advanced/pd_grid/Readme.md,sha256=UVUQxZRFdfymCKDdQEn3ZEwgSqgp9cKJPsU8oZpLFnY,2367
|
|
18
|
+
mesa/examples/advanced/pd_grid/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
|
+
mesa/examples/advanced/pd_grid/agents.py,sha256=DzGj4LZUjV0xMQAwkRsv2Aoap1cUvLscJswfA1PdVDs,1716
|
|
20
|
+
mesa/examples/advanced/pd_grid/analysis.ipynb,sha256=ReYtRe2JVyCCXoMBONvynXDQ_eGtQSWhNcuJY3CYTTI,82323
|
|
21
|
+
mesa/examples/advanced/pd_grid/app.py,sha256=y-W_cWeaXDtsK02ptM1tR8VbHUGO5DMua1Rf9qB7Cgo,1370
|
|
22
|
+
mesa/examples/advanced/pd_grid/model.py,sha256=iKy1Oa5lG_hlxwlw67NfFLP9dKk5uDreaaT0xO9-55A,2325
|
|
23
|
+
mesa/examples/advanced/sugarscape_g1mt/Readme.md,sha256=x3kKw1Rre2FPkNhGDLtdzeThmH089mxsGYUPZUeu26k,3595
|
|
24
|
+
mesa/examples/advanced/sugarscape_g1mt/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
25
|
+
mesa/examples/advanced/sugarscape_g1mt/agents.py,sha256=zE7zbO2_OaQiFDq_-t-0hv4ButBWv26dnS1zaPc3_ZE,10183
|
|
26
|
+
mesa/examples/advanced/sugarscape_g1mt/app.py,sha256=qyVXRABxwvl3bAC6kC_t69JdunBe-RE-jCUyXASN5lo,2032
|
|
27
|
+
mesa/examples/advanced/sugarscape_g1mt/model.py,sha256=VVoUni3N2yk7vLEcWC1hiQemaa1vmzJU3gKxVRXxnqM,6069
|
|
28
|
+
mesa/examples/advanced/sugarscape_g1mt/sugar-map.txt,sha256=zZtGYciBPT4miZVnbVuoQ5TugTmGrbDWV9yb5KH6tnU,5000
|
|
29
|
+
mesa/examples/advanced/sugarscape_g1mt/tests.py,sha256=UNahmZTgLquSqmoi_9GcE3JP0qBHjkrHFZ15NMm0ce8,2517
|
|
30
|
+
mesa/examples/advanced/wolf_sheep/Readme.md,sha256=6zrtCg4Fb-hgQxqdLMpTkIYMwD6owCv8BMz_qn0N98Q,3165
|
|
31
|
+
mesa/examples/advanced/wolf_sheep/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
32
|
+
mesa/examples/advanced/wolf_sheep/agents.py,sha256=UocDCsKmXkWxt0-ToVIOhBjX-amYwMtZbHN8U2AolFI,3068
|
|
33
|
+
mesa/examples/advanced/wolf_sheep/app.py,sha256=oqb8ZsEj7aP-Rhh5RiuQ9c8Za1wrbmtrehq8lUDlGgA,2066
|
|
34
|
+
mesa/examples/advanced/wolf_sheep/model.py,sha256=qtCTA2fBP9lA7jJ8UUJ5SIy8gXW7K73YoY8F3YDKp6k,4522
|
|
35
|
+
mesa/examples/basic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
36
|
+
mesa/examples/basic/boid_flockers/Readme.md,sha256=4KJinsLPtUciQSMzvaX3tU5r1HTUg3AFOFDKy73W5RE,894
|
|
37
|
+
mesa/examples/basic/boid_flockers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
38
|
+
mesa/examples/basic/boid_flockers/agents.py,sha256=QXT1zxOq_kdk_w60H2zPV3KpivzCHQ-ApyFIIDvxvok,2693
|
|
39
|
+
mesa/examples/basic/boid_flockers/app.py,sha256=QutSC7do1EgYATzJ-uSJTyoAtvM3HoVv9E3JRSviFP4,1269
|
|
40
|
+
mesa/examples/basic/boid_flockers/model.py,sha256=o335lgyGQ1E5TkAj4B-INhUL65mO0dEV3tf3gG40FvU,2201
|
|
41
|
+
mesa/examples/basic/boltzmann_wealth_model/Readme.md,sha256=wl1ylO9KWoTiuIJKOnk2FGdcmyVUqJ5wiSbVUa3WWAc,2725
|
|
42
|
+
mesa/examples/basic/boltzmann_wealth_model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
43
|
+
mesa/examples/basic/boltzmann_wealth_model/agents.py,sha256=uVUo9jWQnv5I3uCaYE_N7X-cOdHhdy6RtLUL_znELgI,892
|
|
44
|
+
mesa/examples/basic/boltzmann_wealth_model/app.py,sha256=MmTWGFT-BiWobXeTIAcfehVxjC0tQdsM9ILTGoPHXCw,1943
|
|
45
|
+
mesa/examples/basic/boltzmann_wealth_model/model.py,sha256=BYcfR5Nw0zXkKP72CoVnLkIvV-IVnNKKNQ7KsbJ07pc,1508
|
|
46
|
+
mesa/examples/basic/boltzmann_wealth_model/st_app.py,sha256=v3Je2hSe8nXPgfmZhX8lHM-7xs8dk2g1Zz0X81AqX3k,3466
|
|
47
|
+
mesa/examples/basic/conways_game_of_life/Readme.md,sha256=VRgN6roF6leQ_IMYwxFypSfFjZo9jnCd-rkPTjpp7II,1453
|
|
48
|
+
mesa/examples/basic/conways_game_of_life/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
49
|
+
mesa/examples/basic/conways_game_of_life/agents.py,sha256=ETn87GV8it9p0nlSn6f1qu5CDEmqokkr6Rq7KWaT-5U,1627
|
|
50
|
+
mesa/examples/basic/conways_game_of_life/app.py,sha256=2r3j5aFuNAMrlRd8nAAexRNViOfj86pLuZTd8FWKv0E,1232
|
|
51
|
+
mesa/examples/basic/conways_game_of_life/model.py,sha256=c7lwSelxTplbQlbfGjBSevS2TEg5DFJA8bvhbYbyD_s,1174
|
|
52
|
+
mesa/examples/basic/conways_game_of_life/st_app.py,sha256=_poqU2VR4rfiiq4WFXTbOUSW7liuM86iq913mW6LS50,2400
|
|
53
|
+
mesa/examples/basic/schelling/Readme.md,sha256=CRKBfYtnLJLlTKLsTRQ-7gsQRxVxDooOBN5uP8PEtaU,2296
|
|
54
|
+
mesa/examples/basic/schelling/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
55
|
+
mesa/examples/basic/schelling/agents.py,sha256=dvznzN2As979x-4EH8Y-i7HhlCuv1OdtWYebOdxTdhk,773
|
|
56
|
+
mesa/examples/basic/schelling/analysis.ipynb,sha256=JDJy6-U6eO-LrHWxZr1c3lkvtoY0DNHa-kJ4J-Z-wwo,5804
|
|
57
|
+
mesa/examples/basic/schelling/app.py,sha256=-SXLVg7KPzquh7LausjqTzJh_EA3fFn4xXmY3H4Ba38,973
|
|
58
|
+
mesa/examples/basic/schelling/model.py,sha256=szYiw76JD-OMlZ2Op80Y9L2PZ3VMVfyuUNl1J_jC8BE,1856
|
|
59
|
+
mesa/examples/basic/virus_on_network/Readme.md,sha256=UnCkKiJK7wVw40a-oDR6qdf3QpCsBhgNOVZg-2UXPlc,2528
|
|
60
|
+
mesa/examples/basic/virus_on_network/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
61
|
+
mesa/examples/basic/virus_on_network/agents.py,sha256=a_WhqYblJlW6od67eXfU-nb7IMRyYpgxtf0le--VYoA,1975
|
|
62
|
+
mesa/examples/basic/virus_on_network/app.py,sha256=EQfXYV94GdnC71hVIl9Zpy4JqKNRFINCJxHFdOKbNTU,3340
|
|
63
|
+
mesa/examples/basic/virus_on_network/model.py,sha256=jQoCmvygwCvhUrlL0l7V8GcDLv94CgwtuK7DDGU8q8g,2813
|
|
64
|
+
mesa/experimental/UserParam.py,sha256=f32nmFjroe76HpxU75ZCEOqFW2nAsDfmqIf8kQ1zt-E,2086
|
|
65
|
+
mesa/experimental/__init__.py,sha256=faBYyHSp-sFQPaBx8-WsLToVKCndpSzpt18HmNZtasM,385
|
|
66
|
+
mesa/experimental/solara_viz.py,sha256=uWrNQAX3oEWSftmyjNorN839dBCUp86hnhpL704dyGQ,15212
|
|
67
|
+
mesa/experimental/cell_space/__init__.py,sha256=-NtSCT7mA-aszLSAdqbICGqeFe2vBdb-GrcW562legY,999
|
|
68
|
+
mesa/experimental/cell_space/cell.py,sha256=lDm7NQhPDFf3-SZu5W594lDNGtzcdSPUSSsELFRg0bs,7166
|
|
69
|
+
mesa/experimental/cell_space/cell_agent.py,sha256=jvYOV9OIaBaqAsAG0YLV64X_f3BJe_wP7qfos_RXi0Y,3759
|
|
70
|
+
mesa/experimental/cell_space/cell_collection.py,sha256=ZcyuPEevCZEXW7jFnX6StjBMw4UBDQvUspZRcFi2dFg,3426
|
|
71
|
+
mesa/experimental/cell_space/discrete_space.py,sha256=sD5455phlIthnAK6OsgxVscQ4C_HSVWA9e476C3PuF0,5264
|
|
72
|
+
mesa/experimental/cell_space/grid.py,sha256=oWTy6kaaHXLPneA-w5XdqzwA0YItMWYgCq_UjNH9iA8,7711
|
|
73
|
+
mesa/experimental/cell_space/network.py,sha256=_x0zKlI-odNCSRb_Zqh4nBPjqnW5iVj8sVheKPCLzmU,1321
|
|
74
|
+
mesa/experimental/cell_space/voronoi.py,sha256=lSY8zQhELvOy0RfDyZIek09UMwY9_20UY9SPqFWsNoM,10014
|
|
75
|
+
mesa/experimental/components/altair.py,sha256=49OHgrm1JncfrKqDfw_5ifPtsbMKdgVYCacL9SMwucc,2624
|
|
76
|
+
mesa/experimental/components/matplotlib.py,sha256=j477UBk_7yW5vzT3rjhnuTixpA7PedDNghoK9TLgHVY,8043
|
|
77
|
+
mesa/experimental/devs/__init__.py,sha256=EByaC66ikUIu9G9p1geLm6ESEMWZOPTO9r9627S83j0,211
|
|
78
|
+
mesa/experimental/devs/eventlist.py,sha256=fPj2jfW-jTe-UnIE6TsF1BM2ITKe3jGfVUhu3gBv7UQ,6250
|
|
79
|
+
mesa/experimental/devs/simulator.py,sha256=wvqkLIDgbJNaem9nwMacyEYRp0W3ai5Oxptw3-QmbSw,10595
|
|
80
|
+
mesa/experimental/devs/examples/epstein_civil_violence.py,sha256=E8YSV3O5ihKsntGtnltHM-4IyS8eg2DSRUqmIiw_1iU,10916
|
|
81
|
+
mesa/experimental/devs/examples/wolf_sheep.py,sha256=1eb1CfYNQoprqSJat-LPYPvwWH1ENQdj39viEqwSk0s,8103
|
|
82
|
+
mesa/visualization/UserParam.py,sha256=Dl2WOwLYLf0pfLpabCZtIdFRyKZrK6Qtc3utZx5GPYg,2139
|
|
83
|
+
mesa/visualization/__init__.py,sha256=sa8lqeLcDtte19SMzFiKP6K4CrVLxAPwrhDu_AsDWTs,395
|
|
84
|
+
mesa/visualization/solara_viz.py,sha256=SHlQ8Y4k6EU7LxlJjjvvjDJWGWryahjQXCwMiVgoF0E,14944
|
|
85
|
+
mesa/visualization/utils.py,sha256=lJHgRKF5BHLf72Tw3YpwyiWuRoIimaTKQ7xBCw_Rx3A,146
|
|
86
|
+
mesa/visualization/components/altair.py,sha256=e_J3ZPv4ldtJje5pUm1UgNqcMh7Nc4fyIgvbbcCWESg,4856
|
|
87
|
+
mesa/visualization/components/matplotlib.py,sha256=EBK1zRCl71LkOgeOV7eQE1Ig22n1ZFGtNBhweozPFYk,13241
|
|
88
|
+
mesa-3.0.0b2.dist-info/METADATA,sha256=8FG5-NHehf7et0SOy8FKHCFH-9nvMwOhKpXNi6vfl10,9849
|
|
89
|
+
mesa-3.0.0b2.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
|
90
|
+
mesa-3.0.0b2.dist-info/entry_points.txt,sha256=IOcQtetGF8l4wHpOs_hGb19Rz-FS__BMXOJR10IBPsA,39
|
|
91
|
+
mesa-3.0.0b2.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
92
|
+
mesa-3.0.0b2.dist-info/licenses/NOTICE,sha256=GbsWoK0QWv1JyZ_xer2s-jNilv0RtWl-0UrtlJANHPg,578
|
|
93
|
+
mesa-3.0.0b2.dist-info/RECORD,,
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
from .agent import Citizen, Cop
|
|
2
|
-
|
|
3
|
-
COP_COLOR = "#000000"
|
|
4
|
-
AGENT_QUIET_COLOR = "#0066CC"
|
|
5
|
-
AGENT_REBEL_COLOR = "#CC0000"
|
|
6
|
-
JAIL_COLOR = "#757575"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def citizen_cop_portrayal(agent):
|
|
10
|
-
if agent is None:
|
|
11
|
-
return
|
|
12
|
-
|
|
13
|
-
portrayal = {
|
|
14
|
-
"Shape": "circle",
|
|
15
|
-
"x": agent.pos[0],
|
|
16
|
-
"y": agent.pos[1],
|
|
17
|
-
"Filled": "true",
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if isinstance(agent, Citizen):
|
|
21
|
-
color = (
|
|
22
|
-
AGENT_QUIET_COLOR if agent.condition == "Quiescent" else AGENT_REBEL_COLOR
|
|
23
|
-
)
|
|
24
|
-
color = JAIL_COLOR if agent.jail_sentence else color
|
|
25
|
-
portrayal["Color"] = color
|
|
26
|
-
portrayal["r"] = 0.8
|
|
27
|
-
portrayal["Layer"] = 0
|
|
28
|
-
|
|
29
|
-
elif isinstance(agent, Cop):
|
|
30
|
-
portrayal["Color"] = COP_COLOR
|
|
31
|
-
portrayal["r"] = 0.5
|
|
32
|
-
portrayal["Layer"] = 1
|
|
33
|
-
return portrayal
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import mesa
|
|
2
|
-
|
|
3
|
-
from .agent import Citizen, Cop
|
|
4
|
-
from .model import EpsteinCivilViolence
|
|
5
|
-
|
|
6
|
-
COP_COLOR = "#000000"
|
|
7
|
-
AGENT_QUIET_COLOR = "#648FFF"
|
|
8
|
-
AGENT_REBEL_COLOR = "#FE6100"
|
|
9
|
-
JAIL_COLOR = "#808080"
|
|
10
|
-
JAIL_SHAPE = "rect"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def citizen_cop_portrayal(agent):
|
|
14
|
-
if agent is None:
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
portrayal = {
|
|
18
|
-
"Shape": "circle",
|
|
19
|
-
"x": agent.pos[0],
|
|
20
|
-
"y": agent.pos[1],
|
|
21
|
-
"Filled": "true",
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if type(agent) is Citizen:
|
|
25
|
-
color = (
|
|
26
|
-
AGENT_QUIET_COLOR if agent.condition == "Quiescent" else AGENT_REBEL_COLOR
|
|
27
|
-
)
|
|
28
|
-
color = JAIL_COLOR if agent.jail_sentence else color
|
|
29
|
-
shape = JAIL_SHAPE if agent.jail_sentence else "circle"
|
|
30
|
-
portrayal["Color"] = color
|
|
31
|
-
portrayal["Shape"] = shape
|
|
32
|
-
if shape == "rect":
|
|
33
|
-
portrayal["w"] = 0.9
|
|
34
|
-
portrayal["h"] = 0.9
|
|
35
|
-
else:
|
|
36
|
-
portrayal["r"] = 0.5
|
|
37
|
-
portrayal["Filled"] = "false"
|
|
38
|
-
portrayal["Layer"] = 0
|
|
39
|
-
|
|
40
|
-
elif type(agent) is Cop:
|
|
41
|
-
portrayal["Color"] = COP_COLOR
|
|
42
|
-
portrayal["r"] = 0.9
|
|
43
|
-
portrayal["Layer"] = 1
|
|
44
|
-
|
|
45
|
-
return portrayal
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
model_params = {
|
|
49
|
-
"height": 40,
|
|
50
|
-
"width": 40,
|
|
51
|
-
"citizen_density": mesa.visualization.Slider(
|
|
52
|
-
"Initial Agent Density", 0.7, 0.0, 0.9, 0.1
|
|
53
|
-
),
|
|
54
|
-
"cop_density": mesa.visualization.Slider(
|
|
55
|
-
"Initial Cop Density", 0.04, 0.0, 0.1, 0.01
|
|
56
|
-
),
|
|
57
|
-
"citizen_vision": mesa.visualization.Slider("Citizen Vision", 7, 1, 10, 1),
|
|
58
|
-
"cop_vision": mesa.visualization.Slider("Cop Vision", 7, 1, 10, 1),
|
|
59
|
-
"legitimacy": mesa.visualization.Slider(
|
|
60
|
-
"Government Legitimacy", 0.82, 0.0, 1, 0.01
|
|
61
|
-
),
|
|
62
|
-
"max_jail_term": mesa.visualization.Slider("Max Jail Term", 30, 0, 50, 1),
|
|
63
|
-
}
|
|
64
|
-
canvas_element = mesa.visualization.CanvasGrid(citizen_cop_portrayal, 40, 40, 480, 480)
|
|
65
|
-
chart = mesa.visualization.ChartModule(
|
|
66
|
-
[
|
|
67
|
-
{"Label": "Quiescent", "Color": "#648FFF"},
|
|
68
|
-
{"Label": "Active", "Color": "#FE6100"},
|
|
69
|
-
{"Label": "Jailed", "Color": "#808080"},
|
|
70
|
-
],
|
|
71
|
-
data_collector_name="datacollector",
|
|
72
|
-
)
|
|
73
|
-
server = mesa.visualization.ModularServer(
|
|
74
|
-
EpsteinCivilViolence,
|
|
75
|
-
[
|
|
76
|
-
canvas_element,
|
|
77
|
-
chart,
|
|
78
|
-
],
|
|
79
|
-
"Epstein Civil Violence",
|
|
80
|
-
model_params,
|
|
81
|
-
)
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
def portrayPDAgent(agent):
|
|
2
|
-
"""
|
|
3
|
-
This function is registered with the visualization server to be called
|
|
4
|
-
each tick to indicate how to draw the agent in its current state.
|
|
5
|
-
:param agent: the agent in the simulation
|
|
6
|
-
:return: the portrayal dictionary
|
|
7
|
-
"""
|
|
8
|
-
if agent is None:
|
|
9
|
-
raise AssertionError
|
|
10
|
-
return {
|
|
11
|
-
"Shape": "rect",
|
|
12
|
-
"w": 1,
|
|
13
|
-
"h": 1,
|
|
14
|
-
"Filled": "true",
|
|
15
|
-
"Layer": 0,
|
|
16
|
-
"x": agent.pos[0],
|
|
17
|
-
"y": agent.pos[1],
|
|
18
|
-
"Color": "blue" if agent.isCooroperating else "red",
|
|
19
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import mesa
|
|
2
|
-
|
|
3
|
-
from .model import PdGrid
|
|
4
|
-
from .portrayal import portrayPDAgent
|
|
5
|
-
|
|
6
|
-
# Make a world that is 50x50, on a 500x500 display.
|
|
7
|
-
canvas_element = mesa.visualization.CanvasGrid(portrayPDAgent, 50, 50, 500, 500)
|
|
8
|
-
|
|
9
|
-
model_params = {
|
|
10
|
-
"height": 50,
|
|
11
|
-
"width": 50,
|
|
12
|
-
"activation_order": mesa.visualization.Choice(
|
|
13
|
-
"Activation regime",
|
|
14
|
-
value="Random",
|
|
15
|
-
choices=PdGrid.activation_regimes,
|
|
16
|
-
),
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
server = mesa.visualization.ModularServer(
|
|
20
|
-
PdGrid, [canvas_element], "Prisoner's Dilemma", model_params
|
|
21
|
-
)
|
examples/advanced/pd_grid/run.py
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import sys
|
|
2
|
-
|
|
3
|
-
import matplotlib.pyplot as plt
|
|
4
|
-
import mesa
|
|
5
|
-
import networkx as nx
|
|
6
|
-
import pandas as pd
|
|
7
|
-
from sugarscape_g1mt.model import SugarscapeG1mt
|
|
8
|
-
from sugarscape_g1mt.server import server
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
# Analysis
|
|
12
|
-
def assess_results(results, single_agent):
|
|
13
|
-
# Make dataframe of results
|
|
14
|
-
results_df = pd.DataFrame(results)
|
|
15
|
-
# Plot and show mean price
|
|
16
|
-
plt.scatter(results_df["Step"], results_df["Price"], s=0.75)
|
|
17
|
-
plt.show()
|
|
18
|
-
|
|
19
|
-
if single_agent is not None:
|
|
20
|
-
plt.plot(results_df["Step"], results_df["Trader"])
|
|
21
|
-
plt.show()
|
|
22
|
-
else:
|
|
23
|
-
n = max(results_df["RunId"])
|
|
24
|
-
# Plot number of Traders
|
|
25
|
-
for i in range(n):
|
|
26
|
-
results_explore = results_df[results_df["RunId"] == i]
|
|
27
|
-
plt.plot(results_explore["Step"], results_explore["Trader"])
|
|
28
|
-
plt.show()
|
|
29
|
-
|
|
30
|
-
if single_agent is not None:
|
|
31
|
-
results_df = single_agent
|
|
32
|
-
|
|
33
|
-
# Show Trade Networks
|
|
34
|
-
# create graph object
|
|
35
|
-
print("Making Network")
|
|
36
|
-
G = nx.Graph()
|
|
37
|
-
trade = results_df.dropna(subset=["Trade Network"])
|
|
38
|
-
# add agent keys to make initial node set
|
|
39
|
-
G.add_nodes_from(list(trade["AgentID"].unique()))
|
|
40
|
-
|
|
41
|
-
# create edge list
|
|
42
|
-
for idx, row in trade.iterrows():
|
|
43
|
-
if len(row["Trade Network"]) > 0:
|
|
44
|
-
for agent in row["Trade Network"]:
|
|
45
|
-
G.add_edge(row["AgentID"], agent)
|
|
46
|
-
|
|
47
|
-
# Get Basic Network Statistics
|
|
48
|
-
print(f"Node Connectivity {nx.node_connectivity(G)}")
|
|
49
|
-
print(f"Average Clustering {nx.average_clustering(G)}")
|
|
50
|
-
print(f"Global Efficiency {nx.global_efficiency(G)}")
|
|
51
|
-
|
|
52
|
-
# Plot histogram of degree distribution
|
|
53
|
-
degree_sequence = sorted((d for n, d in G.degree()), reverse=True)
|
|
54
|
-
degree_sequence = [d for n, d in G.degree()]
|
|
55
|
-
plt.hist(degree_sequence)
|
|
56
|
-
plt.show()
|
|
57
|
-
|
|
58
|
-
# Plot network
|
|
59
|
-
nx.draw(G)
|
|
60
|
-
plt.show()
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
# Run the model
|
|
64
|
-
def main():
|
|
65
|
-
args = sys.argv[1:]
|
|
66
|
-
|
|
67
|
-
if len(args) == 0:
|
|
68
|
-
server.launch()
|
|
69
|
-
|
|
70
|
-
elif args[0] == "-s":
|
|
71
|
-
print("Running Single Model")
|
|
72
|
-
model = SugarscapeG1mt()
|
|
73
|
-
model.run_model()
|
|
74
|
-
model_results = model.datacollector.get_model_vars_dataframe()
|
|
75
|
-
model_results["Step"] = model_results.index
|
|
76
|
-
agent_results = model.datacollector.get_agent_vars_dataframe()
|
|
77
|
-
agent_results = agent_results.reset_index()
|
|
78
|
-
assess_results(model_results, agent_results)
|
|
79
|
-
|
|
80
|
-
elif args[0] == "-b":
|
|
81
|
-
print("Conducting a Batch Run")
|
|
82
|
-
params = {
|
|
83
|
-
"width": 50,
|
|
84
|
-
"height": 50,
|
|
85
|
-
"vision_min": range(1, 4),
|
|
86
|
-
"metabolism_max": [2, 3, 4, 5],
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
results_batch = mesa.batch_run(
|
|
90
|
-
SugarscapeG1mt,
|
|
91
|
-
parameters=params,
|
|
92
|
-
iterations=1,
|
|
93
|
-
number_processes=1,
|
|
94
|
-
data_collection_period=1,
|
|
95
|
-
display_progress=True,
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
assess_results(results_batch, None)
|
|
99
|
-
|
|
100
|
-
else:
|
|
101
|
-
raise Exception("Option not found")
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
if __name__ == "__main__":
|
|
105
|
-
main()
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
from mesa.experimental.cell_space import FixedAgent
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class Resource(FixedAgent):
|
|
5
|
-
"""
|
|
6
|
-
Resource:
|
|
7
|
-
- contains an amount of sugar and spice
|
|
8
|
-
- grows 1 amount of sugar at each turn
|
|
9
|
-
- grows 1 amount of spice at each turn
|
|
10
|
-
"""
|
|
11
|
-
|
|
12
|
-
def __init__(self, model, max_sugar, max_spice, cell):
|
|
13
|
-
super().__init__(model)
|
|
14
|
-
self.sugar_amount = max_sugar
|
|
15
|
-
self.max_sugar = max_sugar
|
|
16
|
-
self.spice_amount = max_spice
|
|
17
|
-
self.max_spice = max_spice
|
|
18
|
-
self.cell = cell
|
|
19
|
-
|
|
20
|
-
def step(self):
|
|
21
|
-
"""
|
|
22
|
-
Growth function, adds one unit of sugar and spice each step up to
|
|
23
|
-
max amount
|
|
24
|
-
"""
|
|
25
|
-
self.sugar_amount = min([self.max_sugar, self.sugar_amount + 1])
|
|
26
|
-
self.spice_amount = min([self.max_spice, self.spice_amount + 1])
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import mesa
|
|
2
|
-
|
|
3
|
-
from .model import SugarscapeG1mt
|
|
4
|
-
from .resource_agents import Resource
|
|
5
|
-
from .trader_agents import Trader
|
|
6
|
-
|
|
7
|
-
sugar_dic = {4: "#005C00", 3: "#008300", 2: "#00AA00", 1: "#00F800"}
|
|
8
|
-
spice_dic = {4: "#acac00", 3: "#c5c500", 2: "#dfdf00", 1: "#f8f800"}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def Agent_portrayal(agent):
|
|
12
|
-
if agent is None:
|
|
13
|
-
return
|
|
14
|
-
|
|
15
|
-
if isinstance(agent, Trader):
|
|
16
|
-
return {
|
|
17
|
-
"Shape": "circle",
|
|
18
|
-
"Filled": "true",
|
|
19
|
-
"r": 0.5,
|
|
20
|
-
"Layer": 0,
|
|
21
|
-
"Color": "#FF0A01",
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
elif isinstance(agent, Resource):
|
|
25
|
-
resource_type = "sugar" if agent.max_sugar > agent.max_spice else "spice"
|
|
26
|
-
if resource_type == "sugar":
|
|
27
|
-
color = (
|
|
28
|
-
sugar_dic[agent.sugar_amount] if agent.sugar_amount != 0 else "#D6F5D6"
|
|
29
|
-
)
|
|
30
|
-
layer = 1 if agent.sugar_amount > 2 else 0
|
|
31
|
-
else:
|
|
32
|
-
color = (
|
|
33
|
-
spice_dic[agent.spice_amount] if agent.spice_amount != 0 else "#D6F5D6"
|
|
34
|
-
)
|
|
35
|
-
layer = 1 if agent.spice_amount > 2 else 0
|
|
36
|
-
return {
|
|
37
|
-
"Color": color,
|
|
38
|
-
"Shape": "rect",
|
|
39
|
-
"Filled": "true",
|
|
40
|
-
"Layer": layer,
|
|
41
|
-
"w": 1,
|
|
42
|
-
"h": 1,
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return {}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
canvas_element = mesa.visualization.CanvasGrid(Agent_portrayal, 50, 50, 500, 500)
|
|
49
|
-
chart_element = mesa.visualization.ChartModule(
|
|
50
|
-
[{"Label": "Trader", "Color": "#AA0000"}]
|
|
51
|
-
)
|
|
52
|
-
chart_element2 = mesa.visualization.ChartModule(
|
|
53
|
-
[{"Label": "Price", "Color": "#000000"}]
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
server = mesa.visualization.ModularServer(
|
|
57
|
-
SugarscapeG1mt,
|
|
58
|
-
[canvas_element, chart_element, chart_element2],
|
|
59
|
-
"Sugarscape with Traders",
|
|
60
|
-
)
|
|
61
|
-
# server.launch()
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
mesa~=2.0
|
|
Binary file
|
|
Binary file
|