A self-organizing robot swarm
Context
This project was built by a team of three, in the spirit of a “Game of Life” exercise but applied to autonomous agents instead of cells. The idea: simulate a swarm of robots that explore an unknown map, share information with each other, then go and collect resources based on what has been discovered. Everything is displayed in real time in a terminal.
My contribution: the simulation logic
My part was the core of the project: all the simulation logic and concurrent synchronization between robots. Two kinds of robots coexist: scouts, which explore the map randomly to discover resources, and collectors, which use breadth-first search (BFS) to go and collect the resources reported by the scouts.
Each robot runs on its own thread (2 scouts, 2 collectors), coordinated by a central thread through mpsc channels for asynchronous communication, with shared state protected by Arc<RwLock> so several threads can read and write the map without stepping on each other. It was a chance to really work with Rust’s concurrency concepts (ownership, the borrow checker, synchronization) on a concrete case rather than an isolated exercise.
The rest of the team handled procedural map generation (Perlin noise to place obstacles and resource deposits realistically) and the terminal interface with the Ratatui library, which displays the map and robots in real time with color coding.
Tech stack
- Rust
- Ratatui for terminal rendering
- mpsc channels and Arc<RwLock> for concurrency
- Perlin noise for map generation
You can browse the project on GitHub.