示例#1
0
  private void justMakeReachable(Path path) throws SOSActionException {
    log.info("making reachable to " + path);
    if (!PoliceConstants.IS_NEW_CLEAR) {

      ArrayList<Blockade> blocks = new ArrayList<Blockade>();

      ArrayList<Blockade> blockadeEdge = reachableWithEdge.getBlockingBlockadeOfPath(path);
      blocks.addAll(blockadeEdge);
      //
      if (blocks.isEmpty()) {
        blocks.addAll(reachablityTool.getBlockingBlockadeOfPath(path));
        log.debug("clearableBlockadeToReachablebyReachablityTool is " + blocks);
        //	ArrayList<Blockade> blockadeEdge =
        // clearableBlockadeToFullReachable.getBlockingBlockadeOfPath(path);
      }
      log.debug("clearableBlockadeToReachableWithEdge is " + blocks);

      Blockade clearBlock = chooseBestBlockade(blocks);

      if (clearBlock != null) clear(clearBlock);
      else log.debug("No Blockade found---> we can move");
    } else {
      Point next = agent.degreeClearableToPoint.nextPointToClear(path, true, true);
      if (next != null) {
        //				log.warn("clear at" + next);
        clear(next);
      }
    }
  }
示例#2
0
 public void clearNearestBlockade() throws SOSActionException {
   log.info("clearing NearestBlockade");
   PriorityQueue<Blockade> blockadesInRange =
       model().getBlockadesInRange(agent.me().getX(), agent.me().getY(), agent.clearDistance);
   log.debug("Blockades in Range=" + blockadesInRange);
   Blockade selectedBlock = null;
   if (!blockadesInRange.isEmpty()) selectedBlock = blockadesInRange.remove();
   log.debug("best blockade:" + selectedBlock);
   if (selectedBlock != null) clear(selectedBlock);
 }
示例#3
0
 protected Blockade chooseFirstBlockade(List<Blockade> list) {
   log.debug("Choosing first blockade from list(" + list + ")");
   if (list == null) {
     log.warn("clearableBlockades is null!!! it shouldn't be happened!");
     return null;
   }
   for (Blockade blockade : list) {
     if (PoliceUtils.isValid(blockade)) {
       log.info(" first valid blockade is " + blockade);
       return blockade;
     }
   }
   log.info(" can't choos a blockade ");
   return null;
 }
示例#4
0
  private void justMakeReachableWithGoodReachablity(Path path) throws SOSActionException {
    log.info("making reachable with good reachablity to " + path);

    ArrayList<Blockade> blocks = reachablityTool.getBlockingBlockadeOfPath(path);
    log.debug("clearableBlockadeToReachablebyReachablityTool is " + blocks);
    ArrayList<Blockade> blockadeEdge = reachableWithEdge.getBlockingBlockadeOfPath(path);
    blocks.addAll(blockadeEdge);

    log.debug("clearableBlockadeToReachableWithEdge is " + blocks);

    Blockade clearBlock = chooseBestBlockade(blocks);

    if (clearBlock != null) clear(clearBlock);
    else if (clearBlock == null && !blocks.isEmpty()) {
      log.debug("No blockade is in range but the path is close!!! so move to close area");
      ArrayList<Pair<? extends Area, Point2D>> dest =
          new ArrayList<Pair<? extends Area, Point2D>>();
      for (Blockade blockade : blocks) {
        dest.add(blockade.getPositionPair());
      }
      path = agent.move.getPathToPoints(dest, PoliceMove.class);
      agent.move(path);
    } else log.debug("No Blockade found---> we can move");
  }
示例#5
0
 protected Blockade chooseBestBlockade(List<Blockade> list) {
   log.debug("Choosing best blockade from list(" + list + ")");
   if (list == null) {
     log.warn("clearableBlockades is null!!! it shouldn't be happened!");
     return null;
   }
   Blockade best = null;
   double bestValue = 0;
   for (Blockade blockade : list) {
     if (PoliceUtils.isValid(blockade)) {
       int value = computeBlockadeValue(blockade);
       if (value > bestValue) {
         bestValue = value;
         best = blockade;
       }
     }
   }
   log.info(" best blockade is " + best);
   return best;
 }
示例#6
0
 public void makeReachableTo(List<? extends StandardEntity> targets) throws SOSActionException {
   log.info("makeReachableTo " + targets);
   ArrayList<Pair<? extends Area, Point2D>> reachableAreas =
       new ArrayList<Pair<? extends Area, Point2D>>();
   for (StandardEntity entity : targets) {
     if (entity == null) {
       log.error("A null entity passed to makeReachableTo!!! WHY?");
       continue;
     }
     if (entity.getPositionPair() == null) {
       log.error("A null position entity(" + entity + ") passed to makeReachableTo!!! WHY?");
       continue;
     }
     if (!isReachableTo(entity)) {
       reachableAreas.addAll(PoliceUtils.getReachableAreasPair(entity));
     }
   }
   log.debug("reachableAreas = " + reachableAreas);
   if (!reachableAreas.isEmpty()) {
     moveToPoint(reachableAreas);
   }
 }