Project Malmo  0.14.0
Public Types | Public Member Functions | Friends | List of all members
malmo::AgentHost Class Reference

An agent host mediates between the researcher's code (the agent) and the Mod (the target environment). More...

#include <AgentHost.h>

Inheritance diagram for malmo::AgentHost:
malmo::ArgumentParser

Public Types

enum  VideoPolicy { LATEST_FRAME_ONLY, KEEP_ALL_FRAMES }
 Specifies what to do when there are more video frames being received than can be processed. More...
 
enum  RewardsPolicy { LATEST_REWARD_ONLY, SUM_REWARDS, KEEP_ALL_REWARDS }
 Specifies what to do when there are more rewards being received than can be processed. More...
 
enum  ObservationsPolicy { LATEST_OBSERVATION_ONLY, KEEP_ALL_OBSERVATIONS }
 Specifies what to do when there are more observations being received than can be processed. More...
 

Public Member Functions

 AgentHost ()
 Creates an agent host with default settings.
 
 ~AgentHost ()
 Destructor.
 
void startMission (const MissionSpec &mission, const ClientPool &client_pool, const MissionRecordSpec &mission_record, int role, std::string unique_experiment_id)
 Starts a mission running. More...
 
void startMission (const MissionSpec &mission, const MissionRecordSpec &mission_record)
 Starts a mission running, in the simple case where there is only one agent running on the local machine. More...
 
WorldState peekWorldState () const
 Gets the latest world state received from the game. More...
 
WorldState getWorldState ()
 Gets the latest world state received from the game and resets it to empty. More...
 
void setVideoPolicy (VideoPolicy videoPolicy)
 Specifies how you want to deal with multiple video frames. More...
 
void setRewardsPolicy (RewardsPolicy rewardsPolicy)
 Specifies how you want to deal with multiple rewards. More...
 
void setObservationsPolicy (ObservationsPolicy observationsPolicy)
 Specifies how you want to deal with multiple observations. More...
 
void sendCommand (std::string command)
 Sends a command to the game client. More...
 
boost::shared_ptr< MissionInitSpec > getMissionInit ()
 Returns a pointer to the current MissionInitSpec, to allow retrieval of the ports being used. More...
 
const boost::shared_ptr< MissionInitSpec > getMissionInit () const
 
void parseArgs (int argc, const char **argv)
 Parses a list of strings given in the C style. Throws std::exception if parsing fails. More...
 
void parse (const std::vector< std::string > &args)
 Parses a list of strings. Throws std::exception if parsing fails. More...
 
void addOptionalIntArgument (const std::string &name, const std::string &description, int defaultValue)
 Specify an integer argument that can be given on the command line. More...
 
void addOptionalFloatArgument (const std::string &name, const std::string &description, double defaultValue)
 Specify a floating-point argument that can be given on the command line. More...
 
void addOptionalStringArgument (const std::string &name, const std::string &description, const std::string &defaultValue)
 Specify a string argument that can be given on the command line. More...
 
void addOptionalFlag (const std::string &name, const std::string &description)
 Specify a boolean flag that can be given on the command line. More...
 
std::string getUsage () const
 Gets a string that describes the current set of options we expect. More...
 
bool receivedArgument (const std::string &name) const
 Gets whether a named argument was parsed on the command-line arguments. More...
 
int getIntArgument (const std::string &name) const
 Retrieves the value of a named integer argument. More...
 
double getFloatArgument (const std::string &name) const
 Retrieves the value of a named floating-point argument. More...
 
std::string getStringArgument (const std::string &name) const
 Retrieves the value of a named string argument. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const AgentHost &ah)
 

Detailed Description

An agent host mediates between the researcher's code (the agent) and the Mod (the target environment).

Member Enumeration Documentation

Specifies what to do when there are more observations being received than can be processed.

Enumerator
LATEST_OBSERVATION_ONLY 

Discard all but the most recent observation. This is the default.

KEEP_ALL_OBSERVATIONS 

Attempt to store all the observations.

Specifies what to do when there are more rewards being received than can be processed.

Enumerator
LATEST_REWARD_ONLY 

Discard all but the most recent reward.

SUM_REWARDS 

Add up all the rewards received. This is the default.

KEEP_ALL_REWARDS 

Attempt to store all the rewards.

Specifies what to do when there are more video frames being received than can be processed.

Enumerator
LATEST_FRAME_ONLY 

Discard all but the most recent frame. This is the default.

KEEP_ALL_FRAMES 

Attempt to store all of the frames.

Member Function Documentation

void malmo::ArgumentParser::addOptionalFlag ( const std::string &  name,
const std::string &  description 
)
inherited

Specify a boolean flag that can be given on the command line.

Parameters
nameThe name of the flag. To be given as "--name"
descriptionThe explanation of the flag that can be printed out.
void malmo::ArgumentParser::addOptionalFloatArgument ( const std::string &  name,
const std::string &  description,
double  defaultValue 
)
inherited

Specify a floating-point argument that can be given on the command line.

