Giter Site home page Giter Site logo

sushantpatrikar / pingpongai Goto Github PK

View Code? Open in Web Editor NEW
16.0 2.0 8.0 1.7 MB

Ping Pong game, but AI plays it :robot:

Home Page: https://sushantpatrikar.github.io/

License: MIT License

Python 100.00%
ai artificial-intelligence neat neat-python neat-algorithm genetic-algorithm pygame neural-network machine-learning ml artificial-neural-networks ai-plays-game ping-pong python3 python-3 neuroevolution reinforcement-learning reinforcement-learning-algorithms

pingpongai's Introduction

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!

pingpongai's People

Contributors

imgbotapp avatar sushantpatrikar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pingpongai's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.