public BoardMoveFinder(Board board, IDawgWithAlphabet dawgWithAlphabet) { Board = board; DawgWithAlphabet = dawgWithAlphabet; BoardCrossCheckCollector = new BoardCrossCheckCollector(board, dawgWithAlphabet); BoardWordRetriever = new BoardWordRetriever(Board); }
private void SetBoardTileCrossChecks(BoardTile boardTile) { if (boardTile == null) { return; } HashSet <char> crossChecks = BoardCrossCheckCollector.GetCrossChecksForBoardTile(boardTile); if (BoardTilesAndTheirCrossChecks.ContainsKey(boardTile)) { BoardTilesAndTheirCrossChecks[boardTile] = crossChecks; } else { BoardTilesAndTheirCrossChecks.Add(boardTile, crossChecks); } }
public List <BoardWord> GetPossibleMoves(BoardTile anchor, IPlayerRack playerRack) { ValidWords = new List <BoardWord>(); PlayerRack = playerRack; StartingBoardTile = anchor; BoardTilesAndTheirCrossChecks = new Dictionary <BoardTile, HashSet <char> >(); HorizontalBoardWord wordToTheLeftOfAnchor = BoardWordRetriever.GetHorizontalWordTilesAtCoordinates(StartingBoardTile.X, StartingBoardTile.Y - 1); string partialWord = wordToTheLeftOfAnchor?.GetWord() ?? ""; LeftPartIsAlreadyProvided = partialWord.Length > 0; BoardTilesAndTheirCrossChecks.Add(StartingBoardTile, BoardCrossCheckCollector.GetCrossChecksForBoardTile(StartingBoardTile)); BoardAnchorCollector boardAnchorCollector = new(); BoardTileCollection boardAnchors = boardAnchorCollector.GetAnchors(Board); DawgNode node = GetDawgNode(partialWord); BoardNonAnchorTileCounter boardNonAnchorTileCounter = new(Board); int limit = boardNonAnchorTileCounter.GetNumberOfNonAnchorTilesToTheLeftOfABoardTile(StartingBoardTile, boardAnchors); LeftPart(node, limit, anchor); return(ValidWords); }