Parameters
nameThe name of the argument. To be given as "--name <value>"
descriptionThe explanation of the argument that can be printed out.
defaultValueThe value that this argument should have if not given on the command line.
void malmo::ArgumentParser::addOptionalIntArgument ( const std::string &  name,
const std::string &  description,
int  defaultValue 
)
inherited

Specify an integer argument that can be given on the command line.

Parameters
nameThe name of the argument. To be given as "--name <value>"
descriptionThe explanation of the argument that can be printed out.
defaultValueThe value that this argument should have if not given on the command line.
void malmo::ArgumentParser::addOptionalStringArgument ( const std::string &  name,
const std::string &  description,
const std::string &  defaultValue 
)
inherited

Specify a string argument that can be given on the command line.

Parameters
nameThe name of the argument. To be given as "--name <value>"
descriptionThe explanation of the argument that can be printed out.
defaultValueThe value that this argument should have if not given on the command line.
double malmo::ArgumentParser::getFloatArgument ( const std::string &  name) const
inherited

Retrieves the value of a named floating-point argument.

Parameters
nameThe name of the argument.
Returns
The value of the named argument.
int malmo::ArgumentParser::getIntArgument ( const std::string &  name) const
inherited

Retrieves the value of a named integer argument.

Parameters
nameThe name of the argument.
Returns
The value of the named argument.
boost::shared_ptr<MissionInitSpec> malmo::AgentHost::getMissionInit ( )

Returns a pointer to the current MissionInitSpec, to allow retrieval of the ports being used.

(If port 0 is requested this means bind to any port that is available.)

Returns
A shared pointer to the MissionInitSpec.
std::string malmo::ArgumentParser::getStringArgument ( const std::string &  name) const
inherited

Retrieves the value of a named string argument.

Parameters
nameThe name of the argument.
Returns
The value of the named argument.
std::string malmo::ArgumentParser::getUsage ( ) const
inherited

Gets a string that describes the current set of options we expect.

Returns
The usage string, for displaying.
WorldState malmo::AgentHost::getWorldState ( )

Gets the latest world state received from the game and resets it to empty.

Returns
The world state.
void malmo::ArgumentParser::parse ( const std::vector< std::string > &  args)
inherited

Parses a list of strings. Throws std::exception if parsing fails.

In C++: takes a std::vector<std::string>. In Python: takes a list of strings. In Lua: takes a table of strings.

Parameters
argsThe arguments to parse.
void malmo::ArgumentParser::parseArgs ( int  argc,
const char **  argv 
)
inherited

Parses a list of strings given in the C style. Throws std::exception if parsing fails.

Available in C++ only. In other languages use the parse function instead.

Parameters
argcThe number of arguments.
argvThe arguments to parse.
See also
parse()
WorldState malmo::AgentHost::peekWorldState ( ) const

Gets the latest world state received from the game.

Returns
The world state.
bool malmo::ArgumentParser::receivedArgument ( const std::string &  name) const
inherited

Gets whether a named argument was parsed on the command-line arguments.

Parameters
nameThe name of the argument.
Returns
True if the named argument was received.
void malmo::AgentHost::sendCommand ( std::string  command)

Sends a command to the game client.

See the mission handlers documentation for the permitted commands for your chosen command handler.

Parameters
commandThe command to send as a string. e.g. "move 1"
void malmo::AgentHost::setObservationsPolicy ( ObservationsPolicy  observationsPolicy)

Specifies how you want to deal with multiple observations.

Parameters
observationsPolicyHow you want to deal with multiple observations coming in asynchronously.
void malmo::AgentHost::setRewardsPolicy ( RewardsPolicy  rewardsPolicy)

Specifies how you want to deal with multiple rewards.

Parameters
rewardsPolicyHow you want to deal with multiple rewards coming in asynchronously.
void malmo::AgentHost::setVideoPolicy ( VideoPolicy  videoPolicy)

Specifies how you want to deal with multiple video frames.

Parameters
videoPolicyHow you want to deal with multiple video frames coming in asynchronously.
void malmo::AgentHost::startMission ( const MissionSpec mission,
const ClientPool client_pool,
const MissionRecordSpec mission_record,
int  role,
std::string  unique_experiment_id 
)

Starts a mission running.

Throws an exception if something goes wrong.

Parameters
missionThe mission specification.
client_poolA list of the Minecraft instances that can be used.
mission_recordThe specification of the mission recording to make.
roleIndex of the agent that this agent host is to manage. Zero-based index. Use zero if there is only one agent in this mission.
unique_experiment_idAn arbitrary identifier that is used to disambiguate our mission from other runs.
void malmo::AgentHost::startMission ( const MissionSpec mission,
const MissionRecordSpec mission_record 
)

Starts a mission running, in the simple case where there is only one agent running on the local machine.

Throws an exception if something goes wrong.

Parameters
missionThe mission specification.
mission_recordThe specification of the mission recording to make.

The documentation for this class was generated from the following file: