12 #include "tilesinfo.h" 23 std::fill(inBaseArea.begin(), inBaseArea.end(), 0);
26 auto* tilesData = tilesInfo.
tiles.data();
28 const int mapWidth = state->
mapWidth();
33 const Tile* sourceTile;
37 std::vector<Position> staticDefence;
40 staticDefence.emplace_back(u->x, u->y);
43 const Tile* mainBaseTile =
nullptr;
44 std::deque<OpenNode> open;
47 auto* tile = tilesInfo.tryGetTile(u->x, u->y);
49 float maxDistance = isMain ? 4 * 24 : 4 * 14;
54 open.push_back({tile, tile, maxDistance});
55 inBaseArea.at(tile - tilesData) = 1;
58 while (!open.empty()) {
59 OpenNode curNode = open.front();
62 auto add = [&](
const Tile* ntile) {
63 if (!curNode.tile->entirelyWalkable) {
68 ntile->x, ntile->y, curNode.sourceTile->x, curNode.sourceTile->y);
69 if (sourceDistance >= curNode.maxDistance) {
74 bool staticDefenceIsCloserThanHome =
false;
75 bool isInStaticDefenceRange =
false;
79 isInStaticDefenceRange =
true;
81 if (d < sourceDistance) {
82 staticDefenceIsCloserThanHome =
true;
85 if (staticDefenceIsCloserThanHome && !isInStaticDefenceRange) {
90 auto& v = inBaseArea[ntile - tilesData];
95 open.push_back({ntile, curNode.sourceTile, curNode.maxDistance});
98 const Tile* tile = curNode.tile;
106 if (tile->
y < mapHeight - tc::BW::XYWalktilesPerBuildtile) {
114 if (tile->
y < mapHeight - tc::BW::XYWalktilesPerBuildtile) {
118 if (tile->
x < mapWidth - tc::BW::XYWalktilesPerBuildtile) {
123 if (tile->
y < mapHeight - tc::BW::XYWalktilesPerBuildtile) {
Game state.
Definition: state.h:42
void updateInBaseArea(State *state, std::vector< uint8_t > &inBaseArea)
Definition: interpretstate.h:22
int mapHeight() const
Definition: state.h:84
UnitsInfo & unitsInfo()
Definition: state.h:116
int y
Y position of tile in walk tiles.
Definition: tilesinfo.h:34
const Units & myResourceDepots()
Definition: unitsinfo.h:345
const Units & myUnitsOfType(const BuildType *type)
Our units of a particular type (does not include dead units).
Definition: unitsinfo.cpp:234
Represents a unit in the game.
Definition: unitsinfo.h:35
const BuildType * Zerg_Sunken_Colony
Definition: buildtype.cpp:358
float distance(int x1, int y1, int x2, int y2)
Walktile distance.
Definition: gamemechanics.h:49
static const unsigned tilesWidth
Definition: tilesinfo.h:98
int mapWidth() const
Definition: state.h:81
static const unsigned tilesHeight
Definition: tilesinfo.h:99
TilesInfo & tilesInfo()
Definition: state.h:119
int x
X position of tile in walk tiles.
Definition: tilesinfo.h:32
Represents a tile on the map.
Definition: tilesinfo.h:29
std::vector< Tile > tiles
All the tiles.
Definition: tilesinfo.h:115
Main namespace for bot-related code.
Definition: areainfo.cpp:17