Skip to content

AndroidAkash01/AI_Pong_Game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Pong Game

AI Pong gameplay demo

A small experimental Pong AI project built with Python and Pygame.

The purpose of the project is to explore how a - 2 layer 30 neurons Neural Network, can improve its behavior over time through reward-based learning and repeated training. The project includes different training ideas such as focused replay after missed balls, adaptive rewards, and live visualization of training progress.

The project was mainly created as a learning and experimentation environment for:

  • game AI
  • reinforcement-learning inspired systems
  • reward shaping
  • neural network visualization
  • training analysis

The implementation is intentionally kept relatively simple and readable in order to make experimentation easier.

Features

  • Pong game simulation (basic physics)
  • AI-controlled paddle
  • Data based enforced training system
  • Reward-based training system
  • Neural network visualization
  • Real-time gameplay rendering using Pygame

The 2 layer Neural Network this Ai is trained on

---

Technologies

  • Python
  • Pygame
  • NumPy
  • Matplotlib

Training Approach

There were 2 approaches to train the modle - Enforced learning and Reward based learning

Enforced Learning - Human playing with a paddle was recorded against a wall type program (another paddle moved along with y axis value of ball). The values of position of ball, and position of paddle was all recorded and saved in a file. The next step which was very important was - Cleaning the data was performed, successfully removing the empty values in middle of motion captured while moving because of aliasing(very likely). After that the model was trained and with few epochs and 1000-2000 rows of data, model was perfectly working.

Reward Based Learning -

The AI receives rewards for successful interactions and penalties for missed actions. Different reward strategies can be tested and adjusted in order to observe how learning behavior changes over time.

The project also includes a “train on miss” mode where difficult situations can be repeated multiple times to improve learning stability.


Running the Project

Install dependencies:

pip install pygame numpy matplotlib

Run the project:

python3 main.py

Project Goal

The goal of the project is not to create a perfect AI system, but rather to explore and better understand:

  • training behavior
  • ceaning data
  • learning stability
  • reward balancing
  • iterative improvement in simple environments

Repository Structure

data/
models/
training/
main.py
game_objects.py
utils.py
Visual.py
config.py

Notes

The project is finished, this project building experience shows the imporance of cleaning data.

About

Self-learning Pong AI in Python.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages