示例#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);
        }
示例#2
0
 public void Step() => _impl.MoveForward();