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:
objectDefault 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: listof 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:
objectGame 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:
objectTask Manager
Holds the registered task types, and handles the tasks associated to an Agent.
-
handle(agent, tasks)¶ Execute agent’s most priority task.
Parameters: - agent (
jason_malmo.agent.Agent) – Agent instance. - tasks (
listofpyson.Literal) – List of pyson tasks.
- agent (
-
pythonize_tasks(agent, tasks)¶ Transform pyson tasks into Task objects.
Parameters: - agent (
jason_malmo.agent.Agent) – Agent instance. - tasks (
listofpyson.Literal) – List of pyson tasks.
Returns: List of Task instances.
Return type: listofTaskRaises: jason_malmo.exceptions.TaskNotRegistered– Task not registered.Register the task before running the game:
game.tasks.register(CustomTask) game.run()
- agent (
-
-
class
jason_malmo.tasks.Task(agent, priority, content)¶ Bases:
objectBase 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.TaskAddresses 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
-