/super-mario-neat

This program evolves an AI using the NEAT algorithm to play Super Mario Bros.

Primary LanguagePythonMIT LicenseMIT

Super Mario NEAT

This program uses the NEAT algorithm to evolve a Neural Network to play the original Super Mario Bros.

Requirements

You can install the requirements by running

sudo apt install fceux
python3 -m pip install -r requirements.txt

Or if on windows, run

python3 -m pip install -r requirements.txt
  • Make sure you have FCEUX downloaded and added to PATH

Training

The finisher.pkl file contains the best genome on generation 2284. In ./Files, you can find the backup for generation 2284, and the backup for generation 2492, which is where I stopped training.

You can continue training by running

python3 main.py cont_train --gen <num_generations> --file <file>

Running

To run the finisher.pkl file, run

python3 main.py run

or run

python3 run.py

If you want to run a different file, run

python3 main.py run --file <file_name>

Config

For debugging values, you can change any of the values in the config file. Note that you have to train from the 1st generation for some to take effect.
To use a different config file when training, specify --config <config file> when running main.py.

Multiprocessing

This program uses the build in python module multiprocessing, which is used for parallel computing. You can adjust the amount of genomes to run at once by specifying --parallel <num_of_genomes> when running main.py.

Levels

The default level is World 1, Level 1. This can be changed by specifying --level <level> when running main.py. For example,
python3 main.py train --gen 100 --level "1-1" will use 1-1.

Result

The finisher.pkl file is trained to complete 1-1. It can complete it around 50% of the time. The run.py file keeps running the simulation until it completes the level. Ctrl + C will stop it.


Additional Information

The Wiki contains more information regarding the specifics of implementing certain parts.