-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathai.h
51 lines (38 loc) · 1.42 KB
/
ai.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
/**
* \file ai.h
* \brief High level AI.
*
* This file contains high level AI player behaviour which uses influence maps.
* Low level AI is in people.h.
*/
#ifndef ai_h_bedas_guard
#define ai_h_bedas_guard
#include "core.h"
/**
* \brief Class for managing high level enemy behaviour.
* Gives orders to idle enemy units, and chooses building which the enemies will try attack by influence maps.
*/
class enemy_ai
{
public:
typedef int INFLUENCE_T;
void update(); ///< Should be called once per frame, manages whole class.
void register_units(); ///< Registers all currently existing enemy units to be controled by this class.
void unit_attacked(tile* from); ///< Tells AI that AI's unit was attacked.
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive & ar, const unsigned int version)
{
using boost::serialization::make_nvp;
ar & make_nvp("units", units);
ar & make_nvp("main_target", main_target);
}
protected:
void choose_main_target();
std::vector<std::vector<INFLUENCE_T>> generate_influence_map(); ///< Higher influence means enemy wants to go there
void add_influence_source(std::vector<tile*> starting_tiles, INFLUENCE_T influence, std::vector<std::vector<INFLUENCE_T>>& map); ///< Adds one source of influence (unit, building) to map
void check_death_units();
std::vector<boost::weak_ptr<warrior>> units;
boost::weak_ptr<building> main_target;
};
#endif