-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add fast PropertyLayer implementation of Game of Life #182
Conversation
0e026ad
to
0a36938
Compare
@projectmesa/maintainers this new example model is ready for review! It's the first one that uses the If I can find the time I will also see if I can update another model - maybe the grass in WolfSheep. |
Do you mind updating the top level README file to include this example? Perhaps with a new section for PropertyLayer examples? |
Yes of course, done! |
self.alive_count = 0 | ||
self.alive_fraction = 0 | ||
self.datacollector = DataCollector( | ||
model_reporters={"Cells alive": "alive_count", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nit, but this doesn't seem properly formatted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I already approved, so it is fine, not a big issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find ruff fine for the Mesa code base, but for examples I find it quite limiting at times.
b88a120
to
d8f553b
Compare
I can't figure out why I can't fast-forward merge, so rebase it is. |
A special implementation of Conway's Game of Life, using only the PropertyLayer, without needing a Grid or even any Agents.
Add minimal Solara visualisation, to control model parameters.
- Add two metrics to the model - Collect those with the datacollector - Plot them as measures in SolaraViz
The fast GoL model needs it.
Otherwise we can't use this experimental feature.
`steps` is now increased automatically, it's not needed anymore!
d8f553b
to
fc18ece
Compare
This pull request adds a fast implementation of Conway's Game of Life using the
PropertyLayer
. Unlike traditional approaches, this version doesn't rely on a grid or agents, making it simpler and more efficient (in this specific case).Key features
PropertyLayer
to track cell states, removing the need for a grid or agents. In this layer, a cell value of 1 means being alive, and 0 means being dead.Performance
As benchmarked in projectmesa/mesa#1898 (comment), this models is incredibly fast, about 100x over a traditional implementation.
Structure
This PR is structures in three commits:
Dependencies
This models needs SciPy for
convolve2d
, which is added to the test dependencies.Future work
It would be nice if the PropertyLayer itself could also be visualized, so that you can see Game of Life patterns. That needs support in Mesa however (or a custom
space_drawer
implemented here).Closes: #166