An AI made using neat-python, that can beat the first few levels of Sonic the Hedgehog Classic on the Sega Genesis
This is my Python source code for training a Neuroevolution of Augmenting Topologies (NEAT) artifical intellegence to play Sonic The Hedghehog on Sega Genesis, using the neat-python library implementation.
- Can be applied to almost any level without any changes, and high success rate
- Uses only pixel data. No in-game variables! (Except for Sonic's X position used to calculate reward)
- Uses uncommon NEAT approach instead of A3C
- Multiprocessed
- Slow to train, ~2.5 hours per level on RTX 2070
- Can't beat levels where Sonic has to go to the left
interestingly, it doesn't understand the concept of building up speed to get over ramps, and will instead find a way to glitch through them!
pip install -r requirements.txt
python -m retro.import /roms/
- Python 3.6
- neat-python
- opencv2
- numpy
- gym-retro
- argparse
^ All found in requirements.txt
python replay.py winner-GreenHillZone.Act1.pkl GreenHillZone.Act1
python train.py GreenHillZone.Act1 -r
Adding the -r flag lets you watch the AI play as it trains. (significantly slower)
Replace GreenHillZone.Act1 with any level of your choice
Inspired by https://www.youtube.com/watch?v=8dY3nQRcsac