Shortcuts

minedojo.sim package

minedojo.sim.sim module

class minedojo.sim.sim.MineDojoSim(*, initial_inventory=None, start_position=None, start_health=None, start_food=None, start_time=None, initial_weather=None, spawn_in_village=False, drawing_str=None, break_speed_multiplier=1.0, allow_time_passage=True, allow_mob_spawn=True, generate_world_type='default', regenerate_world_after_reset=False, world_seed=None, world_file_path=None, flat_world_seed_string=None, specified_biome=None, image_size, use_voxel=False, voxel_size=None, use_lidar=False, lidar_rays=None, use_depth=False, event_level_control=True, seed=None, sim_name='MineDojoSim', raise_error_on_invalid_cmds=False)[source]

Bases: gym.core.Env

An environment wrapper for MineDojo simulation.

Parameters
  • allow_mob_spawn (bool) – If True, allow mobs (animals and hostiles) to spawn. Default: True.

  • allow_time_passage (bool) – Time flows if True. Default: True.

  • break_speed_multiplier (float) – Controls the speed of breaking blocks. A value larger than 1.0 accelerates the breaking. Default: 1.0.

  • drawing_str (Optional[str]) – Draws shapes (e.g. spheres, cuboids) in the minecraft world. Default: None.

  • event_level_control (bool) – If True, the agent is able to perform high-level controls including place and equip. If False, then is keyboard-mouse level control. Default: True.

  • flat_world_seed_string (Optional[str]) – A string that specifies how we want the world layers to be created if generate_world_type is “flat”. One can use the tool to generate. Default: None.

  • generate_world_type (Literal[‘default’, ‘from_file’, ‘flat’, ‘specified_biome’]) – A string that specifies the type of the minecraft world. One of "default", "flat", "from_file", "specified_biome". Default: "default".

  • image_size (Union[int, Tuple[int, int]]) – The size of image observations.

  • initial_inventory (Optional[List[InventoryItem]]) – If not None, specifies initial items in the agent’s inventory. Use class InventoryItem to specify items. Default: None.

  • initial_weather (Optional[Literal[‘normal’, ‘clear’, ‘rain’, ‘thunder’]]) – If not None, specifies the initial weather. Can be one of "clear", "normal", "rain", "thunder". Default: None.

  • lidar_rays (Optional[List[Tuple[float, float, float]]]) – Defines the directions and maximum distances of the lidar rays if use_lidar is True. If supplied, should be a list of tuple(pitch, yaw, distance). Pitch and yaw are in radians and relative to agent looking vector. Default: None.

  • raise_error_on_invalid_cmds (bool) – If True, the cmd executor will raise error when a command is invalid. If False, the executor will just skip instead. Default: False.

  • regenerate_world_after_reset (bool) – If True, the minecraft world will be re-generated when resetting. Default: False.

  • seed (Optional[int]) – The seed for an instance’s internal random number generator. Default: None.

  • sim_name (str) – Name of a simulation instance. Default: "MineDojoSim".

  • spawn_in_village (bool) – If True, the agent will spawn in a village. Default: False.

  • specified_biome (Union[int, str, None]) – If not None, specifies the biome of the minecraft world by a string or an integer. Default: None.

  • start_food (Optional[int]) – If not None, specifies initial food of the agent. Default: None.

  • start_health (Optional[float]) – If not None, specifies initial health of the agent. Default: None.

  • start_position (Optional[Dict[str, Union[float, int]]]) – If not None, specifies the agent’s initial location and orientation. If provided, should be a dict with keys x, y, z, yaw, pitch. yaw and pitch are in degrees. Default: None.

  • start_time (Optional[int]) – If not None, specifies the time when the agent spawns. If supplied, should be an int between 0 and 24000. See here for more information. Default: None.

  • use_depth (bool) – If True, includes depth map in observations. Default: False.

  • use_lidar (bool) – If True, includes lidar in observations. Default: False.

  • use_voxel (bool) – If True, includes voxel in observations. Default: False.

  • voxel_size (Optional[Dict[str, int]]) – Defines the voxel’s range in each axis if use_voxel is True. If supplied, should be a dict with keys xmin, xmax, ymin, ymax, zmin, zmax. Each value specifies the voxel size relative to the agent. Default: None.

  • world_file_path (Optional[str]) – The path to the world file if generate_world_type is "from_file". Default: None.

  • world_seed (Union[int, str, None]) –

    Seed for deterministic world generation if generate_world_type is "default" or "specified_biome". See here for more details. Default: None.

clear_inventory(action=None)[source]

Remove all items in the agent’s inventory.

Parameters

action (Optional[dict]) – An action that will be simultaneously executed

Returns

A tuple (obs, reward, done, info) - dict - Agent’s observation of the current environment. - float - Amount of reward returned after previous action. - bool - Whether the episode has ended. - dict - Contains auxiliary diagnostic information (helpful for debugging, and sometimes learning).

close()[source]

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

execute_cmd(cmd, action=None)[source]

Execute a given string command.

Parameters
  • cmd (str) – The string command accepted by the Minecraft client.

  • action (Optional[dict]) – An action that will be simultaneously executed with the command.

Returns

