Skip to content

saranshhalwai/RL-colearning

Repository files navigation

Pokemon 3D Team Battle Engine

A custom Reinforcement Learning environment where teams of Pokemon battle in a 3D arena. Built with Python, Gymnasium (PettingZoo), Pygame, OpenGL, and PyTorch.

Features

  • Multi-Agent Environment: Supports team-based battles (e.g., 2v2, 3v3) using the PettingZoo API.
  • 3D Rendering: Real-time 3D visualization using Pygame and OpenGL.
  • Custom Physics & Mechanics:
    • Lidar-based perception (walls, enemies, teammates).
    • Strategic elements: Backstab bonuses, friendly fire penalties, and team coordination rewards.
    • Turn-based-like actions in a continuous simulation (move, rotate, attack).
  • RL Integration: designed for training with PPO (Proximal Policy Optimization) using PyTorch.

Installation

Ensure you have Python installed (3.8+ recommended). Install the required dependencies:

pip install gymnasium pettingzoo pygame PyOpenGL torch numpy

Usage

Training Agents

To train a new model from scratch:

python train.py

This will start the training process, saving checkpoints to the checkpoints/ directory.

Testing / Watching Agents

To watch a pre-trained model battle:

python test.py

Human Playable Mode

To control a Pokemon yourself against bots or other players (if configured):

python test_human.py

Configuration

All simulation parameters are defined in config.py. You can modify:

  • Team Settings: Number of agents, team colors.
  • Rewards: Win/loss, damage, backstab bonuses, penalties.
  • Physics: Movement speed, rotation speed, attack range.
  • Rendering: Screen size, FPS.
  • Training: Learning rate, batch size, total timesteps.

File Structure

  • custom_env.py: The core Gymnasium/PettingZoo environment logic.
  • model.py: The PyTorch Actor-Critic network architecture.
  • config.py: Central configuration file for all settings.
  • train.py: Main training script using PPO.
  • test.py: Script to load and evaluate trained models.
  • pokemon.py: Class definition for Pokemon entities (physics, state).
  • ground.py: Rendering logic for the arena.
  • verify_dist.py: Utility to verify spawn distances and mechanics.

Tech Stack

  • Language: Python
  • RL Framework: Gymnasium, PettingZoo
  • Deep Learning: PyTorch
  • Rendering: Pygame, PyOpenGL
  • Math/Physics: NumPy

About

Used RL colearning techniques to make a pokemon team battle game.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages