jason_malmo package

Submodules

jason_malmo.actions module

Custom pyson actions.

This module registers all the base custom actions that can be called from Jason.

jason_malmo.actions.actions

pyson.Actions – Pyson custom actions.

jason_malmo.agent module

class jason_malmo.agent.Agent(env, name, beliefs=None, rules=None, plans=None)

Bases: object

Default Agent class.

malmo_agent

MalmoPython.AgentHost – Malmo Agent

send_command(command)

Send command to the malmo’s agent.

Parameters:command (str) –

Command to be executed.

Example:

agent.send_command('move 1')
get_position()

Return the agent’s current position.

Returns:Agent’s current position.
Return type:list of int
get_observations()

Return the agent’s last world observation.

Returns:Last observation.
Return type:dict
get_observations_value(key)

Return a specified value from the agent’s last world observation.

Parameters:key (str) – Key of the value to return.
Returns:Value.
Return type:object

jason_malmo.exceptions module

exception jason_malmo.exceptions.NoAgentsException

Bases: Exception

exception jason_malmo.exceptions.TaskNotRegistered

Bases: Exception

jason_malmo.game module

class jason_malmo.game.Game(name)

Bases: object

Game main class.

This class may be instantiated to run a Malmo Mission using Jason Agents.

name

str – Match’s name.

world

str – World’s generator string. Flat world generator.

tasks

jason_malmo.tasks.TaskManager – Tasks Manager.

register(agent_file)

Register an Agent to the game.

Parameters:agent_file (str) – Path to the .asl file (Jason text file).
run()

Runs the game with the registered agents

Raises:

jason_malmo.exceptions.NoAgentsException – There are not registered agents in the game.

Register an agent before running the game:

game.register('/path/to/file.asl')
game.run()

jason_malmo.math_utils module

jason_malmo.math_utils.calc_turn_value(us, them, current_yaw)

Calc turn speed required to steer ‘us’ towards ‘them’.

jason_malmo.math_utils.get_path_value(agent, position)

jason_malmo.tasks module

class jason_malmo.tasks.TaskManager

Bases: object

Task Manager

Holds the registered task types, and handles the tasks associated to an Agent.

register(task)

Register task type.

Parameters:taskTask to register.
handle(agent, tasks)

Execute agent’s most priority task.

Parameters:
pythonize_tasks(agent, tasks)

Transform pyson tasks into Task objects.

Parameters:
Returns:

List of Task instances.

Return type:

list of Task

Raises:

jason_malmo.exceptions.TaskNotRegistered – Task not registered.

Register the task before running the game:

game.tasks.register(CustomTask)
game.run()
class jason_malmo.tasks.Task(agent, priority, content)

Bases: object

Base Task class to be extended by custom classes.

agent

jason_malmo.agent.Agent – Target agent.

priority

int – Task priority.

content

object – Task arguments.

identifier = None

str – Task identifier.

run()

Run the task

Returns:Should return True if the task has finished, False if not.
Return type:bool
static py_content(content)

Transform the pyson content to python instances. Should be overridden by the subclasses.

Parameters:content (pyson.Literal) – Pyson instance content.
Returns:Python object instance.
Return type:object
classmethod get_subclasses()
class jason_malmo.tasks.GoToPosition(agent, priority, content)

Bases: jason_malmo.tasks.Task

Addresses the agent to a specified position setting it’s move and turn values.

identifier = 'GO_TO_POSITION'
run()

Set the next move and turn to address to the destination.

Returns:True if the task has finished, False if not.
Return type:bool

Module contents