AI learns escape a room.
This is a rust based implementation of a genetic algorithm and reinforcement learning simulation that trains an AI named Zoe to escape from five rooms of increasing difficulty. The simulation is built using the macroquad library.
- Clone the repo
git clone [email protected]:bones-ai/rust-escape-ai.git cd rust-escape-ai
- Run the simulation
cargo run --release
- To update the simulation configurations use the configs file located at
src/configs.rs
- Tiled map editor is used for building the 2d levels
- To create custom levels and play around with the AI, use tile layers with names
player
,keys
,door
,walls
,spikes
,enemies
andbackground
. I suggest taking a look at how other maps are built to understand how things are to be setup.
- The project config file is located at
src/configs.rs
- The game rooms have to be manually configured in the config file.
Spacebar
- Pause/Unpause the simulationTab
- Show/hide the egui control menur
- Restart the simulationBackspace
- Slow modeBackslash
- Enable AI, start the AI training process (Use this to play the game yourself, using keyboard inputs wasd)Right Shift
- Run at 5x speedMouse wheel
- Zoom in/outMouse wheel with ctrl
- Large zoom in/outRight mouse click drag
- Pan through the world- To draw all training AI agents, use the egui menu, then select
Show Multi
. Caution, if you have too many game rooms being simulation, this could freeze your machine.
- Try restarting (using shortcut
r
). It's impossible to get the same results as in the youtube video as every simulation run is random. Sometimes Zoe might get stuck (or spend a lot of time/steps) in a region, letting the simulation run for a longer is an option (but it'll take a long time). - Update
NUM_FRAMES
to a larger value. Once the room is solved, Zoe will try to solve the room more efficiently (i.e taking less steps) - Run the simulation at 5x (by using shortcut
Right Shift
). Some rooms can take a lot of generations to solve. - Disable the drawings in the egui menu to speed up the training process