-
Notifications
You must be signed in to change notification settings - Fork 2
/
InfluenceMap.h
85 lines (61 loc) · 1.79 KB
/
InfluenceMap.h
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
#pragma once
#include <map>
#include <string>
#include <vector>
#include "float3.h"
class BaczekKPAI;
class InfluenceMap
{
protected:
BaczekKPAI* ai;
int lastMinimaFrame; //<? for caching purposes
std::vector<int> minimaCachedValues;
std::vector<float3> minimaCachedPositions;
// partial updates
size_t alliedProgress, enemyProgress;
bool updateInProgress;
bool enemiesDone;
std::vector<int> friends, enemies;
public:
InfluenceMap(BaczekKPAI* ai, std::string);
~InfluenceMap();
static const int influence_size_divisor = 8;
std::string configName;
struct UnitData {
std::string name;
int max_value;
int min_value;
int radius;
};
typedef std::map<std::string, UnitData> unit_value_map_t;
unit_value_map_t unit_map;
int mapw, maph;
float scalex, scaley;
typedef std::vector<std::vector<int> > map_t;
map_t map;
map_t workMap;
/* reads a config file in a format like
{
"kernel": {
"max": 5,
"min": 0,
"radius": 10
}
}
*/
bool ReadJSONConfig();
static void WriteDefaultJSONConfig(std::string configName);
int GetAtXY(int x, int y);
void UpdateAll(const std::vector<int>& friends,
const std::vector<int>& enemies);
void Update(const std::vector<int>& friends,
const std::vector<int>& enemies);
void StartPartialUpdate(const std::vector<int>& friends,
const std::vector<int>& enemies);
void FinishPartialUpdate();
bool IsUpdateInProgress() { return updateInProgress; }
bool UpdatePartial(bool allied, const std::vector<int>& uids);
void UpdateSingleUnit(int uid, int sign, map_t& themap);
void FindLocalMinima(float radius, std::vector<int>& values, std::vector<float3>& positions);
void FindLocalMinNear(float3 point, float3& retpoint, int& retval);
};