示例#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 void moveXY(
     Collection<Pair<? extends Area, Point2D>> destinations, 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();
     MoveType mt = moves.get(type.hashCode());
     if (mt != null) {
       Path path = mt.getPathToPoints(destinations);
       log().debug("MOVE XY" + 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");
     move(bfs.breadthFirstSearchXY((Area) me.location(), destinations));
   }
   log().error("in move can not found type=" + type.getSimpleName());
   me.problemRest("in move can not found type=" + type.getSimpleName());
 }
示例#3
0
文件: Move.java 项目: jpollo/rcrss
 private void removeTemporaryTrafficBlocks() {
   while (!traffic.isEmpty() && me.time() > traffic.getFirst().second() + this.trafficRemainTime) {
     traffic.getFirst().first().setFreeTraffic();
     log().info(" traffic removed " + traffic.getFirst().first());
     traffic.removeFirst();
   }
   if (me.location() instanceof Road) {
     //			inBuildingStoppedCount = 0;
     // isBuildingCenterPassed = false;
   }
 }