Ejemplo n.º 1
0
        public static bool SolveMaze(IMazeWalker entity, Point mazeFinish)
        {
            bool endOfMazeReached = false;

            while (!endOfMazeReached)
            {
                bool couldMoveForward = entity.MoveForward();

                if (!couldMoveForward)
                {
                    entity.TurnRight();
                }
                else
                {
                    if (entity.CanSeeLeftTurning())
                    {
                        entity.TurnLeft();
                    }
                }

                endOfMazeReached = Equals(entity.CurrentPosition, mazeFinish);
                entity.DumpState();
            }

            return(true);
        }
Ejemplo n.º 2
0
 public void Face(Direction direction)
 {
     while (_impl.Direction != direction.GetOrientation())
     {
         _impl.TurnLeft();
     }
 }