public void tryToBuild() throws GameActionException { // try to build a robot Direction dl = randomDirection(); if (rc.getRoundNum() % 400 < 20 && rc.canBuild(dl, RobotType.SCOUT) && rc.isCoreReady()) { rc.build(dl, RobotType.SCOUT); } double prob = random.nextDouble(); int index = 0; RobotType robot; if (Utility.getClosestRound(zss) < 30) { while (prob > probabilitiesZ[index]) { index++; } robot = buildRobotTypes[index]; } else { while (prob > probabilities[index]) { index++; } robot = buildRobotTypes[index]; } for (Direction d : Direction.values()) { if (rc.canBuild(d, robot)) { if (rc.isCoreReady()) { rc.build(d, robot); int newid = rc.senseRobotAtLocation(rc.getLocation().add(d)).ID; MessageSignal teamFirstDirective = new MessageSignal(rc); if (leaderLocation != null) { teamFirstDirective.setCommand(leaderLocation, MessageSignal.CommandType.MOVE); } teamFirstDirective.send(2); } } } return; }
@Override public void prerun() throws GameActionException { if (rc.getRoundNum() % 5 == 0) { RobotInfo[] robotsNearMe = rc.senseNearbyRobots(); for (RobotInfo ri : robotsNearMe) { if (ri.team == Team.NEUTRAL && !neutralBotLocations.contains(ri.location)) { neutralBotLocations.add(ri.location); } } } getSignals(); if (!suppressSignals && heiarchy == -1 && (!sentGoal || rc.getRoundNum() - lastSentGoal > 10)) { MapLocation goal; MessageSignal goalDirection = new MessageSignal(rc); if (foundZombieDen) { goal = knownZombieDenLocations.get(knownZombieDenLocations.size() - 1); goalDirection.setCommand(goal, MessageSignal.CommandType.ATTACK); } else if (foundEnemyArchon) { goal = enemyArchon; goalDirection.setCommand(goal, MessageSignal.CommandType.ATTACK); } else { goal = rc.getLocation(); goalDirection.setCommand(goal, MessageSignal.CommandType.MOVE); } goalDirection.send(GameConstants.MAP_MAX_HEIGHT * GameConstants.MAP_MAX_HEIGHT); sentGoal = true; lastSentGoal = rc.getRoundNum(); rc.setIndicatorString(2, goal + ""); } else { rc.setIndicatorString(2, ""); super.prerun(); } }