This AI can train a car to complete a custom track drawn by the user and find the shortest path possible. The AI is made from scratch using custom classes and utilizes a Q-Learning Agent for training.
draw_track.py
: Allows you to create a custom track using Pygame.train.py
: Trains a Q-Learning Agent to find the optimal path to reach the finish on your custom track.
- Learning curve: Graph of the learning curve
- Best attempt: Video of the best attempt.
- GIFs: GIFs of the best attempts; of each time the max reward is surpassed
- Combined attempts: Video of the combined attempts.
Graph depicting the AI's learning trajectory over training sessions.
Footage of the AI's optimal path completion.
Montage video showing a range of attempts, visualizing the AI's evolution.
GIFs capturing breakthrough moments when the AI outperformed its previous best (these are just some of them).
- Clone the repository:
git clone <repository_link>
- Install required packages:
pip install -r requirements.txt
Run draw_track.py
to create your own track:
python3 draw_track.py
- Options
- ⌃ Control S Save track.
- ⌃ Control Z Undo.
- Bucket fill (⇧ Shift) COLOR Left Click
- B Background color.
- R Road color.
- O Obstacle/border color.
- S Start color.
- F Finish color.
After drawing your track, run train.py
:
python3 train.py
This initiates the training loop and generates videos and graphs of the training process. The training process can be configured in the conf
directory.
Customize various settings in the conf
directory:
conf.general.py
: General settings.conf/track.py
: Track settings.conf/agent.py
: Agent settings (Q-Learning).
classes/
:TrackEnv.py
: Custom environment for the track.QLearningAgent.py
: Q-Learning Agent.
constants/
: Constant values and paths.general.py
: General, agent and track constants.paths.py
: Path constants.
conf/
: Configuration settings.general.py
: General settings.track.py
: Track settings.agent.py
: Agent settings (Q-Learning).
utils/
: Utility functions like plotting.track/
: Stores the custom track.track.npy
: Numpy array of the track.
out/
: Stores the learning curve PNG image after training.learning_curve.png
: Learning curve PNG image.best_attempt.mp4
: Video of the best attempt.combined_attempts.mp4
: Video of the combined attempts.attempts/
: Folder containing GIFs of the best attempts; of each time the max reward is surpassed.
train.py
: Trains a Q-Learning Agent to find the optimal path to reach the finish on your custom track.draw_track.py
: Allows you to create a custom track using Pygame.requirements.txt
: Required packages.LICENSE.md
: MIT License.