-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAI.cpp
More file actions
83 lines (73 loc) · 1.14 KB
/
Copy pathAI.cpp
File metadata and controls
83 lines (73 loc) · 1.14 KB
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
#include "AI.h"
#include "strategy.h"
#include "aggressive.h"
#include "defensive.h"
#include "random.h"
AI::AI(int id)
{
isComputer = true;
playerID = id+10;
name = "CPU"+to_string(id);
int num = strat->getStrategy();
switch (num)
{
case 0:
strat = new aggressive();
stratType = "aggressive";
break;
case 1:
strat = new defensive();
stratType = "defensive";
break;
case 2:
strat = new random();
stratType = "random";
break;
}
}
AI::AI(int id, string inStrat)
{
int result;
isComputer = true;
playerID = id+10;
name = "CPU"+to_string(id);
if (inStrat == "aggressive")
result = 0;
else if (inStrat == "defensive")
result = 1;
else
result = 2;
switch (result)
{
case 0:
strat = new aggressive();
stratType = "aggressive";
break;
case 1:
strat = new defensive();
stratType = "defensive";
break;
case 2:
strat = new random();
stratType = "random";
break;
}
}
AI::AI()
{
isComputer = true;
name = "CPU";
int num = strat->getStrategy();
switch (num)
{
case 0:
strat = new aggressive();
break;
case 1:
strat = new defensive();
break;
case 2:
strat = new random();
break;
}
}