コード例 #1
0
 private static void MoveToDirection(Robot robot, int stepscount, Direction direction)
 {
     for (int i = 0; i < stepscount; i++)
     {
         robot.MoveTo(direction);
     }
 }
コード例 #2
0
 private static void GoToDirection(Robot robot, Direction dir, int steps)
 {
     for (var i = 0; i < steps; i++)
     {
         robot.MoveTo(dir);
     }
 }
コード例 #3
0
 public static void MoveOutFromEmptyMaze(Robot robot, int width, int height)
 {
     for (int i = 0; i < width - 3; ++i)
     {
         robot.MoveTo(1, 1);
     }
     robot.MoveDown();
 }
コード例 #4
0
ファイル: MazeTasks.cs プロジェクト: mrPablox86/loops
        /*
         * Не нужно писать код выхода из произвольного лабиринта. Напишите, решение для конкретных лабиринтов.
         * Используйте циклы. Ваш К.О.
         * Постарайтесь решить задачу с ограничение "не более одного цикла на метод".
         * Подумайте, какие вспомогательные методы помогут сделать ваше решение более лаконичным, понятным и красивым.
         */
        public static void MoveOutFromEmptyMaze(Robot robot, int width, int height)
        {
            while (true)
            {
                for (var i = 0; i < 6; i++)
                {
                    robot.MoveTo(Direction.Down);
                }

                for (var j = 0; j < 5; j++)
                {
                    robot.MoveTo(Direction.Right);
                }

                return;
            }
        }
コード例 #5
0
 public static void MoveToExit(Robot robot, Direction direction, int rightSteps, int downSteps)
 {
     if (direction == Direction.Right)
     {
         for (int x = 0; x < rightSteps; x++)
         {
             robot.MoveTo(Direction.Right);
         }
     }
     if (direction == Direction.Down)
     {
         for (int y = 0; y < downSteps; y++)
         {
             robot.MoveTo(Direction.Down);
         }
     }
 }
コード例 #6
0
 static void DiagonalRun(Robot robot, Direction direction, int distance)
 {
     while (true)
     {
         DoSomeSteps(robot, direction, distance);
         if (robot.Finished)
         {
             break;
         }
         if (direction == Direction.Right)
         {
             robot.MoveTo(Direction.Down);
         }
         else
         {
             robot.MoveTo(Direction.Right);
         }
     }
 }
コード例 #7
0
        public static void MoveOut(Robot robot, int width, int height)
        {
            {
                for (int i = 0; i < 100; i++)
                {
                    try
                    {
                        robot.MoveTo(Direction.Down);
                    }
                    catch (Exception e) { Console.WriteLine(e); };

                    try
                    {
                        robot.MoveTo(Direction.Left);
                    }
                    catch (Exception e) { Console.WriteLine(e); };
                    try { robot.MoveTo(Direction.Right); }
                    catch (Exception e) { Console.WriteLine(e); };
                }
            }
        }
コード例 #8
0
        public static void DiagonalSteps(Robot robot, Direction dirLong, Direction dirShort, int shortSide, int longOffset)
        {
            for (int i = 0; i < shortSide; i++)
            {
                MoveToN(robot, dirLong, longOffset);

                if (!robot.Finished)
                {
                    robot.MoveTo(dirShort);
                }
            }
        }
コード例 #9
0
        public static void MoveOut(Robot robot, int width, int height)
        {
            Maze maze;

            maze = new Maze(File.ReadAllLines(Path.Combine("mazes", "diagonal3" + ".txt")));

            for (var i = 0; !robot.Finished; i++)
            {
                if (maze.IsWall(new System.Drawing.Point(robot.X + 1, robot.Y)))
                {
                    robot.MoveTo(Direction.Down);
                }
                else
                {
                    robot.MoveTo(Direction.Right);
                }
                if (robot.Finished)
                {
                    break;
                }
            }
        }
コード例 #10
0
ファイル: MazeTasks.cs プロジェクト: mrPablox86/loops
 public static void MoveSnakeStraightOnLeft(Robot robot, Direction dir, int width)
 {
     while (true)
     {
         if (robot.Pos.X != width - (width - 1))
         {
             robot.MoveTo(dir);
         }
         else
         {
             break;
         }
     }
 }
コード例 #11
0
        public static void MoveOut(Robot robot, int width, int height)
        {
            var countStepsToLarge = (Math.Max(width, height) - 3) / (Math.Min(width, height) - 2);

            for (int i = 1; i < Math.Max(width, height); i++)
            {
                if (!robot.Finished)
                {
                    MoveToMax(robot, countStepsToLarge, WhoIsMax(width, height));
                }
                if (!robot.Finished)
                {
                    robot.MoveTo(WhoIsMin(width, height));
                }
            }
        }
コード例 #12
0
ファイル: SnakeMazeTask.cs プロジェクト: Apolix96/Ulearn
 public static void SnakeMoveToRight(Robot robot)
 {
     robot.MoveTo(Direction.Right);
 }
コード例 #13
0
ファイル: SnakeMazeTask.cs プロジェクト: Apolix96/Ulearn
 public static void SnakeMoveToDown(Robot robot)
 {
     robot.MoveTo(Direction.Down);
 }
コード例 #14
0
ファイル: SnakeMazeTask.cs プロジェクト: Apolix96/Ulearn
 public static void SnakeMoveToLeft(Robot robot)
 {
     robot.MoveTo(Direction.Left);
 }