private static void MoveToDirection(Robot robot, int stepscount, Direction direction) { for (int i = 0; i < stepscount; i++) { robot.MoveTo(direction); } }
private static void GoToDirection(Robot robot, Direction dir, int steps) { for (var i = 0; i < steps; i++) { robot.MoveTo(dir); } }
public static void MoveOutFromEmptyMaze(Robot robot, int width, int height) { for (int i = 0; i < width - 3; ++i) { robot.MoveTo(1, 1); } robot.MoveDown(); }
/* * Не нужно писать код выхода из произвольного лабиринта. Напишите, решение для конкретных лабиринтов. * Используйте циклы. Ваш К.О. * Постарайтесь решить задачу с ограничение "не более одного цикла на метод". * Подумайте, какие вспомогательные методы помогут сделать ваше решение более лаконичным, понятным и красивым. */ 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; } }
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); } } }
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); } } }
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); }; } } }
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); } } }
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; } } }
public static void MoveSnakeStraightOnLeft(Robot robot, Direction dir, int width) { while (true) { if (robot.Pos.X != width - (width - 1)) { robot.MoveTo(dir); } else { break; } } }
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)); } } }
public static void SnakeMoveToRight(Robot robot) { robot.MoveTo(Direction.Right); }
public static void SnakeMoveToDown(Robot robot) { robot.MoveTo(Direction.Down); }
public static void SnakeMoveToLeft(Robot robot) { robot.MoveTo(Direction.Left); }