示例#1
0
  public Pair<Area, Point2D> getEntrancePoint(Area dest) {
    if (dest == null) {
      log.error("why try to move to " + dest + "?????");
      return null;
    }
    Path path = agent.move.getPathTo(Collections.singleton(dest), PoliceMove.class);
    ArrayList<EntityID> pathArray = path.getIds();
    if (pathArray.isEmpty()) {
      log.error("path is empty. why????");
      return null;
    }

    Edge inComingEdge;
    if (pathArray.size() == 1) {
      inComingEdge = dest.getEdgeTo(agent.location());
    } else {
      inComingEdge = dest.getEdgeTo(pathArray.get(pathArray.size() - 2));
    }
    if (inComingEdge == null) return new Pair<Area, Point2D>(dest, dest.getPositionPoint());
    Line2D wallLine =
        inComingEdge
            .getLine(); // new Line2D(edge.getStartX(), edge.getStartY(), edge.getEndX() -
                        // edge.getStartX(), edge.getEndY() - edge.getStartY());

    Vector2D offset;
    if (AliGeometryTools.havecorrectDirection(dest)) {
      offset = wallLine.getDirection().getNormal().normalised().scale(10);
    } else {
      offset = wallLine.getDirection().getNormal().normalised().scale(-10);
    }
    Point2D destXY = inComingEdge.getMidPoint().plus(offset);
    return new Pair<Area, Point2D>(dest, destXY);
  }
示例#2
0
 public void move(Path path) throws SOSActionException {
   log.info("moving to path: " + path);
   if (path == null) {
     log.error("path is null!!!");
     moveToARandomArea();
   }
   justMakeReachable(path);
   agent.move(path);
 }
示例#3
0
  protected void move(Collection<? extends Area> destination) throws SOSActionException {
    log.info("moving to: " + destination);
    if (destination.isEmpty()) {
      log.error("Move to empty destination????? random move....");
      moveToARandomArea();
    }

    Path path = agent.move.getPathTo(destination, PoliceMove.class);
    move(path);
  }
示例#4
0
  @SuppressWarnings("unused")
  private void moveToPointWithGoodReachablity(ArrayList<Pair<? extends Area, Point2D>> destinations)
      throws SOSActionException {
    log.info("moving to: " + destinations);
    if (destinations.isEmpty()) {
      log.error("Move to empty destination????? random move....");
      moveToARandomArea();
    }

    Path path = agent.move.getPathToPoints(destinations, PoliceMove.class);
    moveWithGoodReachablity(path);
  }
示例#5
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);
   }
 }
示例#6
0
  private static void setConstantsFromConfig(String[] args) throws IOException {

    try {
      config = new Config(new File("sos.config"));
      CommandLineOptions.processArgs(args, config);
      // if(config.getIntValue("sos.password")==SOSConstant.PASSWORD)
      if (!SOSConstant.IS_CHALLENGE_RUNNING)
        SOSConstant.IS_CHALLENGE_RUNNING = config.getBooleanValue("sos.IS_CHALLENGE_RUNNING", true);
      if (!SOSConstant.NO_ANY_LOG)
        SOSConstant.NO_ANY_LOG = config.getBooleanValue("sos.NO_ANY_LOG", true);
    } catch (ConfigException e1) {
      sosLogger.error(e1.getMessage());
    }
  }