Пример #1
0
 public override void executeAction(IAgent agent, IAction action)
 {
     if (!action.IsNoOp())
     {
         Cell <double> s = currentState.getAgentLocation(agent);
         double        probabilityChoice = r.NextDouble();
         double        total             = 0;
         bool          set = false;
         foreach (Cell <double> sDelta in allStates)
         {
             total += tpf.probability(sDelta, s, (CellWorldAction)action);
             if (total > 1.0)
             {
                 throw new IllegalStateException("Bad probability calculation.");
             }
             if (total > probabilityChoice)
             {
                 currentState.setAgentLocation(agent, sDelta);
                 set = true;
                 break;
             }
         }
         if (!set)
         {
             throw new IllegalStateException("Failed to simulate the action=" + action + " correctly from s=" + s);
         }
     }
 }
Пример #2
0
 public virtual double transitionProbability(S sDelta, S s, A a)
 {
     return(transitionProbabilityFunction.probability(sDelta, s, a));
 }