brew install opam # Install OCaml itself
opam install . --deps-only -y # Install project dependencies
dune build # Build the project
Then install Rust and then
cd controller
cargo build --release
Then run the game with
dune exec patchlings -- -p 3
The -- -p 3
sets the number of players in the simulation to be 3
. This must match the number of assembly programs in the ./asm
directory.
To see command-line options, use
dune exec patchlings -- --help
A simulation framework for studying agent behaviors on grid-based environments.
Patchlings 2 is a multi-agent simulation where players with different behaviors navigate a grid world. The simulation tracks player survival, movement patterns, and generates statistical plots to analyze behavioral differences.
- Multiple Player Behaviors:
- RandomWalk: Moves randomly in cardinal directions
- CautiousWalk: Avoids dangerous (fire) tiles when possible
- Stationary: Stays in place
- Dynamic Environment: Grid world with safe (grass) and dangerous (fire) tiles
- Real-time Visualization: Emoji-based display with player positions
- Statistical Analysis: Automatic generation of survival and exploration plots
- Wrapping World: Players can move through map edges
Run the simulation:
dune exec patchlings
The simulation will:
- Display the grid world with emoji representation
- Show players moving with their respective behaviors
- Generate plots when the simulation completes (after 10 iterations or all players die)
player_ages_over_time.png
: Line plot showing player survival over timeplayer_unique_tiles.png
: Bar chart showing exploration patternsscripts/plot_line.py
andscripts/plot_bar.py
: Generated Python plotting scripts
- Grid World: 32x32 grid with 80% safe (🌱) and 20% dangerous (🔥) tiles
- Player Display:
- 🧍 for single player
- 👥 for multiple players on same tile
- Movement: Cardinal directions (North, South, East, West) plus staying in place
- Survival: Players die when stepping on fire tiles
- Statistics: Age (survival time) and unique tiles visited are tracked
The project is structured as:
lib/
: Core simulation logicboard.ml
: Grid world managementplayer.ml
: Player behaviors and stategame_state.ml
: Simulation state and coordinationintent.ml
: Movement direction definitionsplotting.ml
: Statistical analysis and plot generation
bin/
: Executable entry pointscripts/
: Generated Python plotting scriptstest/
: Unit tests
You can modify:
- Grid size and danger ratio in
board.ml
- Player behaviors in
player.ml
- Simulation length in
main.ml
(currently 10 iterations) - Number of test players and their starting positions
This project is open source. See the license file for details.