A custom Reinforcement Learning environment where teams of Pokemon battle in a 3D arena. Built with Python, Gymnasium (PettingZoo), Pygame, OpenGL, and PyTorch.
- 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.
Ensure you have Python installed (3.8+ recommended). Install the required dependencies:
pip install gymnasium pettingzoo pygame PyOpenGL torch numpyTo train a new model from scratch:
python train.pyThis will start the training process, saving checkpoints to the checkpoints/ directory.
To watch a pre-trained model battle:
python test.pyTo control a Pokemon yourself against bots or other players (if configured):
python test_human.pyAll 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.
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.
- Language: Python
- RL Framework: Gymnasium, PettingZoo
- Deep Learning: PyTorch
- Rendering: Pygame, PyOpenGL
- Math/Physics: NumPy