plangym.videogames.nes

Environment for playing Mario bros using gym-super-mario-bros.

Module Contents

Classes

NesEnv

Environment for working with the NES-py emulator.

MarioEnv

Interface for using gym-super-mario-bros in plangym.

Attributes

RIGHT_ONLY

SIMPLE_MOVEMENT

COMPLEX_MOVEMENT

plangym.videogames.nes.RIGHT_ONLY = [['NOOP'], ['right'], ['right', 'A'], ['right', 'B'], ['right', 'A', 'B']]
plangym.videogames.nes.SIMPLE_MOVEMENT = [['NOOP'], ['right'], ['right', 'A'], ['right', 'B'], ['right', 'A', 'B'], ['A'], ['left']]
plangym.videogames.nes.COMPLEX_MOVEMENT = [['NOOP'], ['right'], ['right', 'A'], ['right', 'B'], ['right', 'A', 'B'], ['A'], ['left'],...
class plangym.videogames.nes.NesEnv(name, frameskip=5, episodic_life=False, autoreset=True, delay_setup=False, remove_time_limit=True, obs_type='rgb', render_mode=None, wrappers=None, **kwargs)[source]

Bases: plangym.videogames.env.VideogameEnv

Environment for working with the NES-py emulator.

Parameters
  • name (str) –

  • frameskip (int) –

  • episodic_life (bool) –

  • autoreset (bool) –

  • delay_setup (bool) –

  • remove_time_limit (bool) –

  • obs_type (str) –

  • render_mode (Optional[str]) –

  • wrappers (Iterable[plangym.core.wrap_callable]) –

property nes_env(self)

Access the underlying NESEnv.

Return type

NESEnv

get_image(self)[source]

Return a numpy array containing the rendered view of the environment.

Square matrices are interpreted as a greyscale image. Three-dimensional arrays are interpreted as RGB images with channels (Height, Width, RGB)

Return type

numpy.ndarray

get_ram(self)[source]

Return a copy of the emulator environment.

Return type

numpy.ndarray

get_state(self, state=None)[source]

Recover the internal state of the simulation.

A state must completely describe the Environment at a given moment.

Parameters

state (Optional[numpy.ndarray]) –

Return type

numpy.ndarray

set_state(self, state)[source]

Set the internal state of the simulation.

Parameters

state (numpy.ndarray) – Target state to be set in the environment.

Returns

None

Return type

None

close(self)[source]

Close the underlying gym.Env.

Return type

None

__del__(self)[source]

Tear down the environment.

class plangym.videogames.nes.MarioEnv(name, movement_type='simple', original_reward=False, **kwargs)[source]

Bases: NesEnv

Interface for using gym-super-mario-bros in plangym.

Parameters
  • name (str) –

  • movement_type (str) –

  • original_reward (bool) –

AVAILABLE_OBS_TYPES
MOVEMENTS
get_state(self, state=None)[source]

Recover the internal state of the simulation.

A state must completely describe the Environment at a given moment.

Parameters

state (Optional[numpy.ndarray]) –

Return type

numpy.ndarray

init_gym_env(self)[source]

Initialize the NESEnv` instance that the current class is wrapping.

Return type

gym.Env

_update_info(self, info)[source]
Parameters

info (Dict[str, Any]) –

Return type

Dict[str, Any]

_get_info(self)[source]
get_coords_obs(self, obs, info=None, **kwargs)[source]

Return the information contained in info as an observation if obs_type == “info”.

Parameters
  • obs (numpy.ndarray) –

  • info (Dict[str, Any]) –

Return type

numpy.ndarray

process_reward(self, reward, info, **kwargs)[source]

Return a custom reward based on the x, y coordinates and level mario is in.

Return type

float

process_terminal(self, terminal, info, **kwargs)[source]

Return True if terminal or mario is dying.

Return type

bool

process_info(self, info, **kwargs)[source]

Add additional data to the info dictionary.

Return type

Dict[str, Any]