Ejemplo n.º 1
0
 @Override
 public void setChildren(final List<? extends ISymbol> children) {
   for (final ISymbol c : children) {
     if (c instanceof FsmEnterStatement) {
       enterActions = (FsmEnterStatement) c;
     } else if (c instanceof FsmExitStatement) {
       exitActions = (FsmExitStatement) c;
     } else if (c instanceof FsmTransitionStatement) {
       transitions.add((FsmTransitionStatement) c);
     }
   }
   children.remove(enterActions);
   children.remove(exitActions);
   children.removeAll(transitions);
   transitionsSize = transitions.size();
   super.setChildren(children);
 }
Ejemplo n.º 2
0
  protected String evaluateTransitions(final IScope scope) throws GamaRuntimeException {
    final IAgent agent = scope.getAgentScope();
    for (int i = 0; i < transitionsSize; i++) {
      final FsmTransitionStatement transition = transitions.get(i);

      if (transition.evaluatesTrueOn(scope)) {
        final String futureState = transition.getName();
        haltOn(scope);
        transition.executeOn(scope);
        scope.setAgentVarValue(agent, STATE, futureState);
        return futureState;
      }
    }
    if (!agent.dead()) {
      scope.saveAllVarValuesIn((Map) agent.getAttribute(STATE_MEMORY));
    }
    return name;
  }