A tuple (obs, reward, done, info) - dict - Agent’s observation of the current environment. - float - Amount of reward returned after previous action. - bool - Whether the episode has ended. - dict - Contains auxiliary diagnostic information (helpful for debugging, and sometimes learning).

kill_agent(action=None)[source]

Kill the agent.

Parameters

action (Optional[dict]) – An action that will be simultaneously executed

Returns

A tuple (obs, reward, done, info) - dict - Agent’s observation of the current environment. - float - Amount of reward returned after previous action. - bool - Whether the episode has ended. - dict - Contains auxiliary diagnostic information (helpful for debugging, and sometimes learning).

random_teleport(max_range, action=None)[source]

Teleport the agent randomly.

Parameters
  • max_range (int) – The maximum distance on each horizontal axis from the center of the area to spread targets (thus, the area is square, not circular)

  • action (Optional[dict]) – An action that will be simultaneously executed

Returns

A tuple (obs, reward, done, info) - dict - Agent’s observation of the current environment. - float - Amount of reward returned after previous action. - bool - Whether the episode has ended. - dict - Contains auxiliary diagnostic information (helpful for debugging, and sometimes learning).

render(mode='human')[source]

Renders the environment.

Parameters

mode (str) – The mode to render with.

reset()[source]

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

Returns

Agent’s initial observation.

seed(seed=None)[source]

Sets the seed for this env’s random number generator.

Parameters

seed (Optional[int]) – The seed for the number generator

set_block(blocks, rel_positions, action=None)[source]

Set blocks in the world.

Parameters
  • blocks (Union[str, List[str]]) – The names of the blocks to set

  • rel_positions (Union[ndarray, list]) – The blocks’ positions relative to the agent

  • action (Optional[dict]) – An action that will be simultaneously executed with the setting

Returns

A tuple (obs, reward, done, info) - dict - Agent’s observation of the current environment. - float - Amount of reward returned after previous action. - bool - Whether the episode has ended. - dict - Contains auxiliary diagnostic information (helpful for debugging, and sometimes learning).

set_inventory(inventory_list, action=None)[source]

Set items to the agent’s inventory.

Parameters
  • inventory_list (List[InventoryItem]) – List of InventoryItem to change the inventory status

  • action (Optional[dict]) – An action that will be simultaneously executed

Returns

A tuple (obs, reward, done, info) - dict - Agent’s observation of the current environment. - float - Amount of reward returned after previous action. - bool - Whether the episode has ended. - dict - Contains auxiliary diagnostic information (helpful for debugging, and sometimes learning).

set_time(time, action=None)[source]

Set the world with the given time.

Parameters
  • time (int) – The target time

  • action (Optional[dict]) – An action that will be simultaneously executed

Returns

A tuple (obs, reward, done, info) - dict - Agent’s observation of the current environment. - float - Amount of reward returned after previous action. - bool - Whether the episode has ended. - dict - Contains auxiliary diagnostic information (helpful for debugging, and sometimes learning).

set_weather(weather, action=None)[source]

Set the world with the given weather.

Parameters
  • weather (str) – The target weather

  • action (Optional[dict]) – An action that will be simultaneously executed

Returns

A tuple (obs, reward, done, info) - dict - Agent’s observation of the current environment. - float - Amount of reward returned after previous action. - bool - Whether the episode has ended. - dict - Contains auxiliary diagnostic information (helpful for debugging, and sometimes learning).

spawn_mobs(mobs, rel_positions, action=None)[source]

Spawn mobs in the world.

Parameters
  • mobs (Union[str, List[str]]) – The names of the mobs to spawn

  • rel_positions (Union[ndarray, list]) – The mobs’ positions relative to the agent

  • action (Optional[dict]) – An action that will be simultaneously executed with the spawning

Returns

A tuple (obs, reward, done, info) - dict - Agent’s observation of the current environment. - float - Amount of reward returned after previous action. - bool - Whether the episode has ended. - dict - Contains auxiliary diagnostic information (helpful for debugging, and sometimes learning).

step(action)[source]

Run one timestep of the environment’s dynamics. Accepts an action and returns next_obs, reward, done, info.

Parameters

action (dict) – The action of the agent in current step.

Returns

A tuple (obs, reward, done, info) - dict - Agent’s next observation. - float - Amount of reward returned after executing previous action. - bool - Whether the episode has ended. - dict - Contains auxiliary diagnostic information (helpful for debugging, and sometimes learning).

teleport_agent(x, y, z, yaw, pitch, action=None)[source]

Teleport the agent to a given position.

Parameters
  • x – x coordinate of the destination

  • y – y coordinate of the destination

  • z – z coordinate of the destination

  • yaw – yaw of the targeted orientation

  • pitch – pitch of the targeted orientation

  • action (Optional[dict]) – An action that will be simultaneously executed with the teleporting

Returns

A tuple (obs, reward, done, info) - dict - Agent’s observation of the current environment. - float - Amount of reward returned after previous action. - bool - Whether the episode has ended. - dict - Contains auxiliary diagnostic information (helpful for debugging, and sometimes learning).

property action_space
property is_terminated
property new_seed
property observation_space
property prev_action
property prev_info
property prev_obs