-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathStrat.hpp
112 lines (90 loc) · 2.91 KB
/
Strat.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#ifndef STRAT_HPP
#define STRAT_HPP
#include "Simulator.hpp"
constexpr int DISTR_MAT_CELL_SIZE = 16;
constexpr int DISTR_MAT_CELLS_X = (WIDTH + DISTR_MAT_CELL_SIZE - 1) / DISTR_MAT_CELL_SIZE;
constexpr int DISTR_MAT_CELLS_Y = (HEIGHT + DISTR_MAT_CELL_SIZE - 1) / DISTR_MAT_CELL_SIZE;
struct DistributionMatrix {
struct Cell {
double count[5] = {};
double health[5] = {};
double totalHealth = 0.0;
double updateTick = 0;
double realUpdateTick = 0;
};
Cell cells[DISTR_MAT_CELLS_X * DISTR_MAT_CELLS_Y];
Cell &getCell(int x, int y) {
assert(x >= 0 && x < DISTR_MAT_CELLS_X);
assert(y >= 0 && y < DISTR_MAT_CELLS_Y);
return cells[y * DISTR_MAT_CELLS_X + x];
}
const Cell &getCell(int x, int y) const {
assert(x >= 0 && x < DISTR_MAT_CELLS_X);
assert(y >= 0 && y < DISTR_MAT_CELLS_Y);
return cells[y * DISTR_MAT_CELLS_X + x];
}
DistributionMatrix() {}
void initialize(const Simulator &sim, bool firstTick);
void clear();
void blur(DistributionMatrix &oth) const;
};
struct DebugAttractionPointsInfo {
P point;
P dir;
double val;
};
struct DangerDistCell {
double enemyDamage[5];
double enemyHealth[5];
double totalMyDamage, totalEnemyDamage, totalEnemyHealth;
double f2hDmg;
};
struct ShrinkResult {
BBox endBBox;
P shrinkPoint;
int ticks = 0;
};
struct DangerDistCells {
DangerDistCell cells[DISTR_MAT_CELLS_X * DISTR_MAT_CELLS_Y];
};
struct Strat : Simulator {
Strat();
MyMove calcNextMove();
MyMove nextMove() {
MyMove result = calcNextMove();
if (result.action != MyActionType::NONE)
registerAction();
return result;
}
void calcMicroShift(Group &group, P &shift);
double attractionPoint(const P from, const Group &group, double ticks, bool angryMode);
void calcNuclearEfficiency();
void calcDangerDistCells();
void calcVisibilityFactors();
bool anyEnemiesNearbyByDangerDistr(const Group &group);
const Group *dngGr = nullptr;
void assignBuildings();
void updateGroupAttraction();
void spreadDistributionMatrix(DistributionMatrix &distrMatrix);
int extractFighterStep = -1;
P extractFighterTarget;
//bool highPriorityCells[DISTR_MAT_CELLS_X * DISTR_MAT_CELLS_Y];
int groupSeq = 1;
int internalGroupSeq = 1;
bool initialGroupsGerationDone = false;
DistributionMatrix distributionMatrix;
DistributionMatrix distributionMatrixFOWBlured;
bool distributionMatrixInitialized = false;
double nuclearEfficiency[MICROCELLS_X * MICROCELLS_Y];
std::map<int, DangerDistCells> dangerDistCells;
double visibilityFactors[DISTR_MAT_CELLS_X * DISTR_MAT_CELLS_Y];
ShrinkResult findShrink(Group &group);
int buildingCaptured = 0;
UnitType calcNextUnitTypeForConstruction(bool ground);
///
std::vector<DebugAttractionPointsInfo> debugAttractionPoints;
bool canMove(const P &shift, const Group &group) const;
bool canMoveDetailed(const P &shift, const Group &group, const std::vector<const MyUnit *> &groupUnits, const std::vector<const MyUnit *> &otherUnits) const;
///
};
#endif