concepts.benchmark.gridworld.minigrid.minigrid_v20220407.MiniGridEnvV20220407#

class MiniGridEnvV20220407[source]#

Bases: MiniGridEnv

Methods

agent_sees(x, y)

Check if a non-empty grid position is visible to the agent.

close()

Override close in your subclass to perform any necessary cleanup.

compute_done()

compute_obs()

debug_print()

gen_obs()

Generate the agent's view (partially observable, low-resolution encoding)

gen_obs_grid()

Generate the sub-grid observed by the agent.

get_obs_render(obs[, tile_size])

Render an agent observation for visualization

get_option(name[, default])

get_pds_state()

get_view_coords(i, j)

Translate and rotate absolute grid coordinates (i, j) into the agent's partially observable view (sub-grid).

get_view_exts()

Get the extents of the square set of tiles visible to the agent Note: the bottom extent indices are not included in the set

hash([size])

Compute a hash that uniquely identifies the current state of the environment.

in_view(x, y)

check if a grid position is visible to the agent

iter_objects()

Iterate over every object in the environment, including the current object held by the agent.

place_agent([top, size, rand_dir, max_tries])

Set the agent's starting point at an empty position in the grid

place_obj(obj[, top, size, reject_fn, max_tries])

Place an object at an empty position in the grid

put_obj(obj, i, j)

Put an object at a specific position in the grid

relative_coords(x, y)

Check if a grid position belongs to the agent's field of view, and returns the corresponding coordinates

render([mode, close, highlight, tile_size])

Render the whole-grid human view

reset()

Resets the environment to an initial state and returns the initial observation.

seed([seed])

deprecated:

function that sets the seed for the environment's random number generator(s).

set_encoding_executor(executor)

set_options(**kwargs)

step(action)

The agent performs an action.

step_drop()

step_forward()

step_inner(action)

step_lturn()

step_move_to(pose, dir[, traj])

step_pickup()

step_rturn()

step_toggle()

Attributes

SUPPORTED_ENCODING

SUPPORTED_TASKS

dir_vec

Get the direction vector for the agent, pointing in the direction of forward movement.

encoding_domain

front_pos

Get the position of the cell that is right in front of the agent

metadata

np_random

Returns the environment's internal _np_random that if not set will initialise with a random seed.

reward_range

right_vec

Get the vector pointing to the right of the agent.

spec

steps_remaining

unwrapped

Returns the base non-wrapped environment.

action_space

The action space for the environment.

observation_space

The observation space for the environment.

task

A short string describing the task.

encoding

A short string describing the encoding method.

encoding_executor

The PDSketchExecutor used for encoding the states.

goal_obj

The goal object.

goal_pose

The goal pose.

mission

The mission string.

class Actions#

Bases: IntEnum

An enumeration.

done = 6#
drop = 4#
forward = 2#
left = 0#
pickup = 3#
right = 1#
toggle = 5#
__init__(task='pickup', encoding='full')[source]#
Parameters:

encoding (str) –

__new__(**kwargs)#
agent_sees(x, y)#

Check if a non-empty grid position is visible to the agent.

close()#

Override close in your subclass to perform any necessary cleanup.

Environments will automatically close() themselves when garbage collected or when the program exits.

compute_done()[source]#
compute_obs()[source]#
debug_print()[source]#
gen_obs()#

Generate the agent’s view (partially observable, low-resolution encoding)

gen_obs_grid()#

Generate the sub-grid observed by the agent. This method also outputs a visibility mask telling us which grid cells the agent can actually see.

