Example #1
0
 public void DrawRace(Policy p, RaceViewer form)
 {
     form.StateValues = null;
     form.Start();
     //form.ShowDialog();
     while (form.Active)
     {
         Thread.Sleep(100);
         RaceCarState   s = (RaceCarState)StartState;
         VelocityAction a = null;
         while (form.Active && !IsGoalState(s))
         {
             a = (VelocityAction)p.GetAction(s);
             if (a == null)
             {
                 break;
             }
             form.CarState = s;
             //form.Invoke(form.RefreshForm);
             //form.SetCarState(s);
             Thread.Sleep(100);
             RaceCarState sTag = (RaceCarState)s.Apply(a);
             s = sTag;
         }
     }
 }
Example #2
0
 private double CompOneExperimant(Policy p, int cStepsPerTrial)
 {
     State s = StartState;
     double r = 0;
     int i = 0;
     while (!IsGoalState(s) && i <= cStepsPerTrial)
     {
         Action a = p.GetAction(s);
         r += Math.Pow(DiscountFactor, i) * s.Reward(a);
         i++;
         foreach (State stag in States)
             if (s.TransitionProbability(a, stag) != 0)
                 s = stag;
     }
     return r;
 }
Example #3
0
        private double CompOneExperimant(Policy p, int cStepsPerTrial)
        {
            State  s = StartState;
            double r = 0;
            int    i = 0;

            while (!IsGoalState(s) && i <= cStepsPerTrial)
            {
                Action a = p.GetAction(s);
                r += Math.Pow(DiscountFactor, i) * s.Reward(a);
                i++;
                foreach (State stag in States)
                {
                    if (s.TransitionProbability(a, stag) != 0)
                    {
                        s = stag;
                    }
                }
            }
            return(r);
        }
 public void DrawRace(Policy p, RaceViewer form)
 {
     form.StateValues = null;
     form.Start();
     //form.ShowDialog();
     while (form.Active)
     {
         Thread.Sleep(100);
         RaceCarState s = (RaceCarState)StartState;
         VelocityAction a = null;
         while (form.Active && !IsGoalState(s))
         {
             a = (VelocityAction)p.GetAction(s);
             if (a == null)
                 break;
             form.CarState = s;
             //form.Invoke(form.RefreshForm);
             //form.SetCarState(s);
             Thread.Sleep(100);
             RaceCarState sTag = (RaceCarState)s.Apply(a);
             s = sTag;
         }
     }
 }