forked from phu004/JavaRTS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenemyCommander.java
More file actions
140 lines (99 loc) · 3.14 KB
/
Copy pathenemyCommander.java
File metadata and controls
140 lines (99 loc) · 3.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
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
package enemyAI;
import core.baseInfo;
import core.mainThread;
public class enemyCommander {
//vision map represents the vision of the enemy commander
public static boolean[] visionMap;
public static boolean[] tempBitmap;
public baseInfo theBaseInfo;
public buildingManagerAI theBuildingManagerAI;
public economyManagerAI theEconomyManagerAI;
public mapAwarenessAI theMapAwarenessAI;
public unitProductionAI theUnitProductionAI;
public baseExpensionAI theBaseExpentionAI;
public scoutingManagerAI theScoutingManagerAI;
public defenseManagerAI theDefenseManagerAI;
public combatManagerAI theCombatManagerAI;
public microManagementAI theMicroManagementAI;
public harassmentAI theHarassmentAI;
public int difficulty;
public int frameAI;
public void init(){
//init vision map
visionMap = new boolean[128*128];
tempBitmap = new boolean[148 * 148];
theBaseInfo = new baseInfo();
theBuildingManagerAI = new buildingManagerAI();
theEconomyManagerAI = new economyManagerAI();
theMapAwarenessAI = new mapAwarenessAI();
theUnitProductionAI = new unitProductionAI();
theBaseExpentionAI = new baseExpensionAI();
theScoutingManagerAI = new scoutingManagerAI();
theDefenseManagerAI = new defenseManagerAI();
theCombatManagerAI = new combatManagerAI();
theMicroManagementAI = new microManagementAI();
theHarassmentAI = new harassmentAI();
}
public void update(){
theBaseInfo.update();
//generate visionMap based on the map information of the previous frame
for(int y = 0; y < 128; y++){
for(int x = 0; x < 128; x++){
visionMap[x + y*128] = tempBitmap[x + 10 + (y + 10)*148];
}
}
//process high level enemy AI
thinkHardLikeHumanPlayer();
//drawVisionMap();
//reset tempBitmap;
for(int i = 0 ;i < tempBitmap.length; i++){
tempBitmap[i] = false;
}
}
public void drawVisionMap(){
int pos = 2 + 20 * 768;
boolean tile;
int[] screen = mainThread.screen2;
for(int i = 0; i < 128; i++){
for(int j = 0; j < 128; j++){
tile = visionMap[j + i*128];
if(!tile)
screen[pos + j + i*768] = 0;
}
}
}
public void thinkHardLikeHumanPlayer(){
frameAI = mainThread.gameFrame/30;
//the order is important!!
if(mainThread.gameFrame % 30 == 0){
theMapAwarenessAI.processAI();
}
if(mainThread.gameFrame % 30 == 1){
theBuildingManagerAI.processAI();
}
if(mainThread.gameFrame % 30 == 2){
theEconomyManagerAI.processAI();
}
if(mainThread.gameFrame % 30 == 3){
if(difficulty > 0)
theScoutingManagerAI.processAI();
}
if(mainThread.gameFrame % 30 == 4){
theUnitProductionAI.processAI();
}
if(mainThread.gameFrame % 30 == 5){
theBaseExpentionAI.processAI();
}
if(mainThread.gameFrame % 30 == 6){
theCombatManagerAI.processAI();
}
if(mainThread.gameFrame % 30 == 7){
if(difficulty > 0)
theDefenseManagerAI.processAI();
}
if(difficulty == 2){
theHarassmentAI.processAI();
theMicroManagementAI.processAI();
}
}
}