private IEnumerable <BoardPoint> GetNeighbors(BoardPoint point, GameBoard board)
 {
     {
         var neighbor = point.ShiftLeft();
         if (IsAcceptablePath(board, neighbor))
         {
             yield return(neighbor);
         }
     }
     {
         var neighbor = point.ShiftRight();
         if (IsAcceptablePath(board, neighbor))
         {
             yield return(neighbor);
         }
     }
     {
         var neighbor = point.ShiftTop();
         if (IsAcceptablePath(board, neighbor))
         {
             yield return(neighbor);
         }
     }
     {
         var neighbor = point.ShiftBottom();
         if (IsAcceptablePath(board, neighbor))
         {
             yield return(neighbor);
         }
     }
 }
        private static Direction GetDefaultDirection(GameBoard gameBoard, BoardPoint head)
        {
            if (head == null)
            {
                return(Direction.Right);
            }

            if (prevDirection != Direction.Left &&
                !strongBadElements.Contains(gameBoard.GetElementAtOrWall(head.ShiftRight())))
            {
                return(Direction.Right);
            }

            if (prevDirection != Direction.Down &&
                !strongBadElements.Contains(gameBoard.GetElementAtOrWall(head.ShiftTop())))
            {
                return(Direction.Up);
            }

            if (prevDirection != Direction.Up &&
                !strongBadElements.Contains(gameBoard.GetElementAtOrWall(head.ShiftBottom())))
            {
                return(Direction.Down);
            }

            return(Direction.Left);
        }
 static bool canUp(GameBoard gameBoard, BoardPoint head) => prevDirection != Direction.Down &&
 !badElements.Contains(gameBoard.GetElementAtOrWall(head.ShiftTop()));
 static bool isNotDeadEnd2(GameBoard gameBoard, BoardPoint point) =>
 incrementIfNotDeadEnd(gameBoard, point.ShiftRight()) +
 incrementIfNotDeadEnd(gameBoard, point.ShiftTop()) +
 incrementIfNotDeadEnd(gameBoard, point.ShiftBottom()) +
 incrementIfNotDeadEnd(gameBoard, point.ShiftLeft())
 > 1;