This is a refactor of a project from 2018 where DQN was implemented in Tensorflow 1.x with Openai's gym-retro. Here it is refactored to Pytorch 2.x using the currently maintained stable-retro.
python3 -m venv "venv"
. venv/bin/activate
pip install -r requirements.txt
mkdir roms && wget -P roms https://archive.org/download/ni-roms/roms/Sega%20-%20Mega%20Drive%20-%20Genesis.zip/Sonic%20The%20Hedgehog%202%20%28World%29%20%28Rev%20A%29.zip
python3 -m retro.import ./roms
python train_dqn.py
Follow the progress with Tensorboard
tensorboard --logdir ./runs
python play_episode.py path/to/weights.pt greedy --record ./movie.bk2
python human_record.py --record ./movie.bk2
python3 -m retro.scripts.playback_movie ./movie.bk2