public void MoveRobotToPosition()
        {
            CommandsParser commandParser = new CommandsParser();
            Arena          arena;
            bool           result = commandParser.IsValidArenaCommand("5 5", out arena);

            Assert.IsTrue(result);
            Robot robot;

            result = commandParser.IsValidCreateRobotCommand("1 2 N", out robot);
            Assert.IsTrue(result);
            var moves = commandParser.ParseRobotMoves("LMLMLMLMM");

            Assert.IsTrue(moves.Count > 0);

            MovesProvider provider = new MovesProvider();

            provider.MoveRobotToPosition(arena, robot, moves);

            Assert.AreEqual <int>(1, robot.PositionX);

            Assert.AreEqual <int>(3, robot.PositionY);

            Assert.AreEqual <CompasPoints>(CompasPoints.North, robot.Compas);
        }
        static void Main(string[] args)
        {
            CommandsParser commandParser = new CommandsParser();

            Console.WriteLine("Enter coordinates of the Arena");
            string arenaCommands = Console.ReadLine();
            Arena  arena         = null;

            if (!commandParser.IsValidArenaCommand(arenaCommands, out arena))
            {
                Console.WriteLine("Invalid command");
                Console.ReadKey();
                return;
            }

            while (true)
            {
                Console.WriteLine("Enter position for robot");
                string commands = Console.ReadLine();
                Robot  robot    = null;

                if (!commandParser.IsValidCreateRobotCommand(commands, out robot))
                {
                    Console.WriteLine("Invalid command");
                    Console.ReadKey();
                    return;
                }
                if (robot.PositionX > arena.Width || robot.PositionY > arena.Hight)
                {
                    Console.WriteLine("Invalid coordinates");
                    Console.ReadKey();
                    return;
                }

                Console.WriteLine("Enter robot moves");
                commands = Console.ReadLine();
                var moves = commandParser.ParseRobotMoves(commands);

                var movesProvider = new MovesProvider();
                movesProvider.MoveRobotToPosition(arena, robot, moves);

                Console.WriteLine("{0} {1} {2}", robot.PositionX, robot.PositionY, robot.Compas);
            }
        }
        public LineModel DoYourJob(int[,] maze, int[][] moves1, int[][] moves2, int maxMoves, int optTurns, int id, int x1, int y1, int x2, int y2)
        {
            Console.WriteLine("NUMEREK " + id);
            var array         = GetMazeArray(maze, maze.GetLength(0), maze.GetLength(1));
            var reversedArray = GetReversedMazeArray(maze, maze.GetLength(0), maze.GetLength(1));
            int lowest        = int.MaxValue;
            int leastTurns    = int.MaxValue;
            var visited       = new LineModel();

            Thread t1 = null;
            Thread t2 = null;
            Thread t3 = null;
            Thread t4 = null;

            Stopwatch sw = new Stopwatch();

            sw.Start();
            t1 = new Thread(delegate()
            {
                Move(array, x1, y1, 0, 0, new LineModel(), moves1, maxMoves, optTurns, null, false, ref leastTurns, ref lowest, ref visited);
            });
            t1.Start();

            t2 = new Thread(delegate()
            {
                Move(array, x1, y1, 0, 0, new LineModel(), moves2, maxMoves, optTurns, null, false, ref leastTurns, ref lowest, ref visited);
            });
            t2.Start();
            t3 = new Thread(delegate()
            {
                Move(reversedArray, x2, y2, 0, 0, new LineModel(), MovesProvider.GetReversedMoves(moves1), maxMoves, optTurns, null, true, ref leastTurns, ref lowest, ref visited);
            });
            t3.Start();

            t4 = new Thread(delegate()
            {
                Move(reversedArray, x2, y2, 0, 0, new LineModel(), MovesProvider.GetReversedMoves(moves2), maxMoves, optTurns, null, true, ref leastTurns, ref lowest, ref visited);
            });
            t4.Start();

            var joinThread1 = new Thread(delegate()
            {
                t1.Join();
                t2.Join();
                if (lowest == int.MaxValue)
                {
                    lowest = 0;
                }
            });

            joinThread1.Start();

            var joinThread2 = new Thread(delegate()
            {
                t3.Join();
                t4.Join();
                if (lowest == int.MaxValue)
                {
                    lowest = 0;
                }
            });

            joinThread2.Start();

            //t3.Join();
            //t4.Join();

            //if(lowest == int.MaxValue)
            //    lowest = 0;

            //t1.Join();
            //t2.Join();

            joinThread1.Join();
            joinThread2.Join();

            sw.Stop();
            Console.WriteLine($"Optimal moves: {visited.GetPointsOfLine().Count}");
            Console.WriteLine("ElapsedTime={0}", sw.Elapsed);
            visited.DisplayLine();
            return(visited);
        }