TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
Classes | Public Types | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
cherrypi::BuildingPlacerSample Struct Reference

Describes a sample that can be used to learn the BuildingPlacerModel. More...

#include <buildingplacer.h>

Classes

struct  StaticData
 Game-dependent input features. More...
 

Public Types

using UnitType = int
 

Public Member Functions

 BuildingPlacerSample ()=default
 
virtual ~BuildingPlacerSample ()=default
 
 BuildingPlacerSample (State *state, std::shared_ptr< UPCTuple > upc, StaticData *staticData=nullptr)
 Constructs a new sample with features extracted from the given state. More...
 
 BuildingPlacerSample (State *state, Position action, std::shared_ptr< UPCTuple > upc)
 Constructs a new sample with features extracted from the given state, along with a target action. More...
 
std::vector< torch::Tensor > networkInput () const
 Assemble network input. More...
 
int64_t actionToOffset (Position pos, int scale=1) const
 Maps an action (position) in walktiles to offset in flattened output or target tensor. More...
 
Position offsetToAction (int64_t offset, int scale=1) const
 Maps offset in flattened output or target tensor to a walktile position. More...
 
template<class Archive >
void serialize (Archive &ar, uint32_t const version)
 

Public Attributes

struct {
   FeatureData   map
 Various map features (plus UPC probabilities), build tile resolution. More...
 
   UnitTypeFeaturizer::Data   units
 Unit type IDs that are present. More...
 
   UnitType   type = (+tc::BW::UnitType::MAX)._to_integral()
 Requested building type. More...
 
   torch::Tensor   validLocations
 Float tensor that contains all valid build locations wrt the input UPC (1 = valid, 0 = invalid). More...
 
features
 State-dependent input features. More...
 
UnitTypeFeaturizer unitFeaturizer
 
FrameNum frame
 Frame number of this sample. More...
 
std::string mapName
 Map name (file name for replays); optional. More...
 
std::string playerName
 Player name; optional. More...
 
int areaId = -1
 Area ID; optional, for easier baseline computations. More...
 
Position action
 Model target output: a single position (in walk tiles) More...
 

Static Public Attributes

static int constexpr kMapSize = 512
 
static int kNumMapChannels = 8
 

Detailed Description

Describes a sample that can be used to learn the BuildingPlacerModel.

Member Typedef Documentation

Constructor & Destructor Documentation

cherrypi::BuildingPlacerSample::BuildingPlacerSample ( )
default
virtual cherrypi::BuildingPlacerSample::~BuildingPlacerSample ( )
virtualdefault
cherrypi::BuildingPlacerSample::BuildingPlacerSample ( State state,
std::shared_ptr< UPCTuple upc,
StaticData staticData = nullptr 
)

Constructs a new sample with features extracted from the given state.

cherrypi::BuildingPlacerSample::BuildingPlacerSample ( State state,
Position  action,
std::shared_ptr< UPCTuple upc 
)

Constructs a new sample with features extracted from the given state, along with a target action.

Member Function Documentation

int64_t cherrypi::BuildingPlacerSample::actionToOffset ( Position  pos,
int  scale = 1 
) const

Maps an action (position) in walktiles to offset in flattened output or target tensor.

"scale" will be accounted for in addtion to the scale of the extracted features.

std::vector< torch::Tensor > cherrypi::BuildingPlacerSample::networkInput ( ) const

Assemble network input.

Position cherrypi::BuildingPlacerSample::offsetToAction ( int64_t  offset,
int  scale = 1 
) const

Maps offset in flattened output or target tensor to a walktile position.

"scale" will be accounted for in addtion to the scale of the extracted features.

template<class Archive >
void cherrypi::BuildingPlacerSample::serialize ( Archive &  ar,
uint32_t const  version 
)
inline

Member Data Documentation

Position cherrypi::BuildingPlacerSample::action

Model target output: a single position (in walk tiles)

int cherrypi::BuildingPlacerSample::areaId = -1

Area ID; optional, for easier baseline computations.

struct { ... } cherrypi::BuildingPlacerSample::features

State-dependent input features.

FrameNum cherrypi::BuildingPlacerSample::frame

Frame number of this sample.

int constexpr cherrypi::BuildingPlacerSample::kMapSize = 512
static
int cherrypi::BuildingPlacerSample::kNumMapChannels = 8
static
FeatureData cherrypi::BuildingPlacerSample::map

Various map features (plus UPC probabilities), build tile resolution.

std::string cherrypi::BuildingPlacerSample::mapName

Map name (file name for replays); optional.

std::string cherrypi::BuildingPlacerSample::playerName

Player name; optional.

UnitType cherrypi::BuildingPlacerSample::type = (+tc::BW::UnitType::MAX)._to_integral()

Requested building type.

UnitTypeFeaturizer cherrypi::BuildingPlacerSample::unitFeaturizer
UnitTypeFeaturizer::Data cherrypi::BuildingPlacerSample::units

Unit type IDs that are present.

torch::Tensor cherrypi::BuildingPlacerSample::validLocations

Float tensor that contains all valid build locations wrt the input UPC (1 = valid, 0 = invalid).

This is intended to be used as a mask for the model output.


The documentation for this struct was generated from the following files: