A simple one player pong game that pits you against an neural network trained for pong. Trained using the NEAT algorithm, which is optimal for creating game AI.
- W to move up.
- S to move down.
The model comes pretrained. However for whatever reason if you would like to retrain the model for whatever reason, simply press anything other than 1 on the first prompt.
Uses a simple pong game made using the py-game library as its framework for training.
To train an optimal neural network ...
- A set of 50 basic feed forward neural networks are created using the NEAT library. These take in 3 inputs: the y coordinate of the paddle, the y coordinate of the ball, and the difference between the Y coordinate ball, and generate the output of whether to move the paddle up, down, or to stay still.
- These networks are pitted against one another in a game of pong, evaluting their fitness through the number times the ball is hit by each paddle.
- Finally using the various selection methods of NEAT, the best neural networks with the higheset fitness are moved on to the next generation, new networks will be generated based on these, and once again pitted against each other.
- this is repeatted for 50 generations until finally, an optimal neural network is created.
Finally, this optimal network is saved as an object through the pickle library for later use.