Skip to content

A reinforcement learning environment implementing the classic Pong game using Pygame and Gymnasium. The environment includes both a playable version and training capabilities using Stable Baselines 3.

Notifications You must be signed in to change notification settings

roboserg/pong-env

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pong RL

A reinforcement learning environment implementing the classic Pong game using Pygame and Gymnasium. The environment includes both a playable version and training capabilities using Stable Baselines 3.

Pong RL Demo

▶️ Watch full video

Features

  • Custom Gymnasium environment for Pong
  • Human playable mode with keyboard controls
  • AI training using PPO (Proximal Policy Optimization)
  • Real-time visualization of training progress
  • Configurable game parameters (speed, size, colors)
  • Visual effects (shadows, smooth animations)

Usage

Playing the Game

Run the play script to play against the hardcoded AI:

python scripts/play.py

Controls:

  • Up Arrow: Move paddle up
  • Down Arrow: Move paddle down
  • ESC: Quit game

Training an Agent

To train a new agent:

python scripts/train.py

The training script will:

  • Create a new run directory in logs/
  • Save the best model during training
  • Log metrics to TensorBoard
  • Display periodic evaluation episodes

Evaluating a Trained Agent

To evaluate a trained model:

python scripts/eval.py

Development

For development, install additional dependencies:

pip install -r requirements-dev.txt

Acknowledgments

About

A reinforcement learning environment implementing the classic Pong game using Pygame and Gymnasium. The environment includes both a playable version and training capabilities using Stable Baselines 3.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages