Exemple #1
0
        private static void RunTests(TestData tests)
        {
            var totalSimpleTime = 0.0;
            var totalSmartTime  = 0.0;

            foreach (var test in tests.robotTests)
            {
                double time = 0;
                Console.WriteLine("Robot: " + test.Robot + ". Destination: " + test.Destination);
                var simpleRobot     = test.Robot.Copy();
                var simpleNavigator = new SimpleNavigator(test.Destination, simpleRobot);
                while (simpleRobot.Position.Subtract(test.Destination).Length > 1e-6)
                {
                    var command = simpleNavigator.NavigateRobot2(simpleRobot);
                    simpleRobot = simpleRobot.Move(command);
                    time       += command.Duration;
                }
                Console.WriteLine(time);
                var smartRobot     = test.Robot.Copy();
                var smartNavigator = new SmartNavigator(test.Destination, smartRobot);
                //while (smartRobot.Position.Subtract(test.Destination).Length > 1e-6)
                //{
                //    var command = smartNavigator.NavigateRobot2(smartRobot);
                //    smartRobot = smartRobot.Move(command);
                //    time += command.Duration;
                //}
                Console.WriteLine("-------------------");
            }
            Console.WriteLine("Total simple time: {0}\nTotal smart time: {1}", totalSimpleTime, totalSmartTime);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            var testData = new TestData();

            RunTests(new TestData());
            Console.WriteLine("\n\n\n\n");
            var totalSimpleTime = 0.0;
            var totalSmartTime  = 0.0;

            foreach (var test in testData.robotTests)
            {
                Console.WriteLine("Robot: " + test.Robot + ". Destination: " + test.Destination);
                var simple = new SimpleNavigator(test.Destination, test.Robot).NavigateRobot();
                var smart  = new SmartNavigator(test.Destination, test.Robot).NavigateRobot();
                totalSimpleTime += simple.Commands.Sum(x => x.Duration);
                Console.WriteLine("SimpleNavigate duration: " + simple.Commands.Sum(x => x.Duration));
                Console.WriteLine();
                var testRobot = test.Robot;
                foreach (var command in smart.Commands)
                {
                    testRobot = testRobot.Move(command);
                }
                totalSmartTime += smart.Commands.Sum(x => x.Duration);
                Console.WriteLine("SmartNavigate duration: " + smart.Commands.Sum(x => x.Duration));
                Console.WriteLine("-------------------");
            }
            Console.WriteLine("Total simple time: {0}\nTotal smart time: {1}", totalSimpleTime, totalSmartTime);
        }