Skip to content

sushantPatrikar/pingpongAI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pingpongAI

Ping Pong game, but AI plays it


AI plays Ping Pong using Neuroevolution of Augmenting Topologies(NEAT)

Every generation starts with the population of 200 bars. Every bar has it's own corressponding ball. The aim is to protect the ball from falling down. Once all the bars are dead, next generation is generated. For every 200 individuals of next generation 2 parents are selected from the previous genertion. The selected two parents are crossovered, followed by some percentage of mutation(generally low %).

Every bar looks in 5 direction:

It's distance from the ball in Quadrant I, relative to it's positon and ball's velocity(If it is present in Quadrant I)

It's distance from the ball in Quadrant II, relative to it's positon and ball's velocity(If it is present in Quadrant II)

It's distance from the ball in straight direction, relative to it's positon, and ball's velocity(If it is present overhead)

It's distance from the left wall.

It's distance from the right wall.

Initial generation looks like this

Initially, the bars have no clue, these are just random decisions i.e Move Right or Move Left

After some generations we see some improvements:

By this generation the bars start taking some sensible decisions

As the generations go on, the AI becomes master in playing this game

For detailed explanation, you can visit my website.

For human playable version of this game, Click here

Future Scope

Right now, the algorithm used is NEAT. Some other Reinforcement Learning algorithm, such as Deep Q-Learning can be applied to it. If you have any other ideas, Pull Requests are welcomed!