Project Malmo
0.21.0
|
An agent host mediates between the researcher's code (the agent) and the Mod (the target environment). More...
#include <AgentHost.h>
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... | |
std::string | getRecordingTemporaryDirectory () const |
Gets the temporary directory being used for the mission record, if recording is taking place. More... | |
void | setDebugOutput (bool debug) |
Switches on/off debug print statements. (Currently just client-pool / agenthost connection messages.) | |
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... | |
void | sendCommand (std::string command, std::string key) |
Sends a turn-based 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) |
An agent host mediates between the researcher's code (the agent) and the Mod (the target environment).
|
inherited |
Specify a boolean flag that can be given on the command line.
name | The name of the flag. To be given as "--name" |
description | The explanation of the flag that can be printed out. |
|
inherited |
Specify a floating-point argument that can be given on the command line.
name | The name of the argument. To be given as "--name <value>" |
description | The explanation of the argument that can be printed out. |
defaultValue | The value that this argument should have if not given on the command line. |
|
inherited |
Specify an integer argument that can be given on the command line.
name | The name of the argument. To be given as "--name <value>" |
description | The explanation of the argument that can be printed out. |
defaultValue | The value that this argument should have if not given on the command line. |
|
inherited |
Specify a string argument that can be given on the command line.
name | The name of the argument. To be given as "--name <value>" |
description | The explanation of the argument that can be printed out. |
defaultValue | The value that this argument should have if not given on the command line. |
|
inherited |
Retrieves the value of a named floating-point argument.
name | The name of the argument. |
|
inherited |
Retrieves the value of a named integer argument.
name | The name of the 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.)
std::string malmo::AgentHost::getRecordingTemporaryDirectory | ( | ) | const |
Gets the temporary directory being used for the mission record, if recording is taking place.
|
inherited |
Retrieves the value of a named string argument.
name | The name of the argument. |
|
inherited |
Gets a string that describes the current set of options we expect.
WorldState malmo::AgentHost::getWorldState | ( | ) |
Gets the latest world state received from the game and resets it to empty.
|
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.
args | The arguments to parse. |
|
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.
argc | The number of arguments. |
argv | The arguments to parse. |
WorldState malmo::AgentHost::peekWorldState | ( | ) | const |
Gets the latest world state received from the game.
|
inherited |
Gets whether a named argument was parsed on the command-line arguments.
name | The name of the argument. |
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.
command | The command to send as a string. e.g. "move 1" |
void malmo::AgentHost::sendCommand | ( | std::string | command, |
std::string | key | ||
) |
Sends a turn-based command to the game client.
See the mission handlers documentation for the permitted commands for your chosen command handler.
command | The command to send as a string. e.g. "move 1" |
key | The command-key (provided via observations) which must match in order for the command to be processed. |
void malmo::AgentHost::setObservationsPolicy | ( | ObservationsPolicy | observationsPolicy | ) |
Specifies how you want to deal with multiple observations.
observationsPolicy | How 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.
rewardsPolicy | How 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.
videoPolicy | How 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.
mission | The mission specification. |
client_pool | A list of the Minecraft instances that can be used. |
mission_record | The specification of the mission recording to make. |
role | Index 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_id | An 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.
mission | The mission specification. |
mission_record | The specification of the mission recording to make. |