Beispiel #1
0
        /// <summary>
        /// This method moves to a new maze gridpoint indicated by the specified direction.
        /// If no maze gridpoint is found in the direction specified, an exception is thrown.
        /// </summary>
        public MazeGridpoint ProceedToNewGridpoint(MazeGridpoint mazeGridpoint, DirectionEnum direction)
        {
            var nextCoordinate = mazeGridpoint.Position.MoveInDirection(direction);

            var nextMazeGridpoint = MazeGridpoints[nextCoordinate];

            return(nextMazeGridpoint);
        }
Beispiel #2
0
        /// <summary>
        /// This method checks if moving to a new position in the maze will be inside
        /// the boundaries of the maze, and therfore valid.
        /// </summary>
        public bool IsValidPositionInMaze(
            MazeGridpoint currentMazeGridPoint,
            DirectionEnum directionToMove)
        {
            var nextPotentialCoordinate = currentMazeGridPoint.Position.MoveInDirection(directionToMove);

            var isValid = CheckIfCoordinateIsValid(nextPotentialCoordinate);

            return(isValid);
        }
Beispiel #3
0
        /// <summary>
        /// This method checks two things: 1) If moving to a new position in the maze will be inside
        /// the boundaries of the maze, and therfore valid, 2) If moving to the specified position
        /// in the maze would be back-tracking based on the last position supplied.
        /// </summary>
        public bool IsValidPositionInMazeAndNotBacktracking(
            MazeGridpoint lastMazeGridPoint,
            MazeGridpoint currentMazeGridPoint,
            DirectionEnum directionToMove)
        {
            var nextPotentialCoordinate = currentMazeGridPoint.Position.MoveInDirection(directionToMove);

            var isBacktracking = (lastMazeGridPoint.Position == nextPotentialCoordinate);
            var isValid        = CheckIfCoordinateIsValid(nextPotentialCoordinate);

            return(isValid && !isBacktracking);
        }
Beispiel #4
0
        /// <summary>
        /// Checks if a maze gridpoint is a dead-end or wall.
        /// </summary>
        public bool CheckIfAtDeadEnd(MazeGridpoint mazeGridpoint)
        {
            if (mazeGridpoint.IsFinishPoint)
            {
                return(false);
            }
            if (mazeGridpoint.IsStartPoint)
            {
                return(false);
            }
            if (mazeGridpoint.IsWall)
            {
                return(true);
            }
            if (mazeGridpoint.DirectionsAvailable.Count > 1)
            {
                return(false);
            }

            return(true);
        }
Beispiel #5
0
 /// <summary>
 /// Checks if a maze gridpoint is a finish point of the maze.
 /// </summary>
 public bool CheckIfAtFinish(MazeGridpoint mazeGridpoint)
 {
     return(mazeGridpoint.IsFinishPoint);
 }