This project aims to create a Deep Q-Learning Convolutional Neural Network (DQCNN) that generalizes well on many Video games, but can mainly control the gamejam game "Driving Nightmare". The idea is that the only input the AI gets, are screenshots of the game and some sort of reward signal fitting to the game. The ingame UI elements have been remove from the named game to make the learning more consistent.
Here are demos of the two main games from the project: (both played by the trained AI)
dn_ai_lq_demo.mp4
fb_ai_demo.mp4
This repository contains two different models/frameworks:
Used was Python 3.10.11 and a requirements.txt is provided. But the specific packages installed are:
- pytorch
- tensorflow
- ipykernel
- pandas
- h5py
- matplotlib
- numpy
- pygame
- keyboard
- vgamepad
- pyautogui
- torchsummary
In dqcnn_tensorflow is the original DQCNN built for tensorflow. This started just as a CNN, but was later changed to a Reinforcement Learning approach.
In dqcnn_pytorch is a kind of "fork" of the original DQCNN built for pytorch. This was started to better utilize GPU ressources under windows and potentially make use of the more flexible computational graphs of pytorch.
Currently this version is not working, since even after much training it does not improve performance, unlike the original.
Both versions work pretty much the same way, since the branch was created after the original DQCNN was already working in general.
To make use of the network, a player class needs to be created that controls the game according to predictions, and also identfies and gives back the reward as feedback for learning.
This has been realized as DN_Player.py
and FB_Player.py
respectively.
They manage and run the full learning process and statistics by using model.py
. The longer they run, the more training data is accumulated in the asscociated folder, and in theory the better the model gets.
By using the stat_plotter.ipynb
you can gain insight into the current status by plotting the statistics with the loss and performance over time.
To learn more about the progression as well as the reasoning behind this project, you can read more in the project documentation.
Preview of the current performance:
(Time means the time survived in the game, the higher the better)