-
Notifications
You must be signed in to change notification settings - Fork 5
/
RobotPlayer.java
36 lines (32 loc) · 1.39 KB
/
RobotPlayer.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
package lectureplayer;
import battlecode.common.*;
public strictfp class RobotPlayer {
/**
* run() is the method that is called when a robot is instantiated in the Battlecode world.
* If this method returns, the robot dies!
**/
public static void run(RobotController rc) throws GameActionException {
Robot me = null;
switch (rc.getType()) {
case HQ: me = new HQ(rc); break;
case MINER: me = new Miner(rc); break;
case REFINERY: me = new Refinery(rc); break;
case VAPORATOR: me = new Vaporator(rc); break;
case DESIGN_SCHOOL: me = new DesignSchool(rc); break;
case FULFILLMENT_CENTER: me = new Building(rc); break;
case LANDSCAPER: me = new Landscaper(rc); break;
case DELIVERY_DRONE: me = new Unit(rc); break;
case NET_GUN: me = new Shooter(rc); break;
}
while(true) {
try {
me.takeTurn();
// Clock.yield() makes the robot wait until the next turn, then it will perform this loop again
Clock.yield();
} catch (Exception e) {
System.out.println(rc.getType() + " Exception"); // darn
e.printStackTrace();
}
}
}
}