Ejemplo n.º 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;
         }
     }
 }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            FileStream fs = new FileStream("Debug.txt", FileMode.Create);

            Debug.Listeners.Add(new TextWriterTraceListener(Console.Out));
            Debug.Listeners.Add(new TextWriterTraceListener(fs));

            RaceTrack    rc   = new RaceTrack("RaceTrack1.bmp");//change here to a different race BMP: 2 is very small, 3 is very large
            RandomPolicy p    = new RandomPolicy(rc);
            RaceViewer   form = new RaceViewer(rc);

            form.Start();
            //rc.DrawRace(p, form);

            ValueFunction vi1 = new ValueFunction(rc);
            ValueFunction vi2 = new ValueFunction(rc);
            ValueFunction vi3 = new ValueFunction(rc);
            int           cUpdates1 = 0, cUpdates2 = 0, cUpdates3 = 0;
            TimeSpan      ts1, ts2, ts3;

            form.StateValues = vi3;
            //  vi3.RealTimeDynamicProgramming(100, out cUpdates3, out ts3);

            form.StateValues = vi1;
            vi1.ValueIteration(0.5, out cUpdates1, out ts1);

            form.StateValues = vi2;
            //vi2.PrioritizedValueIteration(0.5, out cUpdates2, out ts2);
            rc.DrawRace(vi3, form);

            double dADR1 = rc.ComputeAverageDiscountedReward(vi1, 1000, 100);
            double dADR2 = rc.ComputeAverageDiscountedReward(vi2, 1000, 100);
            double dADR3 = rc.ComputeAverageDiscountedReward(vi3, 1000, 100);

            Debug.Close();
        }
Ejemplo n.º 3
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;
         }
     }
 }