public SoldierRobot(RobotController rc) throws GameActionException { super(rc); NavSystem.init(this); if (Clock.getRoundNum() < 10) { soldierState = soldierState.SCOUTING; } else { ChannelType channel = EncampmentJobSystem.findJob(); if (channel != null) { unassigned = false; EncampmentJobSystem.updateJobTaken(); } // TODO: this will f**k up if we ever build artillery for non-nuke bots // LEARN THE STRATEGY Message message = BroadcastSystem.read(ChannelType.STRATEGY); if (message.isValid && message.body < Strategy.values().length && message.body >= 0) { strategy = Strategy.values()[message.body]; } else { // we couldn't read the strategy channel MapLocation[] alliedEncampmentSquares = rc.senseAlliedEncampmentSquares(); if (alliedEncampmentSquares.length == 0) { strategy = Strategy.ECON; } else { Robot robot = (Robot) rc.senseObjectAtLocation(alliedEncampmentSquares[0]); RobotInfo robotInfo = rc.senseRobotInfo(robot); if (robotInfo.type == RobotType.ARTILLERY) { strategy = Strategy.NUKE; } else { strategy = Strategy.ECON; } } } // rc.setIndicatorString(2, strategy.toString()); rallyPoint = findRallyPoint(); rSquared = DataCache.rushDistSquared / 4; initializeMining(); } }
/** * code to be used by capturers * * @throws GameActionException */ private void captureCode() throws GameActionException { if (!unassigned) { // if assigned to something EncampmentJobSystem.updateJobTaken(); } if (rc.isActive()) { if (rc.senseEncampmentSquare(currentLocation) && currentLocation.equals(EncampmentJobSystem.goalLoc)) { if (rc.getTeamPower() > rc.senseCaptureCost()) { rc.captureEncampment(EncampmentJobSystem.assignedRobotType); } } else { if (rc.senseNearbyGameObjects(Robot.class, 14, rc.getTeam().opponent()).length > 0) { unassigned = true; soldierState = SoldierState.FIGHTING; } if (NavSystem.navMode == NavMode.BFSMODE) { NavSystem.tryBFSNextTurn(); } else if (NavSystem.navMode == NavMode.GETCLOSER) { NavSystem.tryMoveCloser(); } else if (rc.getLocation().distanceSquaredTo(EncampmentJobSystem.goalLoc) <= 8) { NavSystem.setupGetCloser(EncampmentJobSystem.goalLoc); NavSystem.tryMoveCloser(); } else { NavSystem.moveCloserFavorNoMines(EncampmentJobSystem.goalLoc); // if (NavSystem.navMode == NavMode.NEUTRAL){ // NavSystem.setupSmartNav(EncampmentJobSystem.goalLoc); // NavSystem.followWaypoints(); // } else { // NavSystem.followWaypoints(); // } } } } }