Visual, block-based model builder for Mesa agent-based models.
Mesa Blocks allows you to rapidly prototype agent-based models by dragging and dropping blocks representing agents, spaces, and behaviors. It provides a live simulation preview and generates clean, idiomatic Python code using the Mesa framework.
- Visual Editor: Drag blocks onto a canvas and wire them together to define your model.
- Live Preview: Run simulations directly in the browser with real-time grid and chart visualizations.
- Code Generation: Instant preview of runnable Python code that matches your visual model.
- Save/Load: Export your model configurations as JSON to share or resume later.
- Standard Mesa: Generated code uses standard
mesa.Modelandmesa.Agentpatterns.
# Clone the repository
git clone https://github.com/falloficarus22/mesa-blocks
cd mesa-blocks
# Install in editable mode
pip install -e .Launch the visual editor:
mesa-blocksOr from Python:
import mesa_blocks
mesa_blocks.run()Navigate to http://127.0.0.1:8765 in your browser.
- Model: The main container for your simulation. Set initial seed and max steps.
- Grid Space: Configure the environment (Width, Height, Torus).
- Agent Type: Define agent classes with specific colors and starting counts.
- Behaviors:
Move Random: Standard random walk.Move to Empty: Jump to a random empty neighbor.Die: Probabilistic agent removal.Reproduce: Probabilistic creation of new agents of the same type.
- Data:
Count Agentsto track population over time in the live chart.
Mesa Blocks follows a clean client-server architecture:
- Frontend: Vanilla JS/CSS/HTML with SVG for connections.
- Backend: Flask server that dynamically generates and runs Mesa models.
Apache-2.0
