Add step-based Minesweeper example with data collection#305
Add step-based Minesweeper example with data collection#305darshi1337 wants to merge 5 commits intomesa:mainfrom
Conversation
There was a problem hiding this comment.
Thanks for the PR.
Interesting to see a game here, not the primary target of Mesa but certainly fun!
I noticed I couldn't interact with it. That would be quite cool. Maybe with our Altair visualisation that would be easier than with matplotlib, but not sure.
@Sahil-Chhoker do you know if interactivity / clicking on a cell is possible at all?
|
@EwoutH I’ve made the changes as suggested. Let me know if anything else is needed. |
|
Thanks! We don't have games yet, we might want to give those a dedicated place. Will loop back. |
I don't think it's possible, currently we serve a solara's Maybe a custom component that makes grid using solara buttons with image overlays can work, because the user has granular control over a custom component. Can't say anything for sure though. |
Description
I added a step-based Minesweeper model as a new example in
mesa-examples. This model reframes Minesweeper as an autonomous spatial diffusion process rather than an interactive game, making it suitable as an educational and analytical Mesa example.The model demonstrates how local neighborhood rules and a frontier-based propagation mechanism can produce emergent spatial patterns on a discrete grid.
Motive
Demonstrate frontier-based spatial propagation
The model uses an explicit frontier to control which cells are processed at each step, illustrating wave-like expansion and natural termination.
Show neighborhood-driven dynamics
Cell behavior depends entirely on local neighborhood state (number of adjacent mines), highlighting classic cellular automaton principles.
Combine spatial and temporal analysis
In addition to grid visualization, the example includes a
DataCollectorto track and plot how the system evolves over time.Provide a clear, non-interactive reference model
The example avoids user interaction and instead focuses on step-wise dynamics, aligning with current
SolaraVizcapabilities.Implementation
The model is split across three files:
model.py
PropertyLayerDataCollectortracking:agents.py
MineCellagent storing:app.py
Notes
Running the example