Repository navigation
Expand file tree
/
Copy pathTrainingQueueTest.java
More file actions
52 lines (44 loc) · 1.53 KB
/
Copy pathTrainingQueueTest.java
File metadata and controls
52 lines (44 loc) · 1.53 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
package game;
import bwapi.*;
import java.util.List;
import java.util.stream.Collectors;
class TrainingQueueTest extends DefaultBWListener {
final BWClient bwClient;
Game game;
int mineralsReq = 250;
int workers = 1;
TrainingQueueTest() {
bwClient = new BWClient(this);
bwClient.startGame();
}
public void onStart() {
game = bwClient.getGame();
game.enableFlag(Flag.UserInput);
game.setLocalSpeed(0);
//game.setLatCom(false);
}
@Override
public void onFrame() {
List<Unit> minerals = game.getMinerals().stream().filter(Unit::isVisible).collect(Collectors.toList());
if (game.self().minerals() >= 230) {
game.setLocalSpeed(20);
}
for (Unit unit : game.self().getUnits()) {
UnitType type = unit.getType();
if (type.isWorker() && unit.isIdle()) {
unit.gather(minerals.get(unit.getID() % minerals.size()));
}
else if (type.isResourceDepot() && game.self().minerals() >= mineralsReq) {
System.out.println("######## FRAME " + game.getFrameCount() + " ########");
unit.train(game.self().getRace().getWorker());
System.out.println("training worker: " + workers);
mineralsReq -= 50;
workers += 1;
System.out.println("trainingQueue: " + unit.getTrainingQueue());
}
}
}
public static void main(String[] args) {
new TrainingQueueTest();
}
}