src.plangym.videogames.montezuma

Contents

src.plangym.videogames.montezuma#

Implementation of the montezuma environment adapted for planning problems.

Attributes#

Classes#

MontezumaPosLevel

Contains the information of Panama Joe.

CustomMontezuma

MontezumaEnv environment that tracks the room and position of Panama Joe.

MontezumaEnv

Plangym implementation of the MontezumaEnv environment optimized for planning.

Module Contents#

class src.plangym.videogames.montezuma.MontezumaPosLevel(level, score, room, x, y)[source]#

Contains the information of Panama Joe.

__slots__ = ['level', 'room', 'score', 'tuple', 'x', 'y']#
level#
score#
room#
x#
y#
tuple = None#
set_tuple()[source]#

Set the tuple values from the other attributes.

__hash__()[source]#

Hash the current instance.

__eq__(other)[source]#

Compare equality between instances.

__getstate__()[source]#

Return the tuple containing the attributes.

__setstate__(d)[source]#

Set the class attributes using the provided tuple.

__repr__()[source]#

Print the attributes of the current instance.

src.plangym.videogames.montezuma.PYRAMID#
src.plangym.videogames.montezuma.OBJECT_PIXELS = [50, 40, 40, 40, 37, 37, 42]#
src.plangym.videogames.montezuma.KNOWN_XY: list[None | tuple[int, int]]#
src.plangym.videogames.montezuma.KEY_BITS#
class src.plangym.videogames.montezuma.CustomMontezuma(check_death=True, obs_type='rgb', score_objects=False, objects_from_pixels=False, objects_remember_rooms=False, only_keys=False, death_room_8=True, render_mode='rgb_array', x_repeat=1)[source]#

MontezumaEnv environment that tracks the room and position of Panama Joe.

Parameters:
  • check_death (bool)

  • obs_type (str)

  • score_objects (bool)

  • objects_from_pixels (bool)

  • objects_remember_rooms (bool)

  • only_keys (bool)

  • death_room_8 (bool)

  • render_mode (str)

  • x_repeat (int)

render_mode#
score_objects#
check_death#
objects_from_pixels#
objects_remember_rooms#
only_keys#
coords_obs#
_x_repeat#
_death_room_8#
env#
ram = None#
cur_steps = 0#
cur_score = 0#
rooms#
cur_lives = 5#
pos#
static get_room_xy(room)[source]#

Get the tuple that encodes the provided room.

Parameters:

room (int)

Return type:

None | tuple[int, int]

__getattr__(e)[source]#

Forward to gym environment.

get_ram()[source]#

Return the current RAM.

reset(seed=None, return_info=False)[source]#

Reset the environment.

Parameters:

return_info (bool)

Return type:

tuple[numpy.ndarray, dict[str, Any]]

step(action)[source]#

Step the environment.

Return type:

tuple[numpy.ndarray, SupportsFloat, bool, bool, dict[str, Any]] | tuple[Any, SupportsFloat, bool, bool, dict[str, Any]]

pos_from_obs(face_pixels, obs)[source]#

Extract the information of the position of Panama Joe.

Return type:

MontezumaPosLevel

get_objects_from_pixels(obs, room, old_objects)[source]#

Extract the position of the objects in the provided observation.

get_coords()[source]#

Return an observation containing the position and the flattened screen of the game.

Return type:

numpy.ndarray

state_to_numpy()[source]#

Return a numpy array containing the current state of the game.

Return type:

numpy.ndarray

get_restore()[source]#

Return a tuple containing all the information needed to clone the state of the env.

Return type:

tuple

restore(data)[source]#

Restore the state of the env from the provided tuple.

Return type:

None

is_transition_screen(obs)[source]#

Return True if the current observation corresponds to a transition between rooms.

Return type:

bool

get_face_pixels(obs)[source]#

Return the pixels containing the face of Paname Joe.

Return type:

set

is_pixel_death(obs, face_pixels)[source]#

Return a death signal extracted from the observation of the environment.

is_ram_death()[source]#

Return a death signal extracted from the ram of the environment.

Return type:

bool

render(mode='human', **kwargs)[source]#

Render the environment.

Return type:

None | numpy.ndarray

class src.plangym.videogames.montezuma.MontezumaEnv(name='PlanMontezuma-v0', frameskip=1, episodic_life=False, autoreset=True, delay_setup=False, remove_time_limit=True, obs_type='rgb', mode=0, difficulty=0, repeat_action_probability=0.0, full_action_space=False, render_mode=None, possible_to_win=True, wrappers=None, array_state=True, clone_seeds=True, **kwargs)[source]#

Bases: plangym.videogames.atari.AtariEnv

Plangym implementation of the MontezumaEnv environment optimized for planning.

Parameters:
  • frameskip (int)

  • episodic_life (bool)

  • autoreset (bool)

  • delay_setup (bool)

  • remove_time_limit (bool)

  • obs_type (str)

  • mode (int)

  • difficulty (int)

  • repeat_action_probability (float)

  • full_action_space (bool)

  • render_mode (str | None)

  • possible_to_win (bool)

  • wrappers (Iterable[plangym.core.wrap_callable] | None)

  • array_state (bool)

  • clone_seeds (bool)

AVAILABLE_OBS_TYPES#
_get_default_obs_type(name, obs_type)[source]#

Return the observation type of the internal Atari gym environment.

Return type:

str

init_gym_env()[source]#

Initialize the gum.Env` instance that the current clas is wrapping.

Return type:

CustomMontezuma

get_state()[source]#

Recover the internal state of the simulation.

If clone seed is False the environment will be stochastic. Cloning the full state ensures the environment is deterministic.

Return type:

numpy.ndarray

set_state(state)[source]#

Set the internal state of the simulation.

Parameters:

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

Returns:

None