A C++ simulation of a random-walk agent navigating a 21×12 maze, written as part of the C++ course I took at CY Tech, taught by Prof. Pierre Andry. The agent moves randomly until it finds the exit; running 100 trials produces a minimum of 493 steps, a maximum of 27,197, and a mean of ~6,169.
The main technical challenge was a segmentation fault caused by the agent trying to
read out-of-bounds memory at the maze edges. I fixed this by writing a private
updateCapteurs() function that calculates the agent's x/y position and checks for
border conditions before reading _map. The agent is deliberately "dumb", it holds
only its position and four directional sensors; all logic lives in the maze class.
Structure
maze.h / maze.cpp— maze class, movement logic, sensor updatesagent.h / agent.cpp— agent class (position + sensors, getters/setters only)main.cpp— initialises randomness, runs 100 trials, handles display and statssource.mz— maze layout file
To run
make
./mainThe visualisation uses a boat-finding-land metaphor (yellow square = desert island start, green = mainland arrival).
Full write-up in French in the PDF.