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.
- 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
- Python
- Pygame
- NumPy
- Matplotlib
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.
Install dependencies:
pip install pygame numpy matplotlibRun the project:
python3 main.pyThe 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
data/
models/
training/
main.py
game_objects.py
utils.py
Visual.py
config.py
The project is finished, this project building experience shows the imporance of cleaning data.

