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

Sparse featurizer for unit types, defogger-style. More...

#include <unitsfeatures.h>

Inherits cherrypi::UnitAttributeFeaturizer.

Inherited by cherrypi::UnitTypeMDefoggerFeaturizer.

Public Member Functions

 UnitTypeDefoggerFeaturizer ()
 
int mapType (int unitType) const
 
int unmapType (int mappedType) const
 
FeatureData toDefoggerFeature (Data const &data, int res, int stride) const
 
- Public Member Functions inherited from cherrypi::UnitAttributeFeaturizer
virtual ~UnitAttributeFeaturizer ()=default
 
virtual Data extract (State *state, UnitsInfo::Units const &units, Rect const &boundingBox=Rect())
 Extract unit features for a given set of units. More...
 
Data extract (State *state, Rect const &boundingBox=Rect())
 Extract unit features for all live units. More...
 
Data extract (State *state, UnitFilter filter, Rect const &boundingBox=Rect())
 Extract unit features for all live units that pass the given filter. More...
 
FeatureData toSpatialFeature (Data const &data, SubsampleMethod pooling=SubsampleMethod::Sum) const
 Embeds the unit attribute data into a spatial feature. More...
 
void toSpatialFeature (FeatureData *dest, Data const &data, SubsampleMethod pooling=SubsampleMethod::Sum) const
 Embeds the unit attribute data into a spatial feature. More...
 

Static Public Attributes

static int constexpr kNumUnitTypes = 118 * 2
 

Protected Member Functions

virtual void extractUnit (TensorDest acc, Unit *unit) override
 Reimplement this in actual featurizers. More...
 

Protected Attributes

std::array< int, 234 > * typemap_
 
std::array< int, 234 > * itypemap_
 

Additional Inherited Members

- Public Types inherited from cherrypi::UnitAttributeFeaturizer
using UnitFilter = std::function< bool(Unit *)>
 
using TensorDest = torch::TensorAccessor< float, 1 >
 
- Public Attributes inherited from cherrypi::UnitAttributeFeaturizer
std::shared_ptr< BaseJitterjitter = std::make_shared<NoJitter>()
 Optional jittering of unit positions. More...
 
CustomFeatureType type
 
std::string name
 
int numChannels
 

Detailed Description

Sparse featurizer for unit types, defogger-style.

This featurizer maps unit types to 118 IDs (instead of the 234 possible IDs) and assigns valid IDs to allied and enemy units only – neutral units will be be mapped to -1.

toDefoggerFeature() supports pooling with a given resolution and stride so that the result contains accumulated unit counts per type for each "cell". It ignores neutral units.

Constructor & Destructor Documentation

cherrypi::UnitTypeDefoggerFeaturizer::UnitTypeDefoggerFeaturizer ( )

Member Function Documentation

virtual void cherrypi::UnitTypeDefoggerFeaturizer::extractUnit ( TensorDest  acc,
Unit unit 
)
inlineoverrideprotectedvirtual

Reimplement this in actual featurizers.

This function is expected to set acc[0], ..., acc[numChannels-1]

Implements cherrypi::UnitAttributeFeaturizer.

int cherrypi::UnitTypeDefoggerFeaturizer::mapType ( int  unitType) const
inline
FeatureData cherrypi::UnitTypeDefoggerFeaturizer::toDefoggerFeature ( Data const &  data,
int  res,
int  stride 
) const
int cherrypi::UnitTypeDefoggerFeaturizer::unmapType ( int  mappedType) const
inline

Member Data Documentation

std::array<int, 234>* cherrypi::UnitTypeDefoggerFeaturizer::itypemap_
protected
int constexpr cherrypi::UnitTypeDefoggerFeaturizer::kNumUnitTypes = 118 * 2
static
std::array<int, 234>* cherrypi::UnitTypeDefoggerFeaturizer::typemap_
protected

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