get_obs_render(obs, tile_size=TILE_PIXELS // 2)#

Render an agent observation for visualization

get_option(name, default=None)[source]#
get_pds_state()[source]#
Return type:

State

get_view_coords(i, j)#

Translate and rotate absolute grid coordinates (i, j) into the agent’s partially observable view (sub-grid). Note that the resulting coordinates may be negative or outside of the agent’s view size.

get_view_exts()#

Get the extents of the square set of tiles visible to the agent Note: the bottom extent indices are not included in the set

hash(size=16)#

Compute a hash that uniquely identifies the current state of the environment. :param size: Size of the hashing

in_view(x, y)#

check if a grid position is visible to the agent

iter_objects()#

Iterate over every object in the environment, including the current object held by the agent. This function ensures that the order of iteration is deterministic and fixed through time.

Return type:

Iterable[Tuple[int, int, WorldObj]]

place_agent(top=None, size=None, rand_dir=True, max_tries=math.inf)#

Set the agent’s starting point at an empty position in the grid

place_obj(obj, top=None, size=None, reject_fn=None, max_tries=math.inf)#

Place an object at an empty position in the grid

Parameters:
  • top – top-left position of the rectangle where to place

  • size – size of the rectangle where to place

  • reject_fn – function to filter out potential positions

put_obj(obj, i, j)#

Put an object at a specific position in the grid

relative_coords(x, y)#

Check if a grid position belongs to the agent’s field of view, and returns the corresponding coordinates

render(mode='human', close=False, highlight=True, tile_size=TILE_PIXELS)#

Render the whole-grid human view

reset()[source]#

Resets the environment to an initial state and returns the initial observation.

This method can reset the environment’s random number generator(s) if seed is an integer or if the environment has not yet initialized a random number generator. If the environment already has a random number generator and reset() is called with seed=None, the RNG should not be reset. Moreover, reset() should (in the typical use case) be called with an integer seed right after initialization and then never again.

Parameters:
  • seed (optional int) – The seed that is used to initialize the environment’s PRNG. If the environment does not already have a PRNG and seed=None (the default option) is passed, a seed will be chosen from some source of entropy (e.g. timestamp or /dev/urandom). However, if the environment already has a PRNG and seed=None is passed, the PRNG will not be reset. If you pass an integer, the PRNG will be reset even if it already exists. Usually, you want to pass an integer right after the environment has been initialized and then never again. Please refer to the minimal example above to see this paradigm in action.

  • return_info (bool) – If true, return additional information along with initial observation. This info should be analogous to the info returned in step()

  • options (optional dict) – Additional information to specify how the environment is reset (optional, depending on the specific environment)

Returns:

Observation of the initial state. This will be an element of observation_space

(typically a numpy array) and is analogous to the observation returned by step().

info (optional dictionary): This will only be returned if return_info=True is passed.

It contains auxiliary information complementing observation. This dictionary should be analogous to the info returned by step().

Return type:

observation (object)

seed(seed=1337)#
Deprecated:

function that sets the seed for the environment’s random number generator(s).

Use env.reset(seed=seed) as the new API for setting the seed of the environment.

Note

Some environments use multiple pseudorandom number generators. We want to capture all such seeds used in order to ensure that there aren’t accidental correlations between multiple generators.

Parameters:

seed (Optional int) – The seed value for the random number geneartor

Returns:

Returns the list of seeds used in this environment’s random

number generators. The first value in the list should be the “main” seed, or the value which a reproducer should pass to ‘seed’. Often, the main seed equals the provided ‘seed’, but this won’t be true if seed=None, for example.

Return type:

seeds (List[int])

set_encoding_executor(executor)[source]#
Parameters:

executor (PDSketchExecutor) –

set_options(**kwargs)[source]#
step(action)[source]#

The agent performs an action.

Parameters:

action (MiniGridEnvAction) –

step_drop()[source]#
step_forward()[source]#
step_inner(action)[source]#
step_lturn()[source]#
step_move_to(pose, dir, traj=None)[source]#
step_pickup()[source]#
step_rturn()[source]#
step_toggle()[source]#
SUPPORTED_ENCODING = ['full']#
SUPPORTED_TASKS = ['gotosingle', 'goto', 'goto2', 'pickup', 'open', 'generalization']#
action_space: Discrete#

The action space for the environment. It always has 6 discrete actions

agent_dir: int | None#
agent_pos: Tuple[int, int] | None#
carrying: WorldObj | None#
property dir_vec: ndarray#

Get the direction vector for the agent, pointing in the direction of forward movement.

encoding: str#

A short string describing the encoding method.

property encoding_domain: Domain#
encoding_executor: PDSketchExecutor | None#

The PDSketchExecutor used for encoding the states.

property front_pos: Tuple[int, int]#

Get the position of the cell that is right in front of the agent

goal_obj: WorldObj | None#

The goal object.

goal_pose: Tuple[int, int] | None#

The goal pose.

grid: Grid | None#
metadata = {'render.modes': ['human', 'rgb_array'], 'video.frames_per_second': 10}#
mission: str#

The mission string.

property np_random: RandomNumberGenerator#

Returns the environment’s internal _np_random that if not set will initialise with a random seed.

observation_space: Box#

The observation space for the environment. It is a Box of shape (agent_view_size, agent_view_size, 3)

reward_range = (-inf, inf)#
property right_vec: ndarray#

Get the vector pointing to the right of the agent.

spec = None#
property steps_remaining#
task: str#

A short string describing the task.

property unwrapped: Env#

Returns the base non-wrapped environment.

Returns:

The base non-wrapped gym.Env instance

Return type:

Env