TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
|
(Unit, Position, Command) tuple. More...
#include <upc.h>
Public Types | |
using | Empty = char |
An empty default item for the variants defined below. More... | |
using | UnitMap = std::unordered_map< Unit *, float > |
using | CommandMap = std::unordered_map< Command, float > |
using | BuildTypeMap = std::unordered_map< BuildType const *, float > |
using | SetCreatePriorityState = std::tuple< UpcId, float > |
using | UnitT = UnitMap |
A typedef for the unit distribution. More... | |
using | PositionT = mapbox::util::variant< Empty, Position, Area *, UnitMap, torch::Tensor > |
A typedef for the position distribution. More... | |
using | CommandT = CommandMap |
A typedef for the command distribution. More... | |
using | StateT = mapbox::util::variant< Empty, BuildTypeMap, std::string, Position, SetCreatePriorityState, torch::Tensor > |
A typedef for additional structured information ("state"). More... | |
Public Member Functions | |
std::pair< Position, float > | positionArgMax () const |
Returns argmax and probability of position distribution. More... | |
std::pair< Unit *, float > | positionUArgMax () const |
Returns argmax and probability of position distribution over units. More... | |
float | positionProb (int x, int y) const |
Returns the probability of a given position. More... | |
float | commandProb (Command c) const |
Returns the probability of a given command. More... | |
torch::Tensor | positionTensor (State *state) const |
Returns walk tile resolution tensor of position probabilities. More... | |
std::pair< BuildType const *, float > | createTypeArgMax () const |
Returns argmax and probability of the BuildTypeMap distribution in the UPC's state field. More... | |
Static Public Member Functions | |
static CommandT | uniformCommand () |
Creates a uniform distribution over all game commands. More... | |
Public Attributes | |
UnitT | unit |
A distribution over units that we can control. More... | |
PositionT | position |
A distribution over positions. More... | |
CommandT | command |
A distribution over abstract game commands. More... | |
StateT | state |
An auxiliary state that can be used to pass additional information. More... | |
int | scale = 1 |
Specifies the (inverse) scale of the position tensor or the single sharp position. More... | |
(Unit, Position, Command) tuple.
Specifies the (who, where, what) of an action
UPCTuples are used for module-to-module communication (via the Blackboard). Posting a UPCTuple to the Blackboard is akin to requesting a specific action from another module, and consuming a UPCTuple from the Blackboard implies that the consumer implements this action. The implementation can also consist of refining the UPCTuple so that a more lower-level module can actually execute it.
For example, a build order module might post a UPCTuple to create a certain unit type, and a builder module might wait until their are sufficient resources before consuming it and then select a worker and a location.
The UPCToCommandModule translates executable UPCTuples (ones with sharp unit, position and command entries) to actual game commands.
using cherrypi::UPCTuple::BuildTypeMap = std::unordered_map<BuildType const*, float> |
using cherrypi::UPCTuple::CommandMap = std::unordered_map<Command, float> |
A typedef for the command distribution.
using cherrypi::UPCTuple::Empty = char |
An empty default item for the variants defined below.
using cherrypi::UPCTuple::PositionT = mapbox::util::variant<Empty, Position, Area*, UnitMap, torch::Tensor> |
A typedef for the position distribution.
Possible values:
using cherrypi::UPCTuple::SetCreatePriorityState = std::tuple<UpcId, float> |
using cherrypi::UPCTuple::StateT = mapbox::util::variant< Empty, BuildTypeMap, std::string, Position, SetCreatePriorityState, torch::Tensor> |
A typedef for additional structured information ("state").
Possible values:
using cherrypi::UPCTuple::UnitMap = std::unordered_map<Unit*, float> |
using cherrypi::UPCTuple::UnitT = UnitMap |
A typedef for the unit distribution.
float cherrypi::UPCTuple::commandProb | ( | Command | c | ) | const |
Returns the probability of a given command.
std::pair< BuildType const *, float > cherrypi::UPCTuple::createTypeArgMax | ( | ) | const |
Returns argmax and probability of the BuildTypeMap distribution in the UPC's state
field.
If the UPC specifies a different type of state, this function will return (nullptr, 0.0f)
std::pair< Position, float > cherrypi::UPCTuple::positionArgMax | ( | ) | const |
Returns argmax and probability of position distribution.
float cherrypi::UPCTuple::positionProb | ( | int | x, |
int | y | ||
) | const |
Returns the probability of a given position.
torch::Tensor cherrypi::UPCTuple::positionTensor | ( | State * | state | ) | const |
Returns walk tile resolution tensor of position probabilities.
std::pair< Unit *, float > cherrypi::UPCTuple::positionUArgMax | ( | ) | const |
Returns argmax and probability of position distribution over units.
|
static |
Creates a uniform distribution over all game commands.
CommandT cherrypi::UPCTuple::command |
A distribution over abstract game commands.
PositionT cherrypi::UPCTuple::position |
A distribution over positions.
int cherrypi::UPCTuple::scale = 1 |
Specifies the (inverse) scale of the position tensor or the single sharp position.
For efficiency reasons, position tensors can be specified at a coarser resolution.
StateT cherrypi::UPCTuple::state |
An auxiliary state that can be used to pass additional information.
Interpretation of this is entirely context-dependent.
UnitT cherrypi::UPCTuple::unit |
A distribution over units that we can control.