static void spawnRobot(RobotController rc) throws GameActionException { if (rc.senseRobotCount() < GameConstants.MAX_ROBOTS && rc.isActive()) { int squad = nextSquadNum(rc); boolean spawnSuccess = false; Robot[] allies = rc.senseNearbyGameObjects( Robot.class, RobotType.SOLDIER.attackRadiusMaxSquared / 2, team); if (squad > 10) { spawnSuccess = tryToSpawn(rc, 1); if (spawnSuccess) { int j = Util.assignmentToInt(squad, 1); rc.broadcast(Util.spawnchannel, j); // System.out.println("Spawned an attacker: " + j); } } else if (squad < 11) { spawnSuccess = tryToSpawn(rc, 0); if (spawnSuccess) { int j = Util.assignmentToInt(squad, 0); rc.broadcast(Util.spawnchannel, j); // System.out.println("Spawned a defender: " + j); } } // Increase the squad member count by one if (spawnSuccess) { rc.broadcast(squad, rc.readBroadcast(squad) + 10000); } } }
public static void tryToSpawn() throws GameActionException { if (rc.isActive() && rc.senseRobotCount() < GameConstants.MAX_ROBOTS) { for (int i = 0; i < 8; i++) { Direction trialDir = allDirections[i]; if (rc.canMove(trialDir)) { rc.spawn(trialDir); break; } } } }
static boolean tryToSpawn(RobotController rc, int type) throws GameActionException { if (rc.isActive() && rc.senseRobotCount() < GameConstants.MAX_ROBOTS) { Direction dir = Util.findDirToMove(rc); if (dir != null) { rc.spawn(dir); robotTypeCount[type]++; return true; } } return false; }
public void spawnRobot() throws GameActionException { if (rc.senseRobotCount() < GameConstants.MAX_ROBOTS) { if (rc.canMove(directionToEnemy)) { rc.spawn(directionToEnemy); } else { for (Direction d : Navigation.DIRECTIONS) { // MapLocation loc = hqLocation.add(d); if (rc.canMove(d)) { rc.spawn(d); break; } } } } }