-
Notifications
You must be signed in to change notification settings - Fork 0
/
TTM.java
76 lines (65 loc) · 1.56 KB
/
TTM.java
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
package team022;
import battlecode.common.*;
public class TTM extends BaseRobot {
public MapLocation archonLoc = null;
public TTM(RobotController rcin) {
super(rcin);
// TODO Auto-generated constructor stub
}
//Note: If we are spawned as a TTM, then our strategy is Mongols
@Override
public void run() {
while(true){
receiveAllMessages();
if(archonLoc != null){
boolean notMoved = true;
while(notMoved){
try {
notMoved = moveAsCloseToDirection(archonLoc.directionTo(rc.getLocation()), false);
} catch (GameActionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Clock.yield();
}
try {
rc.unpack();
} catch (GameActionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
public void run_ret(MapLocation archonLoc){
while(archonLoc == null)
receiveAllMessages();
boolean notMoved = true;
while(notMoved){
try {
notMoved = !moveAsCloseToDirection(archonLoc.directionTo(rc.getLocation()), false);
} catch (GameActionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Clock.yield();
}
try {
rc.unpack();
rc.emptySignalQueue();
for(int i = 0; i < 10; i++)
Clock.yield();
} catch (GameActionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void receiveAllMessages(){
for(Signal message : rc.emptySignalQueue()){
if(ComSystem.getFlag(message) == 0x42){
archonLoc = message.getLocation();
break;
}
}
}
}