openai / retro

Retro Games in Gym
MIT License
3.39k stars 526 forks source link

Filtered Actions #245

Open onaclov2000 opened 3 years ago

onaclov2000 commented 3 years ago

Issue summary

I am having issues with the start and select keys being operational for SNES.

in retro_env.py printing "action" prior to filtering, shows a value for select and start, however if you print action after filtering it will show 0.

action = self.data.filter_action(action)

While most games may not require start or select, the game Super Metroid requires both, (one for selecting weapons, and the other for menuing to turn items on and off).

commenting out the filter_action seems to work, but I'm not sure what the larger implications are.

onaclov2000 commented 3 years ago

A better question might be "What does filtering actually do?" I think if I understood the goal up front, it might make sense and I can figure out the more "correct" solution.

endrift commented 3 years ago

The point of filtering actions is to prevent your agent from attempting key presses or combinations that aren't useful in the game, to reduce the search space. For example, in Super Mario Bros, unfiltered actions will include the Start button, which pauses the game, but filtered actions won't.

onaclov2000 commented 3 years ago

@endrift is there somewhere you can (or rather are supposed to) edit the filtered actions per game? For Super Metroid for example it's important you can access the start screen during the game, so you can turn on and off different upgrades occasionally. (or refill health as that is one operation that is useful).

endrift commented 3 years ago

Yes, they can be overridden per game in the scenario.json, see https://github.com/openai/retro/blob/98fe0d328e1568836a46e5fce55a607f47a0c332/retro/data/stable/KidChameleon-Genesis/scenario.json for an example. Each top-level is a set of buttons that can be pressed independently of each other one, so you can press up, down or none × left, right or none × all of the variants in the bottom row.