-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GoL_fast: Visualize the Game of Life cells using the PropertyLayer
- Loading branch information
Showing
1 changed file
with
15 additions
and
9 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,35 +1,41 @@ | ||
from mesa.visualization import SolaraViz, make_plot_measure | ||
from mesa.visualization import SolaraViz, make_plot_measure, make_space_matplotlib | ||
from model import GameOfLifeModel | ||
|
||
propertylayer_portrayal = { | ||
"cell_layer": { | ||
"color": "Black", | ||
"alpha": 1, | ||
}, | ||
} | ||
|
||
model_params = { | ||
"width": { | ||
"type": "SliderInt", | ||
"value": 10, | ||
"value": 20, | ||
"label": "Width", | ||
"min": 5, | ||
"max": 25, | ||
"max": 40, | ||
"step": 1, | ||
}, | ||
"height": { | ||
"type": "SliderInt", | ||
"value": 10, | ||
"value": 20, | ||
"label": "Height", | ||
"min": 5, | ||
"max": 25, | ||
"max": 40, | ||
"step": 1, | ||
}, | ||
} | ||
|
||
gol = GameOfLifeModel(10, 10) | ||
gol = GameOfLifeModel() | ||
|
||
layer_viz = make_space_matplotlib(propertylayer_portrayal=propertylayer_portrayal) | ||
TotalAlivePlot = make_plot_measure("Cells alive") | ||
FractionAlivePlot = make_plot_measure("Fraction alive") | ||
|
||
|
||
page = SolaraViz( | ||
gol, | ||
components=[TotalAlivePlot, FractionAlivePlot], | ||
components=[layer_viz, TotalAlivePlot, FractionAlivePlot], | ||
model_params=model_params, | ||
name="Game of Life Model", | ||
) | ||
page # noqa |