-
Notifications
You must be signed in to change notification settings - Fork 66
Wrappers
Christian Kauten edited this page Jul 22, 2018
·
20 revisions
nes-py includes a full collection of OpenAI Gym wrappers for standard functionality. These functions are located in the nes_py.wrappers
module.
- easily converting the 256 action binary space to a smaller space
- clipping rewards in {-1, 0, 1}
- downsampling frames to B&W with a smaller size via linear interpolation
- stacking the previous k frames into a frame tensor
- normalizing rewards in [-1, 1] using the L-infinity norm
- penalizing deaths using the done flag
- caching unmodified rewards for analysis
A simple way to define a much smaller action space. The initializer takes an environment and a list of button lists:
from nes_py.wrappers import BinarySpaceToDiscreteSpaceEnv
env = BinarySpaceToDiscreteSpaceEnv(env, [
['NOP'],
['right', 'A'],
['left', 'A'],
['A'],
])
Each button list should contain at least one of:
'right'
'left'
'down'
'up'
'start'
'select'
'B'
'A'
'NOP'
It is recommended for custom environments to use this wrapper by default. If there are multiple mappings, the package should provide each list and either register a different environment for each, or make note in the documentation for end users. See gym-super-mario-bros for an example of multiple button lists in the actions.py
module.
A wrapper to clip rewards based on their sign. i.e.
reward = 1 if reward > 0
reward = -1 if reward < 0
reward = 0 if reward == 0
from nes_py.wrappers import ClipRewardEnv
env = ClipRewardEnv(env)
from nes_py.wrappers import DownsampleEnv
from nes_py.wrappers import FrameStackEnv
from nes_py.wrappers import NormalizeRewardEnv
from nes_py.wrappers import PenalizeDeathEnv
from nes_py.wrappers import RewardCacheEnv
from nes_py.wrappers import wrap