11 #include "features/features.h" 12 #include "features/unitsfeatures.h" 14 #include <autogradpp/autograd.h> 70 std::shared_ptr<UPCTuple> upc,
78 std::shared_ptr<UPCTuple> upc);
94 template <
class Archive>
95 void serialize(Archive& ar, uint32_t
const version) {
102 CEREAL_NVP(playerName),
131 TORCH_ARG(
bool, masked) =
false;
132 TORCH_ARG(
bool, flatten) =
true;
133 TORCH_ARG(
bool, logprobs) =
false;
134 TORCH_ARG(
int, num_top_channels) = 64;
135 TORCH_ARG(
int, num_top_convs) = 4;
137 void reset()
override;
140 ag::Variant makeInputBatch(
141 std::vector<BuildingPlacerSample>
const& samples, torch::Device)
const;
142 ag::Variant makeInputBatch(std::vector<BuildingPlacerSample>
const& samples)
151 std::pair<ag::Variant, ag::Variant> makeBatch(
152 std::vector<BuildingPlacerSample>
const& samples, torch::Device)
const;
153 std::pair<ag::Variant, ag::Variant> makeBatch(
154 std::vector<BuildingPlacerSample>
const& samples)
const;
171 ag::Variant forward(ag::Variant input)
override;
174 ag::Container embedU;
175 ag::Container embedT;
179 std::vector<ag::Container> convS;
180 ag::Container dconv2;
182 ag::Container postskip2;
183 ag::Container dconv1;
185 ag::Container postskip1;
Game state.
Definition: state.h:42
torch::Tensor validLocations
Float tensor that contains all valid build locations wrt the input UPC (1 = valid, 0 = invalid).
Definition: buildingplacer.h:46
int FrameNum
Definition: basetypes.h:22
FrameNum frame
Frame number of this sample.
Definition: buildingplacer.h:52
int areaId
Area ID; optional, for easier baseline computations.
Definition: buildingplacer.h:59
Position offsetToAction(int64_t offset, int scale=1) const
Maps offset in flattened output or target tensor to a walktile position.
Definition: buildingplacer.cpp:188
Position action
Model target output: a single position (in walk tiles)
Definition: buildingplacer.h:62
FeatureData map
Various map features (plus UPC probabilities), build tile resolution.
Definition: buildingplacer.h:38
FeatureData smap
Definition: buildingplacer.h:32
void serialize(Archive &ar, uint32_t const version)
Definition: buildingplacer.h:95
struct cherrypi::BuildingPlacerSample::@0 features
State-dependent input features.
Game-dependent input features.
Definition: buildingplacer.h:30
BuildingPlacerSample()=default
virtual ~BuildingPlacerSample()=default
static int kNumMapChannels
Definition: buildingplacer.h:27
StaticData(State *state)
Definition: buildingplacer.cpp:70
std::vector< torch::Tensor > networkInput() const
Assemble network input.
Definition: buildingplacer.cpp:168
Sparse featurizer for numeric unit types.
Definition: unitsfeatures.h:116
Represents a collection of spatial feature data.
Definition: features.h:190
static int constexpr kMapSize
Definition: buildingplacer.h:26
UnitTypeFeaturizer::Data units
Unit type IDs that are present.
Definition: buildingplacer.h:40
Describes a sample that can be used to learn the BuildingPlacerModel.
Definition: buildingplacer.h:24
std::string playerName
Player name; optional.
Definition: buildingplacer.h:57
AUTOGRAD_CONTAINER_CLASS(BuildingPlacerModel)
A CNN model for determining building positions.
Definition: buildingplacer.h:129
Definition: unitsfeatures.h:33
int UnitType
Definition: buildingplacer.h:25
int64_t actionToOffset(Position pos, int scale=1) const
Maps an action (position) in walktiles to offset in flattened output or target tensor.
Definition: buildingplacer.cpp:180
std::string mapName
Map name (file name for replays); optional.
Definition: buildingplacer.h:55
Main namespace for bot-related code.
Definition: areainfo.cpp:17
UnitTypeFeaturizer unitFeaturizer
Definition: buildingplacer.h:49
UnitType type
Requested building type.
Definition: buildingplacer.h:42