public void checkKnownTowerLocations() { Robot robot = null; ArrayList<MapLocation> towers = sensing.senseKnownAlliedTowerLocations(); if (towers.size() > 0) { // we remember that there used to be a tower here, so lets try going there. once we get // there, we can ask again MapLocation closest = navigation.findClosest(towers); if (controller.canSenseSquare(closest) && closest != null) { try { robot = controller.senseGroundRobotAtLocation(closest); } catch (Exception e) {; } if (robot == null) { int id = sensing.knownAlliedTowerIDs.remove(closest.getX() + "," + closest.getY()); sensing.knownAlliedTowerLocations.remove(id); } } navigation.changeToLocationGoal(closest, true); setGoal(Goal.movingToPreviousTowerLocation); return; } spawnTeleporter(); }
public void placeTower() { idealTowerSpawnLocations = null; turnsWaitedForTowerSpawnLocationMessage = 0; towerSpawnFromLocation = null; towerSpawnLocation = null; turnsWaitedForMove = 0; ArrayList<MapLocation> towers; // //sensing.senseAlliedTeleporters(); int towerID = BroadcastMessage.everyone; MapLocation location; Robot robot; towers = sensing.senseAlliedTowerLocations(); if (towers.size() > 0) { // no teles in range, but there are other towers. they should be talking to the tele and // should know the status of where to build try { location = navigation.findClosest(towers); if (controller.canSenseSquare(location) && location != null) { robot = controller.senseGroundRobotAtLocation(location); if (robot != null) towerID = robot.getID(); else pa("cannot sense robot at " + location); } messaging.sendTowerBuildLocationRequest(towerID); setGoal(Goal.askingForTowerLocation); return; } catch (Exception e) { pa("----Caught exception in place tower. " + e.toString()); } } // no towers in range, lets just ask everyone messaging.sendTowerBuildLocationRequest(BroadcastMessage.everyone); setGoal(Goal.askingForTowerLocation); return; }