-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHQ.java
More file actions
49 lines (44 loc) · 1.22 KB
/
Copy pathHQ.java
File metadata and controls
49 lines (44 loc) · 1.22 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
package team018;
import battlecode.common.Direction;
import battlecode.common.MapLocation;
import battlecode.common.Robot;
import battlecode.common.RobotController;
import battlecode.common.Upgrade;
public class HQ extends DefaultRobot {
private int soldierCount = 0;
public HQ(RobotController rc) {
super(rc);
}
public void run() {
while (true) {
MapLocation location = rc.getLocation();
try {
if (rc.isActive()) {
if (roundCount < 45 && roundCount != 0 && roundCount != 30) {
rc.researchUpgrade(Upgrade.DEFUSION);
} else {
// spawn soldier
Direction dir = location.directionTo(enemyHQLoc);
dir = getDirTowTarAvoidMines(dir);
if (dir == null) {
dir = randDirNoMines();
}
if (dir == null) {
dir = directions[rand.nextInt(8)];
}
rc.spawn(dir);
soldierCount++;
}
rc.broadcast(roundCountChan, roundCount);
broadcastDataScram(defenseNeedChan, rc.senseNearbyGameObjects(Robot.class, 9, rc.getTeam()).length);
broadcastDataScram(spawnChannel, soldierCount);
}
} catch (Exception e) {
e.printStackTrace();
}
rc.setIndicatorString(1, "round: " + Integer.toString(roundCount));
roundCount++;
rc.yield();
}
}
}