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); } } }
static bool isNotDeadEnd2(GameBoard gameBoard, BoardPoint point) => incrementIfNotDeadEnd(gameBoard, point.ShiftRight()) + incrementIfNotDeadEnd(gameBoard, point.ShiftTop()) + incrementIfNotDeadEnd(gameBoard, point.ShiftBottom()) + incrementIfNotDeadEnd(gameBoard, point.ShiftLeft()) > 1;
static bool canLeft(GameBoard gameBoard, BoardPoint head) => prevDirection != Direction.Right && !badElements.Contains(gameBoard.GetElementAtOrWall(head.ShiftLeft()));