From 54e45b9d96c33920168b8f488c8a26a09c468c61 Mon Sep 17 00:00:00 2001 From: Jan Kwakkel Date: Mon, 11 Nov 2024 18:46:24 +0100 Subject: [PATCH] add seed to all examples --- mesa/examples/advanced/epstein_civil_violence/app.py | 5 +++++ mesa/examples/advanced/pd_grid/app.py | 5 +++++ mesa/examples/advanced/sugarscape_g1mt/app.py | 9 +++++++-- mesa/examples/basic/boid_flockers/app.py | 5 +++++ mesa/examples/basic/boltzmann_wealth_model/app.py | 10 +++++----- mesa/examples/basic/conways_game_of_life/app.py | 5 +++++ mesa/examples/basic/schelling/app.py | 5 +++++ mesa/examples/basic/virus_on_network/app.py | 5 +++++ 8 files changed, 42 insertions(+), 7 deletions(-) diff --git a/mesa/examples/advanced/epstein_civil_violence/app.py b/mesa/examples/advanced/epstein_civil_violence/app.py index d3eb4643d87..13ac8947a1c 100644 --- a/mesa/examples/advanced/epstein_civil_violence/app.py +++ b/mesa/examples/advanced/epstein_civil_violence/app.py @@ -44,6 +44,11 @@ def post_process(ax): model_params = { + "seed": { + "type": "InputText", + "value": 42, + "label": "Random Seed", + }, "height": 40, "width": 40, "citizen_density": Slider("Initial Agent Density", 0.7, 0.0, 0.9, 0.1), diff --git a/mesa/examples/advanced/pd_grid/app.py b/mesa/examples/advanced/pd_grid/app.py index 94c2d71f482..d99136fb3e5 100644 --- a/mesa/examples/advanced/pd_grid/app.py +++ b/mesa/examples/advanced/pd_grid/app.py @@ -24,6 +24,11 @@ def pd_agent_portrayal(agent): # Model parameters model_params = { + "seed": { + "type": "InputText", + "value": 42, + "label": "Random Seed", + }, "width": Slider("Grid Width", value=50, min=10, max=100, step=1), "height": Slider("Grid Height", value=50, min=10, max=100, step=1), "activation_order": { diff --git a/mesa/examples/advanced/sugarscape_g1mt/app.py b/mesa/examples/advanced/sugarscape_g1mt/app.py index 6564cb68361..4903943671f 100644 --- a/mesa/examples/advanced/sugarscape_g1mt/app.py +++ b/mesa/examples/advanced/sugarscape_g1mt/app.py @@ -47,6 +47,11 @@ def portray(g): model_params = { + "seed": { + "type": "InputText", + "value": 42, + "label": "Random Seed", + }, "width": 50, "height": 50, # Population parameters @@ -66,10 +71,10 @@ def portray(g): "enable_trade": {"type": "Checkbox", "value": True, "label": "Enable Trading"}, } -model1 = SugarscapeG1mt() +model = SugarscapeG1mt() page = SolaraViz( - model1, + model, components=[SpaceDrawer, make_plot_component(["Trader", "Price"])], model_params=model_params, name="Sugarscape {G1, M, T}", diff --git a/mesa/examples/basic/boid_flockers/app.py b/mesa/examples/basic/boid_flockers/app.py index 074c1ab341f..16b1ccf7f68 100644 --- a/mesa/examples/basic/boid_flockers/app.py +++ b/mesa/examples/basic/boid_flockers/app.py @@ -12,6 +12,11 @@ def boid_draw(agent): model_params = { + "seed": { + "type": "InputText", + "value": 42, + "label": "Random Seed", + }, "population": Slider( label="Number of boids", value=100, diff --git a/mesa/examples/basic/boltzmann_wealth_model/app.py b/mesa/examples/basic/boltzmann_wealth_model/app.py index c03d1763619..b86c4b87da3 100644 --- a/mesa/examples/basic/boltzmann_wealth_model/app.py +++ b/mesa/examples/basic/boltzmann_wealth_model/app.py @@ -12,6 +12,11 @@ def agent_portrayal(agent): model_params = { + "seed": { + "type": "InputText", + "value": 42, + "label": "Random Seed", + }, "n": { "type": "SliderInt", "value": 50, @@ -20,11 +25,6 @@ def agent_portrayal(agent): "max": 100, "step": 1, }, - "seed": { - "type": "InputText", - "value": 42, - "label": "Random Seed", - }, "width": 10, "height": 10, } diff --git a/mesa/examples/basic/conways_game_of_life/app.py b/mesa/examples/basic/conways_game_of_life/app.py index e2219c9d2ff..4423f873c87 100644 --- a/mesa/examples/basic/conways_game_of_life/app.py +++ b/mesa/examples/basic/conways_game_of_life/app.py @@ -20,6 +20,11 @@ def post_process(ax): model_params = { + "seed": { + "type": "InputText", + "value": 42, + "label": "Random Seed", + }, "width": { "type": "SliderInt", "value": 50, diff --git a/mesa/examples/basic/schelling/app.py b/mesa/examples/basic/schelling/app.py index 933b3c2703d..56c0547ac6f 100644 --- a/mesa/examples/basic/schelling/app.py +++ b/mesa/examples/basic/schelling/app.py @@ -19,6 +19,11 @@ def agent_portrayal(agent): model_params = { + "seed": { + "type": "InputText", + "value": 42, + "label": "Random Seed", + }, "density": Slider("Agent density", 0.8, 0.1, 1.0, 0.1), "minority_pc": Slider("Fraction minority", 0.2, 0.0, 1.0, 0.05), "homophily": Slider("Homophily", 3, 0, 8, 1), diff --git a/mesa/examples/basic/virus_on_network/app.py b/mesa/examples/basic/virus_on_network/app.py index 7f3a905b126..f278f2334ec 100644 --- a/mesa/examples/basic/virus_on_network/app.py +++ b/mesa/examples/basic/virus_on_network/app.py @@ -35,6 +35,11 @@ def get_resistant_susceptible_ratio(model): model_params = { + "seed": { + "type": "InputText", + "value": 42, + "label": "Random Seed", + }, "num_nodes": Slider( label="Number of agents", value=10,