Skip to content

Roshyoshi/Pong-py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

How to play

  • W to move up.
  • S to move down.

How to train

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.

How Training Works

Uses a simple pong game made using the py-game library as its framework for training.

To train an optimal neural network ...

  1. 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.
  2. 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.
  3. 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.
  4. 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.

Releases

No releases published

Packages

No packages published

Languages