Skip to content

Latest commit

 

History

History
30 lines (24 loc) · 1.18 KB

README.md

File metadata and controls

30 lines (24 loc) · 1.18 KB

maze-cpp

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 updates
  • agent.h / agent.cpp — agent class (position + sensors, getters/setters only)
  • main.cpp — initialises randomness, runs 100 trials, handles display and stats
  • source.mz — maze layout file

To run

make
./main

The visualisation uses a boat-finding-land metaphor (yellow square = desert island start, green = mainland arrival).


Full write-up in French in the PDF.