Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Mazes
- {
- public static class SnakeMazeTask
- {
- private static Robot _robot;
- private static int _width;
- private static int _height;
- public static void MoveOut(Robot robot, int width, int height)
- {
- _robot = robot;
- _width = width;
- _height = height;
- MoveSnake();
- }
- private static void MoveSnake()
- {
- while (true)
- {
- MoveToManySteps(Direction.Right, _width - 3);
- MoveToManySteps(Direction.Down, 2);
- MoveToManySteps(Direction.Left, _width - 3);
- if (_robot.X == 1 && _robot.Y == _height - 2)
- break;
- MoveToManySteps(Direction.Down, 2);
- }
- }
- private static void MoveToManySteps(Direction direction, int countSteps)
- {
- for (var i = 0; i < countSteps; i++)
- _robot.MoveTo(direction);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment