예제 #1
0
  @Override
  public Mission getMission(Sergeant s) {
    if (this.isEmpty()) return null;

    PriorityBlockingQueue<Mission> relevantQueue;
    Vector<Mission> temp = new Vector<Mission>();

    if (s.getPriority().equals(Sergeant.SHORTEST)) relevantQueue = this.minLength;
    else if (s.getPriority().equals(Sergeant.LONGEST)) relevantQueue = this.maxLength;
    else if (s.getPriority().equals(Sergeant.MINITEMS)) relevantQueue = this.minItems;
    else relevantQueue = this.maxItems;
    while (!relevantQueue.isEmpty()) {
      Mission candidate = relevantQueue.poll();
      temp.add(candidate);
      WarSim.LOG.fine("Testing Mission " + candidate.getName() + "(" + candidate.getSkill() + ")");
      if (s.getSkills().contains(candidate.getSkill())) {
        for (Mission tm : temp) relevantQueue.put(tm);
        return candidate;
      } else
        WarSim.LOG.fine(
            "The sergeant " + s.getName() + " can't execute mission " + candidate.getName());
    }
    for (Mission tm : temp) relevantQueue.put(tm);

    return null;
  }
예제 #2
0
 public void compute() {
   /* Tant qu'il reste des points dans le tas */
   while (!q.isEmpty()) {
     /* Extraire le point le plus proche de l'arrivée */
     try {
       current = q.take();
       // update();
       /* appelle les obs */
       /* Trouver les voisins & MAJ -> dans une autre méthode */
       trouverVoisinEtMaj(current);
     } catch (InterruptedException e) {
       e.printStackTrace();
     }
   }
 }