예제 #1
0
 public BoardMoveFinder(Board board, IDawgWithAlphabet dawgWithAlphabet)
 {
     Board                    = board;
     DawgWithAlphabet         = dawgWithAlphabet;
     BoardCrossCheckCollector = new BoardCrossCheckCollector(board, dawgWithAlphabet);
     BoardWordRetriever       = new BoardWordRetriever(Board);
 }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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);
        }