The techniques used in this project are:
- Deep Learning
- Q Learning
- Simulated Annealing
- Heuristics
The Pacman game is implemented using pygame, and converted into a GYM environment. After that, the keras-rl library is used to make, train and test the model.
- Contains variables to set up the gym environment.
- Sets up the environment. Used by gym.
- Contains the class for the ghosts. Has all the functions that the ghosts need, like move, return to home, etc.
- Contains the functions that set the level design up. Like setting all the food, superfood, walls, etc. up.
- Contains the functions for the pacman entity. Has all the functions like move, eat, respawn, etc. (not named as such, but perform the following).
- This is the main file with the class that gym uses to interface with the game environment. This file consists of the game loop, defined as per as the gym definition requires it. Has graphic rendering functions, game system functioning, score handling, etc.
- This file consists of the game over screen. Uses pygame to render the graphics.
- This file consists of the model training script and the model testing scripts. It generates the model and tests it.
- This is the model that is saved. Using keras-rl library.
- This is just a log file that keeps track of the callbacks.
- Python 3
- Pygame
- Keras-rl
- Numpy
- Gym
- Tensorflow
- Pip
- Jupyter Notebook
Go to the pac folder. Open command prompt/terminal from that folder. Enter:
pip install -e
This will install the environment.
Open Pac.ipynb and set the variable from:
mode = “train”
to
mode = “test”
And run all the cells.
(NOTE: If you wish to train the model yourself, then leave the variable as it is, and just run all the cells. Make sure the “mode” variable is set to “train” and not “test”.)
A very fast game, is played. Will have to minimize the jupyter notebook, that is running the script.
The AI will perform better with more training. An approximate of 20 days worth of training with better tuned parameters should get us somewhere. This model attached, is with only approximately 1 hour of training.