-
Notifications
You must be signed in to change notification settings - Fork 0
/
actions.cpp
103 lines (74 loc) · 2.3 KB
/
actions.cpp
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
#include "common.h"
#include "basic_function.cpp"
int ACTION_ID = 0;
extern int ja; // ktory hrac som
extern Mapa mapa;
extern Tah tah;
extern Stav stav;
extern Tah mojTah;
//basic action
struct Action {
int id;
Zivocich actor;
double get_priority (){
return 0;
}
int get_ap (){
return zistiApCenu(mapa,stav,tah,);
}
Prikaz get_command () {
return Prikaz::chod (actor.id, actor.x, actor.y);
};
void execute () {
vykonaj (this->get_command());
}
Action (Zivocich actor) {
this->id = ACTION_ID++;
this->actor = actor;
}
Action () {
this->id = ACTION_ID++;
}
};
bool asdfghjkl (pair <Quest, Quest_spec> a, pair <Quest, Quest_spec> b){
return (a.first.zlato - (double)a.second.vzdialenost_k_mestu/10)*1000 / a.second.vzdialenost_k_mestu >
(b.first.zlato - (double)b.second.vzdialenost_k_mestu/10)*1000 / b.second.vzdialenost_k_mestu;
}
struct CollectItems: public Action {
Quest targetQuest;
Quest_spec targetItem;
vector <vector<int> > bfsdata;
void QuestSelect(){
if (!QuestExist(targetQuest)){
vector <pair <Quest, Quest_spec>> data;
for(Quest quest: stav.questy){
Quest_spec target_item = getBestItem(quest, bfsdata);
if (target_item.item_owner != -1) data.push_back(make_pair(quest, target_item));
}
sort (data.begin(), data.end(), asdfghjkl);
if (data.size() > 1) {
targetItem = data[1].second;
targetQuest = data[1].first;
}
else if (data.size() > 0){
targetItem = data[0].second;
targetQuest = data[0].first;
}
}
}
Prikaz get_command(){
bfsdata = bfsmem(Bod(actor));
QuestSelect ();
Bod target = targetItem.poz;
if (actor.nesenyPredmet == targetQuest.ziadanyPredmet) target = Bod (targetQuest.cielX, targetQuest.cielY);
int v = target.get(bfsdata);
Bod next;
for (auto smer: d_cka){
if ((smer + target).get(bfsdata) < v) {
next = smer + target;
v = (smer + target).get(bfsdata);
}
}
return Prikaz::chod(actor.id, next.x, next.y);
}
};