Ejemplo n.º 1
0
  public void move(Collection<? extends Area> goals, 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.getPathTo(goals);
        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 ec) {
      throw ec;
    } catch (Exception er) {
      log().error(er);
      log().warn("using bfs for finding path");
      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());
  }