A C++ console and graphics simulation of robot swarms demonstrating multiple behavioral strategies including flocking, formation movement, pathfinding, and predator/prey dynamics.
- Multiple Behavior Strategies: Robots can exhibit flocking, formation, pathfinding, and predator/prey behaviors
- Console & Graphics Modes: Run as a lightweight console app or with a full interactive raylib UI
- Interactive Controls: Click-to-move targets and dynamic environment switching (Sandbox/Maze modes)
- Collision Detection: Robots collide with each other and obstacles (rocks, walls)
- Live Statistics: Real-time tracking of robot count, energy, speed, and more
- Object-Oriented Design: Clean architecture with behavior interfaces and concrete implementations
.\scripts\build.bat
.\build\swarm_sim.exe.\scripts\build-raylib.bat
.\build\swarm_sim_raylib.exe --graphics# Adjust simulation speed
.\build\swarm_sim_raylib.exe --graphics --speed 2
# Quick console test (5 steps, no delays)
.\build\swarm_sim.exe --steps 5 --no-delay- C++ Compiler: g++ (MinGW) with C++17 support
- For Graphics Mode: raylib library (included in
third_party/or setRAYLIB_PATHenvironment variable)
Ensure you have g++ installed. Test with:
g++ --version.\scripts\build.batOr manually:
g++ -std=c++17 -Wall -Wextra -Wpedantic -Iinclude src\main.cpp src\DemoWorld.cpp src\Robot.cpp src\World.cpp src\Renderer.cpp src\Simulator.cpp src\FlockingBehavior.cpp src\FormationBehavior.cpp src\PathfindingBehavior.cpp src\PredatorPreyBehavior.cpp -o build\swarm_sim.exeIf raylib is installed locally in third_party/:
.\scripts\build-raylib.batOr set an external raylib path:
$env:RAYLIB_PATH = "C:\path\to\raylib"
.\scripts\build-raylib.batSee docs/RAYLIB_SETUP.md for detailed raylib setup instructions.
- Runs for a fixed number of steps
- Periodically changes target location
- Output shows robot positions and behaviors
- Click in the field: Move target to that location
- Speed slider: Adjust simulation speed (0.1 - 5.0)
- Robot count slider: Add/remove robots dynamically
- Energy slider: Set robot energy levels
- Rocks/Walls: Toggle obstacles
- Sandbox/Maze switch: Change environment mode
- Sandbox: Robots follow your clicks
- Maze: Four robots navigate fixed checkpoints through a maze
R= Flocking robotF= Formation robotP= Pathfinding robotX= Predator robot*= Target#= Obstacle (rock/wall)
src/ C++ implementation files
include/ C++ header files
docs/ Documentation and project notes
scripts/ Build scripts (build.bat, build-raylib.bat)
third_party/ External libraries (raylib)
build/ Compiled executables
CMakeLists.txt CMake configuration (alternative build method)
docs/OOD_ARCHITECTURE.md- Object-oriented design detailsdocs/RAYLIB_SETUP.md- Detailed raylib setup and troubleshootingdocs/PROJECT_SETUP_GUIDE.md- C++ graphics project setup guideSOFTWARE_WORKFLOW_GUIDE.md- General software project workflow guide
- Check if raylib is in
third_party/raylib/include/ - Or set
$env:RAYLIB_PATHto your raylib installation - See
docs/RAYLIB_SETUP.mdfor help
- Ensure you're running with
--graphicsflag - Check that raylib was built successfully
- Run console version first to verify basic compilation works
- Try running with
--steps 5 --no-delayfor instant output - Check console window hasn't scrolled past output
- Run the console version to verify the build works
- Try the graphics version for the full interactive experience
- Explore
src/to understand the behavior implementations - Check
docs/OOD_ARCHITECTURE.mdfor design patterns
- The console version runs standalone with no external dependencies
- The graphics version requires raylib (MIT licensed)
- Robots use a modular behavior system for easy extensibility
- The project demonstrates OOP principles with abstract base classes and polymorphism