jill/src/main/java/io/github/agentsoz/jill/lang/PlanBindings.java
private Plan selectPlanAtRandom() {
    Plan plan = null;
    Set<Belief> vars = null;
    int index = rand.nextInt(size());
    int idx = 0;
    boolean bindingsExist = false;
    for (Plan p : bindings.keySet()) {
      vars = bindings.get(p);
      bindingsExist = (vars != null && !vars.isEmpty());
      idx += bindingsExist ? vars.size() : 1;
      if (idx > index) {
        plan = p;
        if (bindingsExist) {
          index = index - (idx - vars.size());
          setPlanVariables(plan.getAgent(), plan, vars, index);
        }
        break;
      }
    }
    return plan;
  }
private Plan selectPlanAtRandom() {
    Plan plan = null;
    Set<Belief> vars = null;
    int index = rand.nextInt(size());
    int idx = 0;
    boolean bindingsExist = false;
    for (Plan p : bindings.keySet()) {
      vars = bindings.get(p);
      bindingsExist = (vars != null && !vars.isEmpty());
      idx += bindingsExist ? vars.size() : 1;
      if (idx > index) {
        plan = p;
        if (bindingsExist) {
          index = index - (idx - vars.size());
          setPlanVariables(plan.getAgent(), plan, vars, index);
        }
        break;
      }
    }
    return plan;
  }
private Plan selectPlanAtRandom ( ) { Plan plan = null ; Set < Belief > vars = null ; int index = rand . nextInt ( size ( ) ) ; int idx = 0 ; boolean bindingsExist = false ; for ( Plan p : bindings . keySet ( ) ) { vars = bindings . get ( p ) ; bindingsExist = ( vars != null && ! vars . isEmpty ( ) ) ; idx += bindingsExist ? vars . size ( ) : 1 ; if ( idx > index ) { plan = p ; if ( bindingsExist ) { index = index - ( idx - vars . size ( ) ) ; setPlanVariables ( plan . getAgent ( ) , plan , vars , index ) ; } break ; } } return plan ; }
Selects a plan instance at random from the set of plan bindings.

@return a randomly selected plan instance, or null if ther are no bindings to choose from
Selects a plan instance at random from the set of plan bindings .