/// <summary> /// Moves the robot to the exit /// </summary> /// <remarks> /// This function uses methods of the robot that was passed into this class' /// constructor. It has to move the robot until the robot's event /// <see cref="IRobot.ReachedExit"/> is fired. If the algorithm finds out that /// the exit is not reachable, it has to call <see cref="IRobot.HaltAndCatchFire"/> /// and exit. /// </remarks> public void MoveRobotToExit() { // Here you have to add your code // Trivial sample algorithm that can just move right var reachedEnd = false; robot.ReachedExit += (_, __) => reachedEnd = true; Random rdn = new Random(); bool noEnd = false; int moves = 0; while (!reachedEnd && !noEnd) { robot.TryMove((Direction)rdn.Next(0, 4)); moves++; if (moves == 1000000000) { robot.HaltAndCatchFire(); break; } } }
/// <summary> /// Moves the robot to the exit /// </summary> /// <remarks> /// This function uses methods of the robot that was passed into this class' /// constructor. It has to move the robot until the robot's event /// <see cref="IRobot.ReachedExit"/> is fired. If the algorithm finds out that /// the exit is not reachable, it has to call <see cref="IRobot.HaltAndCatchFire"/> /// and exit. /// </remarks> public void MoveRobotToExit() { // Here you have to add your code bool reachedEnd = false; robot.ReachedExit += (_, __) => reachedEnd = true; Random rnd = new Random(); for (int i = 0; i < 1000000 && !reachedEnd; i++) { robot.TryMove((Direction)rnd.Next(0, 4)); } robot.HaltAndCatchFire(); // Trivial sample algorithm that can just move right }
public void CalculatePath() { Random rnd = new Random(); int moves = 0; while (!reachedEnd) { robot.TryMove((Direction)rnd.Next(0, 4)); moves++; if (moves == 10000000) { robot.HaltAndCatchFire(); break; } } }
/// <summary> /// Moves the robot to the exit /// </summary> /// <remarks> /// This function uses methods of the robot that was passed into this class' /// constructor. It has to move the robot until the robot's event /// <see cref="IRobot.ReachedExit"/> is fired. If the algorithm finds out that /// the exit is not reachable, it has to call <see cref="IRobot.HaltAndCatchFire"/> /// and exit. /// </remarks> public void MoveRobotToExit() { var rnd = new Random(); var moves = 0; robot.ReachedExit += (_, __) => reachedEnd = true; while (!reachedEnd) { robot.TryMove((Direction)rnd.Next(0, 4)); moves++; if (moves == 1000000) { robot.HaltAndCatchFire(); break; } } }
/// <summary> /// Moves the robot to the exit /// </summary> /// <remarks> /// This function uses methods of the robot that was passed into this class' /// constructor. It has to move the robot until the robot's event /// <see cref="IRobot.ReachedExit"/> is fired. If the algorithm finds out that /// the exit is not reachable, it has to call <see cref="IRobot.HaltAndCatchFire"/> /// and exit. /// </remarks> public void MoveRobotToExit() { bool reachedEnd = false; robot.ReachedExit += (_, __) => reachedEnd = true; Random rnd = new Random(); for (int i = 0; i < 100000000; i++) { if (reachedEnd) { return; } robot.TryMove((Direction)rnd.Next(0, 4)); } robot.HaltAndCatchFire(); }
/// <summary> /// Moves the robot to the exit /// </summary> /// <remarks> /// This function uses methods of the robot that was passed into this class' /// constructor. It has to move the robot until the robot's event /// <see cref="IRobot.ReachedExit"/> is fired. If the algorithm finds out that /// the exit is not reachable, it has to call <see cref="IRobot.HaltAndCatchFire"/> /// and exit. /// </remarks> public void MoveRobotToExit() { // Here you have to add your code // Trivial sample algorithm that can just move right var reachedEnd = false; robot.ReachedExit += (_, __) => reachedEnd = true; Random rdm = new Random(); for (int i = 0; !reachedEnd; i++) { robot.TryMove((Direction)rdm.Next(0, 4)); if (i == 1000000) { robot.HaltAndCatchFire(); break; } } }
/// <summary> /// Moves the robot to the exit /// </summary> /// <remarks> /// This function uses methods of the robot that was passed into this class' /// constructor. It has to move the robot until the robot's event /// <see cref="IRobot.ReachedExit"/> is fired. If the algorithm finds out that /// the exit is not reachable, it has to call <see cref="IRobot.HaltAndCatchFire"/> /// and exit. /// </remarks> public void MoveRobotToExit() { bool reachedEnd = false; robot.ReachedExit += (_, __) => reachedEnd = true; Random random = new Random(); int moves = 0; while (!reachedEnd) { robot.TryMove((Direction)random.Next(0, 4)); moves++; if (moves == 10000000) { robot.HaltAndCatchFire(); break; } } //MakeAMove(null); }
/// <summary> /// Moves the robot to the exit /// </summary> /// <remarks> /// This function uses methods of the robot that was passed into this class' /// constructor. It has to move the robot until the robot's event /// <see cref="IRobot.ReachedExit"/> is fired. If the algorithm finds out that /// the exit is not reachable, it has to call <see cref="IRobot.HaltAndCatchFire"/> /// and exit. /// </remarks> public void MoveRobotToExit() { // Here you have to add your code var reachedEnd = false; robot.ReachedExit += (_, __) => reachedEnd = true; Random rnd = new Random(); int moves = 0; while (!reachedEnd) { robot.TryMove((Direction)rnd.Next(0, 4)); moves++; if (moves == 10000000) { robot.HaltAndCatchFire(); break; } } }
/// <summary> /// Moves the robot to the exit /// </summary> /// <remarks> /// This function uses methods of the robot that was passed into this class' /// constructor. It has to move the robot until the robot's event /// <see cref="IRobot.ReachedExit"/> is fired. If the algorithm finds out that /// the exit is not reachable, it has to call <see cref="IRobot.HaltAndCatchFire"/> /// and exit. /// </remarks> public void MoveRobotToExit() { var reachedEnd = false; robot.ReachedExit += (_, __) => reachedEnd = true; var rng = new Random(); const int maxMoves = 10000000; var moves = 0; while (!reachedEnd) { robot.TryMove((Direction)rng.Next(0, 4)); moves++; if (moves == maxMoves) { robot.HaltAndCatchFire(); break; } } }