Пример #1
0
  /**
   * Should be run in a while loop to ensure that all agents are ejected properly. eg: <code>
   *  while(ejectAgents()); </code>
   *
   * @return return whether an agent has been ejected.
   */
  public boolean ejectAgents() {

    for (int i = 0; i < agents.size(); i++) {
      if (agents.get(i).getComfort() < comfortThreshold) {
        // agents.get(i).resetLocation();
        agents.remove(i).setCaptured(false);
        // agents.get(i).setVelZero();
        // agents.remove(i);

        if (SecretAgents.SECRET_TRACING) Driver.trace("ejecting an agent");
        return true;
      }

      if (!agents.get(i).isCaptured()) {
        agents.remove(i);

        if (SecretAgents.SECRET_TRACING)
          Driver.trace("ejecting an agent that shouldnt be captured");
        return true;
      }
    }

    // Driver.trace(getClass(), "finished checking agents, found none to
    // eject");
    return false;
  }
Пример #2
0
 public boolean isAllComfortZero() {
   for (int i = 0; i < agents.size(); i++) {
     if (agents.get(i).getComfort() >= comfortThreshold) {
       if (SecretAgents.SECRET_TRACING)
         Driver.trace(
             "this well has at least one agent with more than " + comfortThreshold + " comfort");
       return false;
     }
   }
   if (SecretAgents.SECRET_TRACING)
     Driver.trace("this well has comforts all less than " + comfortThreshold);
   return true;
 }