-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFile.java
More file actions
executable file
·86 lines (84 loc) · 2.15 KB
/
File.java
File metadata and controls
executable file
·86 lines (84 loc) · 2.15 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import battlecode.common.*;
public class MinerNav {
static RobotController rc;
MinerNav(RobotController rc) {
this.rc = rc;
}
static MapLocation loc0;
static MapLocation loc1;
static MapLocation loc2;
static MapLocation loc3;
static MapLocation loc4;
static MapLocation loc5;
static MapLocation loc6;
static MapLocation loc7;
static MapLocation bestSpot;
int rubble;
MapLocation findBestSquare(MapLocation leadLoc, int minRubble) throws GameActionException{
loc0 = leadLoc.add(Direction.EAST);
loc1 = leadLoc.add(Direction.WEST);
loc2 = leadLoc.add(Direction.SOUTH);
loc3 = leadLoc.add(Direction.NORTH);
loc4 = leadLoc.add(Direction.NORTHEAST);
loc5 = leadLoc.add(Direction.NORTHWEST);
loc6 = leadLoc.add(Direction.SOUTHEAST);
loc7 = leadLoc.add(Direction.SOUTHWEST);
if (rc.canSenseLocation(loc0)) {
rubble = 1 + rc.senseRubble(loc0) / 10;
if (rubble < minRubble) {
minRubble = rubble;
bestSpot = loc0;
}
}
if (rc.canSenseLocation(loc1)) {
rubble = 1 + rc.senseRubble(loc1) / 10;
if (rubble < minRubble) {
minRubble = rubble;
bestSpot = loc1;
}
}
if (rc.canSenseLocation(loc2)) {
rubble = 1 + rc.senseRubble(loc2) / 10;
if (rubble < minRubble) {
minRubble = rubble;
bestSpot = loc2;
}
}
if (rc.canSenseLocation(loc3)) {
rubble = 1 + rc.senseRubble(loc3) / 10;
if (rubble < minRubble) {
minRubble = rubble;
bestSpot = loc3;
}
}
if (rc.canSenseLocation(loc4)) {
rubble = 1 + rc.senseRubble(loc4) / 10;
if (rubble < minRubble) {
minRubble = rubble;
bestSpot = loc4;
}
}
if (rc.canSenseLocation(loc5)) {
rubble = 1 + rc.senseRubble(loc5) / 10;
if (rubble < minRubble) {
minRubble = rubble;
bestSpot = loc5;
}
}
if (rc.canSenseLocation(loc6)) {
rubble = 1 + rc.senseRubble(loc6) / 10;
if (rubble < minRubble) {
minRubble = rubble;
bestSpot = loc6;
}
}
if (rc.canSenseLocation(loc7)) {
rubble = 1 + rc.senseRubble(loc7) / 10;
if (rubble < minRubble) {
minRubble = rubble;
bestSpot = loc7;
}
}
return bestSpot;
}
}