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 run() throws GameActionException {
    // try to heal nearby robots
    RobotInfo[] nearbyAllies = rc.senseNearbyRobots(2, myTeam);
    RobotInfo friendWithLowestHP = Utility.getRobotWithLowestHP(nearbyAllies);
    if (rc.isCoreReady() && friendWithLowestHP != null) {
      if (friendWithLowestHP.type != RobotType.ARCHON) {
        rc.repair(friendWithLowestHP.location);
      }
    }
    if (goalLocation != null) {

      if (rc.canSense(goalLocation)) {
        goalLocation = null;
      }
      if (Utility.getClosestRound(zss) - rc.getRoundNum() > 50 && rc.getTeamParts() > 200) {
        tryToBuild();
      } else if (rc.isCoreReady() && goalLocation != null) {
        BugNav.goTo(goalLocation);
      }
    }

    // try to activate neutral units
    MapLocation closestNeutral = Utility.closestLocation(neutralBotLocations, rc.getLocation());
    if (closestNeutral != null) {
      rc.setIndicatorString(2, "Finding Neutal");
      if (rc.canSense(closestNeutral)
          && (rc.senseRobotAtLocation(closestNeutral) == null
              || rc.senseRobotAtLocation(closestNeutral).team != Team.NEUTRAL)) {
        neutralBotLocations.remove(closestNeutral);
      } else if (rc.getLocation().distanceSquaredTo(closestNeutral) < 2) {
        if (rc.isCoreReady()) {
          rc.activate(closestNeutral);
          neutralBotLocations.remove(closestNeutral);
        }
      } else if (rc.isCoreReady() && rc.canMove(rc.getLocation().directionTo(closestNeutral))) {
        tryToMove(rc.getLocation().directionTo(closestNeutral));
      }
    }

    RobotInfo[] enemies =
        rc.senseHostileRobots(rc.getLocation(), RobotType.ARCHON.sensorRadiusSquared);
    if (enemies.length > 3) {
      tryToRetreat(enemies);
    }

    tryToBuild();
    if (enemies.length > 0) {
      tryToRetreat(enemies);
      suppressSignals = true;
      return;
    } else {
      defaultBehavior();
    }
    suppressSignals = false;
  }