示例#1
1
文件: Move.java 项目: jpollo/rcrss
  public void moveToShape(Collection<ShapeInArea> des, Class<? extends MoveType> type)
      throws SOSActionException {

    if (!(me.me() instanceof Human)) {
      log().warn("can't use move in Center Agent " + me + "\n");
      return;
    }
    try {
      checkTraffic(); // TODO uncomment
      MoveType mt = moves.get(type.hashCode());
      if (mt != null) {
        Path path = mt.getPathToShape(des);
        log().debug("MOVE " + type.getSimpleName() + "\nTO : " + path + "\n");
        move(path);
      } else log().error(new Error("in move can not found type=" + type.getSimpleName()));

    } catch (SOSActionException e) {
      throw e;
    } catch (Exception er) {
      log().error(er);
      log().warn("using bfs for finding path");
      ArrayList<Area> goals = new ArrayList<Area>();

      for (ShapeInArea shapeInArea : des) {
        goals.add(shapeInArea.getArea(me.model()));
      }
      move(bfs.breadthFirstSearch((Area) me.location(), goals));
    }
    log().error("in move can not found type=" + type.getSimpleName());
    me.problemRest("in move can not found type=" + type.getSimpleName());
  }
示例#2
0
文件: Move.java 项目: jpollo/rcrss
  public Path getPathToShapes(Collection<ShapeInArea> des, Class<? extends MoveType> type) {
    try {
      MoveType mt = moves.get(type.hashCode());
      if (mt != null) {
        Path path = mt.getPathToShape(des);
        return path;

      } else {
        log().error(new Error("in move can not found type=" + type.getSimpleName()));
      }

    } catch (Exception er) {
      log().error(er);
      log().warn("using bfs for finding path");
      ArrayList<Area> goals = new ArrayList<Area>();

      for (ShapeInArea shapeInArea : des) {
        goals.add(shapeInArea.getArea(me.model()));
      }
      return getPathTo(goals, type);
    }
    return null;
  }
示例#3
0
文件: Move.java 项目: jpollo/rcrss
 public long getWeightToLowProcess(List<ShapeInArea> targets, Class<? extends MoveType> type) {
   long min = Long.MAX_VALUE;
   MoveType movetype = moves.get(type.hashCode());
   for (ShapeInArea shapeInArea : targets) {
     if (shapeInArea
         .getArea(me.model())
         .equals(me.me().getAreaPosition())) { // source and destination is in same area
       if (shapeInArea.contains(((Human) me.me()).getX(), ((Human) me.me()).getY())) {
         log().debug("in shape--Yoosef");
         return 0;
       }
     }
     min =
         Math.min(
             min,
             movetype.getWeightToLowProcess(
                 shapeInArea.getArea(me.model()),
                 shapeInArea.getCenterX(),
                 shapeInArea.getCenterY()));
   }
   if (min < 0) log().error(new Error("why it become negetive here???"));
   return min;
 }
示例#4
0
文件: Move.java 项目: jpollo/rcrss
 public boolean isReallyUnreachable(ShapeInArea sh) {
   if (sh.contains(me.me().getPositionPoint().toGeomPoint())) return false;
   long weightTo = moves.get(StandardMove.class.hashCode()).getWeightTo(sh);
   if (weightTo < 0) log().error(new Error("why it become negetive here???"));
   return weightTo > UNREACHABLE_COST;
 }