https://github.com/matpoliquin/stable-retro-scripts
Train models on retro games. AI vs AI contest. Pytorch C++ plugin for RetroArch that let you override player input with models
https://github.com/matpoliquin/stable-retro-scripts
machine-learning pytorch reinforcement-learning retrogaming videogames
Last synced: 1 day ago
JSON representation
Train models on retro games. AI vs AI contest. Pytorch C++ plugin for RetroArch that let you override player input with models
- Host: GitHub
- URL: https://github.com/matpoliquin/stable-retro-scripts
- Owner: MatPoliquin
- License: mit
- Created: 2021-09-09T13:02:28.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2025-07-20T01:36:27.000Z (3 months ago)
- Last Synced: 2025-07-20T03:46:28.295Z (3 months ago)
- Topics: machine-learning, pytorch, reinforcement-learning, retrogaming, videogames
- Language: C++
- Homepage: https://www.videogames.ai
- Size: 105 MB
- Stars: 34
- Watchers: 3
- Forks: 11
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README


# stable-retro scripts
* Train models on retro games
* Pit two models against each other on PvP retro games such as NHL94, Mortal Kombat or WWF Wrestlemania: The Arcade Game
* Play against an improved AI opponent
* Emulator Frontend library using Pytorch C++ to able to play with or against stable-retro models in apps like RetroArch### Supported models
* MLPs
* Nature CNN (from DeepMind)
* Impala CNN (from DeepMind)
* Combined Input models (image + scalar)Experimental:
* Attention MLPsNHL94 (1 on 1) | Wrestlemania: The Arcade game | Virtua Fighter 1
:-------------------------:|:-------------------------:|:-------------------------:
 |  | ## Installation
Tested on Ubuntu 22.04/24.04 and Windows 11 WSL2 (Ubuntu 22.04 VM)
Requires:
* Python 3.7 and up
* gymnasium
* stable-baselines3
* stable-retro (fork of gym-retro)```
sudo apt update
sudo apt-get install python3 python3-pip git zlib1g-dev libopenmpi-dev ffmpeg cmakesudo pip3 install -U virtualenv
virtualenv --system-site-packages -p python3 ~/vretro
source ~/vretro/bin/activategit clone https://github.com/Farama-Foundation/stable-retro.git
cd stable-retro
pip3 install -e .pip3 install "stable_baselines3[extra]" pygame torchsummary opencv-python timm
```Windows WSL2 + Ubuntu 22.04 setup guide: https://www.youtube.com/watch?v=vPnJiUR21Og
## Install roms
You need to provide your own romsIn your rom directory exec this command, it will import the roms into stable-retro
```
python3 -m retro.import .
```### Train a model
Note: Airstriker is a public domain rom and is already included in stable-retro
```bash
python3 train.py --env=Airstriker-Genesis --nn=CnnPolicy --num_env=8 --num_timesteps=1_000_000 --play --hyperparams=../hyperparams/default.json
```## Game specific Examples
* For NHL94 specific page click [here](./readmes/NHL94-README.md)
* For Wrestlemania the arcade game specific page click [here](./readmes/WWF-README.md)## retro ai lib
C++ lib using Pytorch that runs models inside emulator frontends like retro arch to override player input. Which means you can play against a smarter opponent at NHL94 for example or let the AI play with you in COOP or play for you.
See [README](./retro_ai_lib/README.md) for build and install instructions
Tutorial video:
[](https://www.youtube.com/watch?v=hkOcxJvJVjk)