private static void expand() throws GameActionException { // rallyPoint = findClosestLocation(rc.senseAllEncampmentSquares()); if (!localscan) { rallyPoint = findClosestEmptyCamp(); } if (rc.getLocation().distanceSquaredTo(rallyPoint) < 1) // if we are at the location of the rally point { if (!localscan) { rallyPoint = findFurthestLocalCamp(); localscan = true; } } if (rc.getLocation().distanceSquaredTo(rallyPoint) < 1) // if we are at the location of the rally point { if (rc.isActive()) // if we are allowed to capture { if (rc.senseCaptureCost() + 1.8 * getNumberOfAlliedRobosAfterMe() < rc.getTeamPower()) // if we have enough power to capture { int readIn = rc.readBroadcast(Constants.campChannel); if (readIn == Constants.campGen) { rc.broadcast(Constants.campChannel, Constants.campGenInProduction); rc.captureEncampment(RobotType.GENERATOR); } else if (readIn == Constants.campGenInProduction) { rc.captureEncampment(RobotType.SUPPLIER); } else if (readIn == Constants.campSupplier) { rc.captureEncampment(RobotType.SUPPLIER); } else // TODO: transmissions may be being scrambled, for now just make supplier { rc.captureEncampment(RobotType.SUPPLIER); } } } } else if (rc.senseNearbyGameObjects(Robot.class, rallyPoint, 0, rc.getTeam()).length > 0) // if there is an allied robot on our rally point { rallyPoint = findClosestEmptyCamp(); if (rallyPoint == null) { rallyPoint = findRallyPoint(); } goToLocation(rallyPoint); } else { goToLocation(rallyPoint); } }
public static void expandIndividual() throws GameActionException { MapLocation expandLocation = new MapLocation( rc.readBroadcast(Constants.singleExpandXChannel), rc.readBroadcast(Constants.singleExpandYChannel)); rc.broadcast(Constants.commandChannel, Constants.commandRally); while (true) { if (rc.getLocation().distanceSquaredTo(expandLocation) < 1) // if we are at the location of the rally point { if (rc.isActive()) // if we are allowed to capture { if (rc.senseCaptureCost() + 1.8 * getNumberOfAlliedRobosAfterMe() < rc.getTeamPower()) // if we have enough power to capture { int readIn = rc.readBroadcast(Constants.campChannel); if (readIn == Constants.campGen) { rc.broadcast(Constants.campChannel, Constants.campGenInProduction); rc.captureEncampment(RobotType.GENERATOR); } else if (readIn == Constants.campGenInProduction) { rc.captureEncampment(RobotType.SUPPLIER); } else if (readIn == Constants.campSupplier) { rc.captureEncampment(RobotType.SUPPLIER); } else // TODO: transmissions may be being scrambled, for now just make supplier { rc.captureEncampment(RobotType.SUPPLIER); } break; } } } else if (rc.senseNearbyGameObjects(Robot.class, expandLocation, 0, rc.getTeam()).length > 0) // if there is an allied robot on our rally point { expandLocation = findClosestEmptyCamp(); if (expandLocation == null) { expandLocation = findRallyPoint(); } goToLocation(expandLocation); } else { goToLocation(expandLocation); } rc.yield(); } }