示例#1
0
        static int unmovableDenominator = 10; // approximately  1 / unmovableDenominator robots will be unmovable


        static void Main(string[] args)
        {
            RobotSimulation sim = init();

            sim.UpdateMode = RobotSimulation.FrameUpdateMode.Sequential;
            Stopwatch sw = new Stopwatch();

            sw.Start();
            for (int i = 0; i < stepCount; i++)
            {
                sim.PerformFrameUpdate();
                if (sim.CheckInvariant())
                {
                    Console.WriteLine("!!BUG!!, Sequential, step {0}, location {1}", i, sim.ConflictLocation);
                }
                Console.WriteLine("Sequential, step {0}, meanDist {1:0.0000}", i, GetMeanDist(sim.Robots));
            }
            sw.Stop();
            TimeSpan sequentialSpan = sw.Elapsed;

            sim            = init();
            sim.UpdateMode = RobotSimulation.FrameUpdateMode.Parallel;

            sw.Restart();
            for (int i = 0; i < stepCount; i++)
            {
                sim.PerformFrameUpdate();
                if (sim.CheckInvariant())
                {
                    Console.WriteLine("!!BUG!!, Parallel, step {0}, location {1}", i, sim.ConflictLocation);
                }
                Console.WriteLine("Parallel, step {0}, meanDist {1:0.0000}", i, GetMeanDist(sim.Robots));
            }
            sw.Stop();

            Console.WriteLine("Sequential took {0}", sequentialSpan);
            Console.WriteLine("Parallel took {0}", sw.Elapsed);
        }