diff --git a/templates/Attack.java.jinja2 b/templates/Attack.java.jinja2 index 169da67..fe939bd 100644 --- a/templates/Attack.java.jinja2 +++ b/templates/Attack.java.jinja2 @@ -28,8 +28,8 @@ public class Attack { public static void initTurn() throws GameActionException { myloc = rc.getLocation(); boolean shouldComputeReachSoon = false; - for (int i = Globals.enemies.length; --i >= 0; ) { - RobotInfo enemy = Globals.enemies[i]; + for (int i = Cache.enemies.length; --i >= 0; ) { + RobotInfo enemy = Cache.enemies[i]; switch (enemy.type) { case SOLDIER, MOPPER, SPLASHER: continue; default: @@ -110,8 +110,8 @@ public class Attack { public static boolean shouldSoldierMicro() throws GameActionException { - for (int i = Globals.enemies.length; --i >= 0; ) { - RobotInfo enemy = Globals.enemies[i]; + for (int i = Cache.enemies.length; --i >= 0; ) { + RobotInfo enemy = Cache.enemies[i]; switch (enemy.type) { case SOLDIER, MOPPER, SPLASHER: continue; default: if (canHitSoon(enemy.location)) return true; @@ -121,8 +121,8 @@ public class Attack { } public static void soldierTryAttack() throws GameActionException { - for (int i = Globals.enemies.length; --i >= 0;) { - RobotInfo enemy = Globals.enemies[i]; + for (int i = Cache.enemies.length; --i >= 0;) { + RobotInfo enemy = Cache.enemies[i]; switch (enemy.type) { case SOLDIER, SPLASHER, MOPPER: continue; default: { @@ -138,8 +138,8 @@ public class Attack { public static boolean shouldSplasherMicro() throws GameActionException { // Only activate micro if you can attack a tower. - for (int i = Globals.enemies.length; --i >= 0; ) { - RobotInfo enemy = Globals.enemies[i]; + for (int i = Cache.enemies.length; --i >= 0; ) { + RobotInfo enemy = Cache.enemies[i]; switch (enemy.type) { case SOLDIER, MOPPER, SPLASHER: continue; default: if (canHitSoon(enemy.location)) return true; @@ -200,7 +200,7 @@ public class Attack { {%- endfor -%} boolean friendNearby = false; - for (RobotInfo r: Globals.friends) { + for (RobotInfo r: Cache.friends) { if (r.type == UnitType.SOLDIER) { friendNearby = true; break; @@ -212,15 +212,15 @@ public class Attack { boolean actionReady = (rc.isActionReady() && (rc.getPaint() >= 5) && !shouldWaitForFriend); int cooldownTurns = rc.getActionCooldownTurns(); {# {% debug('actionReady', 'cooldownTurns') %} #} - for (int i = Globals.friends.length; --i >= 0; ) { - RobotInfo robot = Globals.friends[i]; + for (int i = Cache.friends.length; --i >= 0; ) { + RobotInfo robot = Cache.friends[i]; {% for i in range(9) -%} {{ addAlly(type, i) | indent(8) -}} {% endfor %} } - for (int i = Globals.enemies.length; --i >= 0; ) { - RobotInfo robot = Globals.enemies[i]; + for (int i = Cache.enemies.length; --i >= 0; ) { + RobotInfo robot = Cache.enemies[i]; {% for i in range(9) -%} {{ addEnemy(type, i) | indent(8) -}} {% endfor %} diff --git a/templates/Cache.java.jinja2 b/templates/Cache.java.jinja2 new file mode 100644 index 0000000..acf3b7f --- /dev/null +++ b/templates/Cache.java.jinja2 @@ -0,0 +1,22 @@ +package current; +import java.util.Random; +import battlecode.common.*; + +public class Cache { + public static RobotController rc; + public static RobotInfo[] friends; + public static RobotInfo[] enemies; + public static MapLocation[] ruins; + public static MapInfo[] mapInfos; + + public static void init(RobotController rc) { + Cache.rc = rc; + } + + public static void run() throws GameActionException { + friends = rc.senseNearbyRobots(-1, rc.getTeam()); + enemies = rc.senseNearbyRobots(-1, rc.getTeam().opponent()); + ruins = rc.senseNearbyRuins(-1); + mapInfos = rc.senseNearbyMapInfos(-1); + } +} \ No newline at end of file diff --git a/templates/Comms.java.jinja2 b/templates/Comms.java.jinja2 index 42b8cde..183061b 100644 --- a/templates/Comms.java.jinja2 +++ b/templates/Comms.java.jinja2 @@ -2,12 +2,18 @@ package current; import battlecode.common.*; public class Comms { + public static MapLocation myloc; public static RobotController rc; public static void init(RobotController rc) throws GameActionException { Comms.rc = rc; } + public static int totalHarassersMade = 0; public static void run() throws GameActionException { + myloc = rc.getLocation(); + if (rc.getRoundNum() % 20 == 0) { + totalHarassersMade = 0; + } updateSym(); broadcastSym(); } @@ -19,30 +25,63 @@ public class Comms { SymmetryChecker.RSYM &= (msg & 1); SymmetryChecker.HSYM &= ((msg & 2) >> 1); SymmetryChecker.VSYM &= ((msg & 4) >> 2); + if (((msg & 8) >> 3) != 0) + Harass.isHarasser = true; } } public static void broadcastSym() throws GameActionException { + int harassersMade = 0; int R = SymmetryChecker.RSYM; int H = SymmetryChecker.HSYM; int V = SymmetryChecker.VSYM; int send = R + 2 * H + 4 * V; + int harassMessage = send + 8; + boolean shouldMakeHarassers = shouldMakeHarassers(); if (Globals.isTower(rc.getType())) { if (rc.canBroadcastMessage()) { rc.broadcastMessage(send); } - for (int i = Globals.friends.length; --i >= 0;) { - if (rc.canSendMessage(Globals.friends[i].location, send)) { - rc.sendMessage(Globals.friends[i].location, send); + for (int i = Cache.friends.length; --i >= 0;) { + RobotInfo friend = Cache.friends[i]; + if ((shouldMakeHarassers) + && (friend.type == UnitType.SOLDIER) + && (myloc.distanceSquaredTo(friend.location) <= 9) + && (harassersMade < 2)) { + if (rc.canSendMessage(friend.location, harassMessage)) { + rc.sendMessage(friend.location, harassMessage); + ++harassersMade; + } + } else { + if (rc.canSendMessage(friend.location, send)) { + rc.sendMessage(friend.location, send); + } } } } else { - for (int i = Globals.friends.length; --i >= 0;) if (Globals.isTower(Globals.friends[i].getType())) { - if (rc.canSendMessage(Globals.friends[i].location, send)) { - rc.sendMessage(Globals.friends[i].location, send); + for (int i = Cache.friends.length; --i >= 0;) if (Globals.isTower(Cache.friends[i].getType())) { + if (rc.canSendMessage(Cache.friends[i].location, send)) { + rc.sendMessage(Cache.friends[i].location, send); } } } } + + + public static boolean shouldMakeHarassers() throws GameActionException { + if (rc.getRoundNum() % 20 < 15) return false; + if (totalHarassersMade >= 2) return false; + int soldierCount = 0; + for (int i = Cache.friends.length; --i >= 0;) { + RobotInfo r = Cache.friends[i]; + if ((r.type == UnitType.SOLDIER) + && (rc.canSendMessage(r.location, 0)) + && (myloc.distanceSquaredTo(r.location) <= 9)) { + ++soldierCount; + } + } + if (soldierCount >= 2) return true; + return false; + } } \ No newline at end of file diff --git a/templates/Globals.java.jinja2 b/templates/Globals.java.jinja2 index bf631b3..3895636 100644 --- a/templates/Globals.java.jinja2 +++ b/templates/Globals.java.jinja2 @@ -17,11 +17,7 @@ public class Globals { born = rc.getRoundNum(); } - public static RobotInfo[] friends; - public static RobotInfo[] enemies; public static void run() throws GameActionException { - friends = rc.senseNearbyRobots(-1, rc.getTeam()); - enemies = rc.senseNearbyRobots(-1, rc.getTeam().opponent()); roundNum = rc.getRoundNum(); updateTowerTracker(); } diff --git a/templates/Harass.java.jinja2 b/templates/Harass.java.jinja2 new file mode 100644 index 0000000..df022d7 --- /dev/null +++ b/templates/Harass.java.jinja2 @@ -0,0 +1,112 @@ +package current; +import battlecode.common.*; + +public class Harass { + public static RobotInfo friend = null; + public static RobotController rc; + public static boolean wasHarasser = false; + public static boolean isHarasser = false; + public static boolean reachedH = false; + public static boolean reachedR = false; + public static boolean reachedV = false; + public static boolean seenCenter = false; + public static MapLocation center = null; + public static void init(RobotController rc) throws GameActionException { + Harass.rc = rc; + center = new MapLocation(rc.getMapWidth() / 2, rc.getMapHeight() / 2); + } + + public static void initTurn() throws GameActionException { + if (!isHarasser && !wasHarasser) { + isHarasser = decideHarasser(); + if (isHarasser) wasHarasser = true; + } + + // This should be static... + friend = null; + MapLocation myloc = rc.getLocation(); + for (RobotInfo r: Cache.friends) { + if (r.type == UnitType.SOLDIER) { + if (r.location.distanceSquaredTo(myloc) <= 36) { + friend = r; + break; + } + } + } + } + + public static boolean decideHarasser() throws GameActionException { + if (rc.getRoundNum() >= 50) return false; + if (rc.getRoundNum() > 5) return false; + if (RefuelManager.home == null) return false; + if (!rc.canSenseLocation(RefuelManager.home)) return false; + RobotInfo r = rc.senseRobotAtLocation(RefuelManager.home); + if (r == null) return false; + if (r.getType() == UnitType.LEVEL_ONE_PAINT_TOWER) return true; + if (r.getType() == UnitType.LEVEL_TWO_PAINT_TOWER) return true; + return false; + } + + public static boolean shouldHarass() { + // return (isHarasser) && (friend != null); + return isHarasser; + } + + public static void harass() throws GameActionException { + MapLocation myloc = rc.getLocation(); + int sym = SymmetryChecker.HSYM + SymmetryChecker.RSYM + SymmetryChecker.VSYM; + if (sym > 1 && !seenCenter) { + if (rc.getLocation().distanceSquaredTo(center) <= 9) seenCenter = true; + else { + Pathing.pathTo(center); + return; + } + } + + int closest = 1000000000; + MapLocation best = null; + MapLocation target; + MapLocation ruin = RefuelManager.firstHome; + if (SymmetryChecker.RSYM != 0 && !reachedR) { + target = new MapLocation(rc.getMapWidth() - ruin.x - 1, rc.getMapHeight() - ruin.y - 1); + if (myloc.distanceSquaredTo(target) <= 9) { + reachedR = true; + } + else { + int d = rc.getLocation().distanceSquaredTo(target); + if (d < closest) { + best = target; + closest = d; + } + } + } + if (SymmetryChecker.HSYM != 0 && !reachedH) { + target = new MapLocation(ruin.x, rc.getMapHeight() - ruin.y - 1); + if (myloc.distanceSquaredTo(target) <= 9) { + reachedH = true; + } + else { + int d = rc.getLocation().distanceSquaredTo(target); + if (d < closest) { + best = target; + closest = d; + } + } + } + if (SymmetryChecker.VSYM != 0 && !reachedV) { + target = new MapLocation(rc.getMapWidth() - ruin.x - 1, ruin.y); + if (myloc.distanceSquaredTo(target) <= 9) { + reachedV = true; + } + else { + int d = rc.getLocation().distanceSquaredTo(target); + if (d < closest) { + best = target; + closest = d; + } + } + } + if (best != null) Pathing.pathTo(best); + else isHarasser = false; + } +} \ No newline at end of file diff --git a/templates/Mopper.java.jinja2 b/templates/Mopper.java.jinja2 index 00f0f6a..c937dcc 100644 --- a/templates/Mopper.java.jinja2 +++ b/templates/Mopper.java.jinja2 @@ -27,7 +27,7 @@ public class Mopper { public static MapLocation mopTarget = null; public static void computeMopTarget() throws GameActionException { RobotInfo enemyTower = null; - MapLocation[] ruins = rc.senseNearbyRuins(-1); + MapLocation[] ruins = Cache.ruins; for (MapLocation loc: ruins) { RobotInfo r = rc.senseRobotAtLocation(loc); if (r != null && r.team != rc.getTeam()) { @@ -115,7 +115,7 @@ public class Mopper { public static void initTurn() throws GameActionException { myloc = rc.getLocation(); myPaint = rc.getPaint(); - near = rc.senseNearbyMapInfos(); + near = Cache.mapInfos; computeMopTarget(); RefuelManager.setHome(); boolean lowHealth = (myPaint <= (paintCapacity >> 2)); diff --git a/templates/MopperAttack.java.jinja2 b/templates/MopperAttack.java.jinja2 index 06ca2c3..53a69c7 100644 --- a/templates/MopperAttack.java.jinja2 +++ b/templates/MopperAttack.java.jinja2 @@ -22,9 +22,9 @@ public class MopperAttack { } public static boolean shouldMopperMicro() throws GameActionException { - for (int i = Globals.enemies.length; --i >= 0; ) { - if (Globals.enemies[i].paintAmount == 0) continue; - switch (Globals.enemies[i].type) { + for (int i = Cache.enemies.length; --i >= 0; ) { + if (Cache.enemies[i].paintAmount == 0) continue; + switch (Cache.enemies[i].type) { case SOLDIER, MOPPER, SPLASHER: return true; default: return false; } @@ -34,7 +34,7 @@ public class MopperAttack { public static void mopperTryAttack() throws GameActionException { if ((rc.getPaint() < (UnitType.MOPPER.paintCapacity >> 1)) - || (Globals.enemies.length == 1)) { + || (Cache.enemies.length == 1)) { mopperHealAttack(); } else { mopperMopAttack(); @@ -42,11 +42,11 @@ public class MopperAttack { } public static void mopperHealAttack() throws GameActionException { - for (int i = Globals.enemies.length; --i >= 0; ) { - switch (Globals.enemies[i].type) { + for (int i = Cache.enemies.length; --i >= 0; ) { + switch (Cache.enemies[i].type) { case SOLDIER, MOPPER, SPLASHER: { - if (rc.canAttack(Globals.enemies[i].location)) { - rc.attack(Globals.enemies[i].location); + if (rc.canAttack(Cache.enemies[i].location)) { + rc.attack(Cache.enemies[i].location); return; } } @@ -117,8 +117,8 @@ public class MopperAttack { {%- endfor -%} boolean shouldChase = true; - for (int i = Globals.enemies.length; --i >= 0; ) { - RobotInfo robot = Globals.enemies[i]; + for (int i = Cache.enemies.length; --i >= 0; ) { + RobotInfo robot = Cache.enemies[i]; switch (robot.type) { case MOPPER -> shouldChase = false; default -> {} @@ -126,15 +126,15 @@ public class MopperAttack { } boolean actionReady = rc.isActionReady() || shouldChase; - for (int i = Globals.friends.length; --i >= 0; ) { - RobotInfo robot = Globals.friends[i]; + for (int i = Cache.friends.length; --i >= 0; ) { + RobotInfo robot = Cache.friends[i]; {% for i in range(9) -%} {{ addAlly(i) | indent(8) -}} {% endfor %} } - for (int i = Globals.enemies.length; --i >= 0; ) { - RobotInfo robot = Globals.enemies[i]; + for (int i = Cache.enemies.length; --i >= 0; ) { + RobotInfo robot = Cache.enemies[i]; {% for i in range(9) -%} {{ addEnemy(i) | indent(8) -}} {% endfor %} diff --git a/templates/RefuelManager.java.jinja2 b/templates/RefuelManager.java.jinja2 index 8cf2c54..5a4f363 100644 --- a/templates/RefuelManager.java.jinja2 +++ b/templates/RefuelManager.java.jinja2 @@ -50,7 +50,7 @@ public class RefuelManager { RobotInfo robot = rc.senseRobotAtLocation(home); homeState = getTowerState(robot); } - MapLocation[] ruins = rc.senseNearbyRuins(-1); + MapLocation[] ruins = Cache.ruins; for (MapLocation ruin: ruins) { RobotInfo robot = rc.senseRobotAtLocation(ruin); if (robot != null && robot.team != rc.getTeam()) continue; diff --git a/templates/RobotPlayer.java.jinja2 b/templates/RobotPlayer.java.jinja2 index b241eb5..c25e142 100644 --- a/templates/RobotPlayer.java.jinja2 +++ b/templates/RobotPlayer.java.jinja2 @@ -4,6 +4,7 @@ public class RobotPlayer { @SuppressWarnings("unused") public static void run(RobotController rc) throws GameActionException { {# This is technically unnecessary but this is the easiest way to get a reference to the controller #} + Cache.init(rc); Globals.init(rc); Mopper.init(rc); Pathing.init(rc); @@ -18,14 +19,17 @@ public class RobotPlayer { RefuelManager.init(rc); TowerBuild.init(rc); SquareManager.init(rc); + Harass.init(rc); Comms.init(rc); {%- macro generate_main_loop(classname) -%} while (true) { try { + Cache.run(); TileLoader.load(); Globals.run(); SquareManager.run(); Attack.initTurn(); + Harass.initTurn(); {{ classname }}.run(); SymmetryChecker.run(); Comms.run(); diff --git a/templates/Soldier.java.jinja2 b/templates/Soldier.java.jinja2 index 5c1e809..68617c1 100644 --- a/templates/Soldier.java.jinja2 +++ b/templates/Soldier.java.jinja2 @@ -21,14 +21,6 @@ public class Soldier { public static boolean moved = false; public static MapLocation returnLoc = null; public static boolean reallyGoing = false; - public static boolean seenCenter = false; - public static boolean harrasser = false; - public static MapLocation center = null; - public static boolean reachedH = false; - public static boolean reachedR = false; - public static boolean reachedV = false; - public static boolean wasHarrasser = false; - public static MapLocation chunkGoal = null; public static int[] dy = {0, 0, 4, -4}; @@ -40,7 +32,6 @@ public class Soldier { public static void init(RobotController rc) { Soldier.rc = rc; resourcePat = rc.getResourcePattern(); - center = new MapLocation(rc.getMapWidth() / 2, rc.getMapHeight() / 2); } public static boolean shouldUseSecond(MapLocation loc, MapLocation center) throws GameActionException { @@ -157,7 +148,7 @@ public class Soldier { else Pathing.pathTo(chunkGoal); } - if (Globals.enemies.length > 0) return; + if (Cache.enemies.length > 0) return; //this just checks that nothing is like directly in the way for (int i = 3; --i >= -2; ){ @@ -284,12 +275,13 @@ public class Soldier { } public static void initTurn() throws GameActionException { - near = rc.senseNearbyMapInfos(); + near = Cache.mapInfos; myloc = rc.getLocation(); myPaint = rc.getPaint(); moved = false; RefuelManager.setHome(); + Harass.initTurn(); boolean lowHealth = (myPaint <= (paintCapacity >> 2)); if (lowHealth != shouldGoHome) { shouldGoHome = lowHealth; @@ -297,24 +289,6 @@ public class Soldier { if (buildTower != null && shouldGoHome) returnLoc = buildTower; RefuelManager.reset(); } - - if (!harrasser && !wasHarrasser) { - harrasser = isHarasser(); - if (harrasser) wasHarrasser = true; - } - } - - public static boolean isHarasser() throws GameActionException { - if (Math.max(rc.getMapHeight(), rc.getMapWidth()) > 40) return false; - if (rc.getRoundNum() < 50) { - if (rc.getRoundNum() > 2) return false; - if (RefuelManager.home == null) return false; - if (!rc.canSenseLocation(RefuelManager.home)) return false; - RobotInfo r = rc.senseRobotAtLocation(RefuelManager.home); - if (r == null || r.getType() != UnitType.LEVEL_TWO_PAINT_TOWER) return false; - return true; - } - else return false; } public static boolean getGoodColor(MapLocation m) throws GameActionException { @@ -362,65 +336,9 @@ public class Soldier { } } } - - public static void goHarrass() throws GameActionException { - int sym = SymmetryChecker.HSYM + SymmetryChecker.RSYM + SymmetryChecker.VSYM; - if (sym > 1 && !seenCenter) { - if (rc.getLocation().distanceSquaredTo(center) <= 9) seenCenter = true; - else { - Pathing.pathTo(center); - return; - } - } - - int closest = 1000000000; - MapLocation best = null; - MapLocation target; - MapLocation ruin = RefuelManager.firstHome; - if (SymmetryChecker.RSYM != 0 && !reachedR) { - target = new MapLocation(rc.getMapWidth() - ruin.x - 1, rc.getMapHeight() - ruin.y - 1); - if (myloc.distanceSquaredTo(target) <= 9) { - reachedR = true; - } - else { - int d = rc.getLocation().distanceSquaredTo(target); - if (d < closest) { - best = target; - closest = d; - } - } - } - if (SymmetryChecker.HSYM != 0 && !reachedH) { - target = new MapLocation(ruin.x, rc.getMapHeight() - ruin.y - 1); - if (myloc.distanceSquaredTo(target) <= 9) { - reachedH = true; - } - else { - int d = rc.getLocation().distanceSquaredTo(target); - if (d < closest) { - best = target; - closest = d; - } - } - } - if (SymmetryChecker.VSYM != 0 && !reachedV) { - target = new MapLocation(rc.getMapWidth() - ruin.x - 1, ruin.y); - if (myloc.distanceSquaredTo(target) <= 9) { - reachedV = true; - } - else { - int d = rc.getLocation().distanceSquaredTo(target); - if (d < closest) { - best = target; - closest = d; - } - } - } - if (best != null) Pathing.pathTo(best); - else harrasser = false; - } public static void runTurn() throws GameActionException { + rc.setIndicatorString("Harasser := " + Harass.isHarasser); if (Attack.shouldSoldierMicro()) { rc.setIndicatorString("Attacking"); Attack.soldierAttackMicro(); @@ -428,7 +346,7 @@ public class Soldier { } // Opportunistically steal paint from adjacent towers. - MapLocation[] ruins = rc.senseNearbyRuins(-1); + MapLocation[] ruins = Cache.ruins; for (MapLocation tower: ruins) { RobotInfo r = rc.senseRobotAtLocation(tower); if (r == null || r.team != rc.getTeam()) continue; @@ -473,23 +391,26 @@ public class Soldier { RefuelManager.refuel(); return; } - else if (rc.getNumberTowers() < 25 && markedResource == null) { if (buildTower != null) { TowerBuild.makeTower(buildTower); return; } } - else if (harrasser) { - goHarrass(); + + if (Harass.shouldHarass()) { + rc.setIndicatorString("Harassing"); + Harass.harass(); return; } + if (returnLoc != null) { if (myloc.distanceSquaredTo(returnLoc) <= 5) { returnLoc = null; } else { Pathing.pathTo(returnLoc); + return; } } @@ -504,7 +425,7 @@ public class Soldier { if (moved) return; - //rc.setIndicatorString("Exploring"); + rc.setIndicatorString("Exploring"); Explore.explore(near); } @@ -512,7 +433,7 @@ public class Soldier { // Lay paint where I am first. myloc = rc.getLocation(); - if (canChangeColor(myloc) && rc.canAttack(myloc) && rc.getPaint() >= 50 && okToTile(myloc) && !harrasser){ + if (canChangeColor(myloc) && rc.canAttack(myloc) && rc.getPaint() >= 50 && okToTile(myloc) && !Harass.isHarasser) { rc.attack(myloc, getGoodColor(myloc)); } diff --git a/templates/TileLoader.java.jinja2 b/templates/TileLoader.java.jinja2 index c8ce1f2..33ce460 100644 --- a/templates/TileLoader.java.jinja2 +++ b/templates/TileLoader.java.jinja2 @@ -64,7 +64,7 @@ public class TileLoader { int myY = rc.getLocation().y; int myX = rc.getLocation().x; long lastSquare = (1L << (rc.getMapWidth() - 1)); - MapLocation[] ruins = rc.senseNearbyRuins(-1); + MapLocation[] ruins = Cache.ruins; for (int i = ruins.length; --i >= 0; ) { MapLocation ruin = ruins[i]; switch (ruin.y) { @@ -91,7 +91,7 @@ public class TileLoader { // We measure from the top right corner since that will always // Have non-negative coordinates, meaning this hashCode magic will make sense. offset = rc.getLocation().translate({{CORNER_OFFSET}}, {{CORNER_OFFSET}}).hashCode(); - mapInfos = rc.senseNearbyMapInfos(); + mapInfos = Cache.mapInfos; // The seen masks are known statically. local_seen8 = 0b001111100; diff --git a/templates/Tower.java.jinja2 b/templates/Tower.java.jinja2 index 84b9526..1857960 100644 --- a/templates/Tower.java.jinja2 +++ b/templates/Tower.java.jinja2 @@ -27,7 +27,7 @@ public class Tower { myloc = rc.getLocation(); threatLoc = null; shouldDefend = false; - for (RobotInfo r: Globals.enemies) { + for (RobotInfo r: Cache.enemies) { switch (r.type) { case SOLDIER, SPLASHER: { threatLoc = r.location; @@ -74,7 +74,7 @@ public class Tower { public static void runTurn() throws GameActionException { towerTryAttack(); - if (Globals.enemies.length > 0) + if (Cache.enemies.length > 0) enemyLastSeen = rc.getRoundNum(); UnitType t; @@ -148,8 +148,8 @@ public class Tower { int smallestSoldierHealth = 100000000; MapLocation bestNonSoldierLoc = null; int smallestNonSoldierHealth = 10000000; - for (int i = Globals.enemies.length; --i >= 0;) { - RobotInfo enemy = Globals.enemies[i]; + for (int i = Cache.enemies.length; --i >= 0;) { + RobotInfo enemy = Cache.enemies[i]; if (enemy.paintAmount == 0) continue; MapLocation loc = enemy.location; if (rc.canAttack(loc)) {