This repository has been archived by the owner on Feb 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathai.cpp
148 lines (141 loc) · 3.56 KB
/
ai.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#include <bits/stdc++.h>
using namespace std;
const int MAX_TURN = 1000;
const int H = 15;
const int W = 15;
enum UNIT_TYPE {
KING,
ASSASSIN,
WARRIOR,
MAGE,
NONE
};
int dy[] = {1, 1, 1, 0, 0, -1, -1, -1};
int dx[] = {1, 0, -1, 1, -1, 1, 0, -1};
class Units {
public:
int id;
UNIT_TYPE type;
int x;
int y;
int hp;
int atk;
int value;
Units() {
id=x=y=hp=atk=value=-1;
type=NONE;
}
Units(int _id, UNIT_TYPE _type, int _hp, int _atk, int _x, int _y, int _value):id(_id), type(_type), hp(_hp), atk(_atk), x(_x), y(_y), value(_value) {
}
};
Units getShop() {
int id, hp, atk, value;
string s;
cin>>id>>s>>hp>>atk>>value;
Units ret = Units();
ret.id=id;
ret.hp = hp;
ret.atk = atk;
ret.x = ret.y = -1;
ret.value = value;
if(s=="ASSASSIN") {
ret.type = ASSASSIN;
}
else if(s=="WARRIOR") {
ret.type = WARRIOR;
}
else if(s=="MAGE") {
ret.type = MAGE;
}
return ret;
}
Units getUnit() {
int id, hp, atk, x, y;
string type; cin>>id>>type>>hp>>atk>>x>>y;
Units ret = Units();
ret.id = id;
ret.hp = hp;
ret.atk = atk;
ret.x = x;
ret.y = y;
if(type=="KING") {
ret.type = KING;
}
else if(type=="ASSASSIN") {
ret.type = ASSASSIN;
}
else if(type == "WARRIOR") {
ret.type = WARRIOR;
}
else if(type == "MAGE") {
ret.type = MAGE;
}
return ret;
}
int main() {
random_device rnd;
cout<<"Sample_AI2"<<endl;
int turn = 0;
while(++turn < MAX_TURN) {
cin >> turn;
int time_left; cin>>time_left;
int myLevel,oppLevel; cin>>myLevel>>oppLevel;
int myGold, oppGold; cin>>myGold>>oppGold;
vector<Units> shop(3);
for(int i = 0; i < 3; i++) {
shop[i] = getShop();
}
int n; cin>>n;
vector<Units> Align(n);
for(int i = 0; i < n; i++) {
Align[i] = getUnit();
}
int m; cin>>m;
vector<Units> Enemy(m);
for(int i = 0; i < m; i++) {
Enemy[i] = getUnit();
}
int command_num = rnd()%5;
if(command_num == 0) {
int selected = rnd()%3;
int tx = Align[0].x + (rnd()%7)-3;
int ty = Align[0].y + (rnd()%7)-3;
cout<<"buy "<<shop[selected].id<<" "<<tx<<" "<<ty<<endl;
}
else if(command_num == 1) {
vector<vector<int>> memo(4, vector<int>());
for(int i = 0 ; i < Align.size(); i++){
memo[Align[i].type].push_back(i);
}
bool nop = true;
for(int i = 1; i <= 3; i++) {
if(memo[i].size() >= 3) {
cout<<"evolve "<<Align[memo[i][0]].id<<" "<<Align[memo[i][1]].id<<" "<<Align[memo[i][2]].id<<endl;
nop=false;
break;
}
}
if(nop) {
cout<<"nop"<<endl;
}
}
else if(command_num == 2) {
cout<<"levelup"<<endl;
}
else {
cout<<"nop"<<endl;
}
vector<string> out;
for(int i = 0; i < Align.size(); i++) {
if(Align[i].x != -1) {
int dir = rnd()%8;
out.push_back(to_string(Align[i].id) + " " + to_string(Align[i].x + dx[dir]) + " " + to_string(Align[i].y + dy[dir]));
}
}
cout<<out.size()<<endl;
for(int i = 0 ; i < out.size(); i++) {
cout<<out[i]<<endl;
}
}
return 0;
}