示例#1
0
文件: Q2.cs 项目: Tilps/Stash
 static void Main(string[] args)
 {
     RobotSimulation c = new RobotSimulation();
     object o = c.cellsVisited("UUDUDDLLDR", 1);
     PrintObj(o);
     System.Console.In.ReadLine();
 }
示例#2
0
// END CUT HERE
// BEGIN CUT HERE
    public static void Main()
    {
        try {
            RobotSimulation ___test = new RobotSimulation();
            ___test.run_test(-1);
        } catch (Exception e) {
//Console.WriteLine(e.StackTrace);
            Console.WriteLine(e.ToString());
        }
    }
示例#3
0
 // END CUT HERE
 // BEGIN CUT HERE
 public static void Main()
 {
     try {
     RobotSimulation ___test = new RobotSimulation();
     ___test.run_test(-1);
     } catch(Exception e) {
     //Console.WriteLine(e.StackTrace);
     Console.WriteLine(e.ToString());
     }
 }
示例#4
0
        static RobotSimulation init()
        {
            int             step = (stepCount * stepCount) / robotCount;
            RobotSimulation sim  = new RobotSimulation(roomCellsSize);

            Random r = new Random();

            for (int i = 0; i < robotCount; i++)
            {
                bool movable = r.Next(unmovableDenominator) != 0;
                int  x       = (i * step) / roomCellsSize;
                int  y       = (i * step) % roomCellsSize;
                sim.CreateRobot(x, y, movable);
            }

            return(sim);
        }
示例#5
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);
        }