Skip to content

Commit e230ebd

Browse files
feat: locks on to closest ruin, found actual way to check if ruin is finished tower
1 parent f0336cd commit e230ebd

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

java/src/s1/RobotPlayer.java

+8-6
Original file line numberDiff line numberDiff line change
@@ -233,19 +233,21 @@ public static boolean buildRuins(RobotController rc) throws GameActionException
233233
MapInfo[] nearbyTiles = rc.senseNearbyMapInfos();
234234
// Search for a nearby ruin to complete.
235235
MapInfo curRuin = null;
236+
int curDist = 100000000;
236237
for (MapInfo tile : nearbyTiles) {
237-
if (tile.hasRuin()) {
238-
curRuin = tile;
238+
// Make sure the ruin is not already complete (has no tower on it)
239+
if (tile.hasRuin() && rc.senseRobotAtLocation(tile.getMapLocation()) == null) {
240+
int checkDist = tile.getMapLocation().distanceSquaredTo(rc.getLocation());
241+
if (checkDist < curDist) {
242+
curDist = checkDist;
243+
curRuin = tile;
244+
}
239245
}
240246
}
241247

242248
if (curRuin != null) {
243249
MapLocation targetLoc = curRuin.getMapLocation();
244250
Direction dir = rc.getLocation().directionTo(targetLoc);
245-
boolean isActuallyTower = rc.canTransferPaint(targetLoc, -1);
246-
if (isActuallyTower) {
247-
return false;
248-
}
249251
if (rc.canMove(dir))
250252
rc.move(dir);
251253
// Mark the pattern we need to draw to build a tower here if we haven't already.

0 commit comments

Comments
 (0)