Prison AI


Project made for the AI module at ESAT, final year. It consist of a prison with guards, soldiers and workers. Each agent has its own state machine, divided in mind and body (mind calculates, body executes). Developed in C++ using an ESAT Graphic library similar to SFML.

In the video, the demo will freeze when the alarms sets off because it was recorded in debug mode and each prisoner calculates a new path using A Star path calculation.



  • State machines and sub state machines.
  • Node graph for the guards movement.
  • A Star path calculation (optimized to calculate new paths in real time).
  • Simulation loop: Start, update, draw and input service functions.

Prisoners (red dots): The prisoners, until one of the doors is open, will be working or resting. Only 5 prisoners can work at the same time carrying boxes. When prisoners carry a box, their speed will be reduced. As long as there is no free space to work, the rest of the prisoners will be at the rest area.

Soldiers (blue dots): The soldiers must set the prisoners free. To do that, they have to the right door and open it, after this they will go into the prison and open the left foor. They will be in a loop, opening doors, until all the prisoners have the oportunity to escape.


Guards (green dots): The guard will patrol inside the prison. When a guard detects a door open, the alarm will be set off and the guards will chasing the soldiers and close the doors.