Skip to content

Commit

Permalink
GoL_fast: Visualize the Game of Life cells using the PropertyLayer
Browse files Browse the repository at this point in the history
  • Loading branch information
EwoutH authored Oct 3, 2024
1 parent 84542d4 commit a8b71b2
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions examples/conways_game_of_life_fast/app.py
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

0 comments on commit a8b71b2

Please sign in to comment.