forked from andrepl/bcode2013
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRobotPlayer.java
More file actions
57 lines (48 loc) · 1.73 KB
/
RobotPlayer.java
File metadata and controls
57 lines (48 loc) · 1.73 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
package team028;
import battlecode.common.*;
/** The example funcs player is a player meant to demonstrate basic usage of the most common commands.
* Robots will move around randomly, occasionally mining and writing useless messages.
* The HQ will spawn soldiers continuously.
*/
public class RobotPlayer {
public static void run(RobotController rc) {
Robot robot = rc.getRobot();
int robotId = robot.getID();
RobotType robotType = rc.getType();
Team team = robot.getTeam();
Bot bot = null;
switch (robotType) {
case HQ:
bot = new HQBot(robot, robotId, team, robotType, rc);
break;
case SOLDIER:
bot = new SoldierBot(robot, robotId, team, robotType, rc);
break;
case SUPPLIER:
bot = new SupplierBot(robot, robotId, team, robotType, rc);
break;
case SHIELDS:
bot = new ShieldBot(robot, robotId, team, robotType, rc);
break;
case ARTILLERY:
bot = new ArtilleryBot(robot, robotId, team, robotType, rc);
break;
case GENERATOR:
bot = new GeneratorBot(robot, robotId, team, robotType, rc);
break;
case MEDBAY:
bot = new MedBayBot(robot, robotId, team, robotType, rc);
break;
default:
System.out.println("Unhandled bot type: " + robotType);
break;
}
while(true) {
try {
bot.go();
} catch (GameActionException e) {
e.printStackTrace();
}
rc.yield();
}
}}