I am a management consultant exploring the World of Artificial intelligence.

Manually play Airstriker-Genesis with your keyboard in the OpenAI Gym Retro

Since it took me a while to find the answer to the question of how to play Airstriker-Genesis with my keyboard in the OpenAI Gym Retro, I wanted to write it down here - maybe helps someone else looking for this.

First, go here and use that code. It sets you up perfectly fine to play in the standard (non-retro) gym version. Problem is though, if you want to play Airstriker-Genesis by replacing this line…

env = gym.make('LunarLander-v2' if len(sys.argv)<2 else sys.argv[1])

with this one…

env = retro.make(game='Airstriker-Genesis' if len(sys.argv)<2 else sys.argv[1])

… you’ll run into the following error:

ap = a[self.num_buttons * p:self.num_buttons * (p + 1)]
TypeError: 'int' object is not subscriptable

After searching around for a while, the solution is very easy. Replace above line of code with this one:

env = retro.make(game='Airstriker-Genesis', use_restricted_actions=retro.Actions.DISCRETE)

Everything should just run fine by then. You can use keys ‘5’ and ‘6’ for left and right and ‘9’ to fire.

Movement Predictions in Airstriker Genesis

Movement Predictions in Airstriker Genesis

Action Space for the OpenAI Retro Gym game Airstriker-Genesis

Action Space for the OpenAI Retro Gym game Airstriker-Genesis