minerl.env

The minerl.env package provides an optimized python software layer over MineRLEnv, a fork of the popular Minecraft simulator Malmo which enables synchronous, stable, and fast samples from the Minecraft environment.

MineRLEnv

InstanceManager

class minerl.env.malmo.CustomAsyncRemoteMethod(proxy, name, max_retries)

Bases: Pyro4.core._AsyncRemoteMethod

class minerl.env.malmo.InstanceManager

Bases: object

The Minecraft instance manager library. The instance manager can be used to allocate and safely terminate existing Malmo instances for training agents.

Note: This object never needs to be explicitly invoked by the user of the MineRL library as the creation of one of the several MineRL environments will automatically query the InstanceManager to create a new instance.

Note: In future versions of MineRL the instance manager will become its own daemon process which provides instance allocation capability using remote procedure calls.

DEFAULT_IP = 'localhost'
KEEP_ALIVE_PYRO_FREQUENCY = 5
MAXINSTANCES = None
MINECRAFT_DIR = '/Users/cody/.pyenv/versions/3.7.0/envs/minerl_dev/lib/python3.7/site-packages/minerl/env/../Malmo/Minecraft'
REMOTE = False
SCHEMAS_DIR = '/Users/cody/.pyenv/versions/3.7.0/envs/minerl_dev/lib/python3.7/site-packages/minerl/env/../Malmo/Schemas'
STATUS_DIR = '/Users/cody/.pyenv/versions/minerl_dev/bin/performance'
X11_DIR = '/tmp/.X11-unix'
classmethod add_existing_instance(port)
classmethod add_keep_alive(_pid, _callback)
classmethod allocate_pool(num)
classmethod configure_malmo_base_port(malmo_base_port)

Configure the lowest or base port for Malmo

classmethod get_instance(pid, instance_id=None)

Gets an instance from the instance manager. This method is a context manager and therefore when the context is entered the method yields a InstanceManager.Instance object which contains the allocated port and host for the given instance that was created.

Yields

The allocated InstanceManager.Instance object.

Raises
  • RuntimeError – No available instances or the maximum number of allocated instances reached.

  • RuntimeError – No available instances and automatic allocation of instances is off.

headless = False
classmethod is_remote()
managed = True
ninstances = 0
classmethod set_valid_jdwp_port_for_instance(instance)None

Find a valid port for JDWP (Java Debug Wire Protocol), so that the instance can be debugged with an attached debugger. The port is set in the instance, so that other instances can check whether the port is reserved. :param instance: Instance to find and port for, and where we will set the jdwp port.

classmethod shutdown()
class minerl.env.malmo.MinecraftInstance(port=None, existing=False, status_dir=None, seed=None, instance_id=None)

Bases: object

A subprocess wrapper which maintains a reference to a minecraft subprocess and also allows for stable closing and launching of such subprocesses across different platforms.

The Minecraft instance class works by launching two subprocesses: the Malmo subprocess, and a watcher subprocess with access to the process IDs of both the parent process and the Malmo subprocess. If the parent process dies, it will kill the subprocess, and then itself.

This scheme has a single failure point of the process dying before the watcher process is launched.

MAX_PIPE_LENGTH = 500
property actor_name
property client_socket
client_socket_close()
client_socket_recv_message()
client_socket_send_message(msg)
client_socket_shutdown(param)
close()

Closes the object.

create_multiagent_instance_socket(socktime)
get_output()
property had_to_clean
has_client_socket()
property host
property jdwp_port

JDWP (Java Debug Wire Protocol) port, if any, so the instance can be debugged with an attached debugger.

kill()

Kills the process (if it has been launched.)

launch(daemonize=False, replaceable=True)
property port
release_lock()
property status_dir
class minerl.env.malmo.SeedType(value)

Bases: enum.IntEnum

The seed type for an instance manager.

Values:

0 - NONE: No seeding whatsoever. 1 - CONSTANT: All envrionments have the same seed (the one specified

to the instance manager) (or alist of seeds , separated)

2 - GENERATED: All environments have different seeds generated from a single

random generator with the seed specified to the InstanceManager.

3 - SPECIFIED: Each instance is given a list of seeds. Specify this like

1,2,3,4;848,432,643;888,888,888 Each instance’s seed list is separated by ; and each seed is separated by ,

CONSTANT = 1
GENERATED = 2
NONE = 0
SPECIFIED = 3
classmethod get_index(type)
minerl.env.malmo.launch_instance_manager()

Defines the entry point for the remote procedure call server.

minerl.env.malmo.launch_queue_logger_thread(output_producer, should_end)