Skip to content

Conversation

@darshi1337
Copy link

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 DataCollector to 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 SolaraViz capabilities.


Implementation

The model is split across three files:

model.py

  • Orthogonal grid with one agent per cell
  • Random mine placement via PropertyLayer
  • Frontier-based reveal logic (flood-fill–like propagation)
  • Automatic reseeding of unrevealed safe regions
  • DataCollector tracking:
    • Total revealed cells
    • Frontier size per step

agents.py

  • MineCell agent storing:
    • Revealed state
    • Number of neighboring mines

app.py

  • Matplotlib-based grid visualization
  • Time-series plot showing reveal dynamics
  • Parameter controls for grid size, mine density, and seed

Notes

  • This model is non-interactive by design and does not implement player clicks.
  • I was wondering whether click-based interaction can currently be implemented for more complex models. From what I understand, Mesa does not yet support this functionality. I would also appreciate any suggestions or guidance on how click handling might be implemented within Mesa itself.

Running the example

solara run examples/minesweeper/app.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant