Exemplo n.º 1
0
        public void PrintBoard(Piece selectedPiece = null)
        {
            Console.Clear();
            var roundFlag = true;

            for (int i = _board.GetLength(0) - 1; i >= 0; i--)
            {
                Console.WriteLine("---------------------------------------------");
                Console.Write($"  {i + 1} |");
                for (int j = 0; j < _board.GetLength(1); j++)
                {
                    var piece = _board[i, j].OccupyingPiece;

                    var pos = new PiecePosition(i, j);

                    if (roundFlag)
                    {
                        Console.BackgroundColor = ConsoleColor.Gray;
                    }
                    else
                    {
                        Console.BackgroundColor = ConsoleColor.DarkGray;
                    }

                    roundFlag = !roundFlag;

                    if (selectedPiece != null && selectedPiece.GetMoves().Any(m => m.GetMovePos().Position == pos))
                    {
                        Console.BackgroundColor = ConsoleColor.Magenta;
                    }

                    if (piece == null)
                    {
                        Console.ForegroundColor = ConsoleColor.Black;
                        Console.Write("     ");
                        continue;
                    }

                    Console.ForegroundColor = piece.PieceOwner.Side == "bottom" ? ConsoleColor.DarkBlue : ConsoleColor.DarkRed;
                    Console.Write($"  {piece.VisualID}  ");
                }

                // offset for checker board pattern.
                roundFlag = !roundFlag;

                Console.ResetColor();

                Console.WriteLine();
            }

            Console.WriteLine("---------------------------------------------");
            for (int i = 0; i < _board.GetLength(1) + 1; i++)
            {
                Console.Write($"| {i} |");
            }
            Console.WriteLine("\n---------------------------------------------");
        }
Exemplo n.º 2
0
    void ListPossibleMoves()
    {
        board = null;
        pieces.Clear();

        board = Board.instance.GetBoard();
        listAvaliableMoves = new List <AIMoviment>();

        //checking dark pieces
        for (int i = 0; i < board.GetLength(0); i++)
        {
            for (int j = 0; j < board.GetLength(1); j++)
            {
                if (board[i, j].currentPiece == null)
                {
                    continue;
                }

                if (board[i, j].currentPiece.CheckPieceType(PieceTypes.Black))
                {
                    pieces.Add(board[i, j].currentPiece);
                }
            }
        }
        //list possible piece moves
        for (int i = 0; i < pieces.Count; i++)
        {
            //getting piece tile coordinates
            int actualRow = pieces[i].currentTile.row;
            int actualCol = pieces[i].currentTile.column;

            if (pieces[i].IsKing()) //if the actual piece is a king
            {
                //checking diagonals
                bool downRight = AIKingTile(pieces[i], actualRow + 1, actualCol + 1, 1, 1, PieceTypes.Black);
                bool downLeft  = AIKingTile(pieces[i], actualRow + 1, actualCol - 1, 1, -1, PieceTypes.Black);
                bool upRight   = AIKingTile(pieces[i], actualRow - 1, actualCol + 1, -1, 1, PieceTypes.Black);
                bool upLeft    = AIKingTile(pieces[i], actualRow - 1, actualCol - 1, -1, -1, PieceTypes.Black);
            }
            else
            {
                if (pieces[i].IsDownMoviment())
                {
                    bool upRight = AIBoardTile(pieces[i], actualRow - 1, actualCol + 1, -1, 1, PieceTypes.Black);
                    bool upLeft  = AIBoardTile(pieces[i], actualRow - 1, actualCol - 1, -1, -1, PieceTypes.Black);
                }
                else
                {
                    bool downRight = AIBoardTile(pieces[i], actualRow + 1, actualCol + 1, 1, 1, PieceTypes.Black);
                    bool downLeft  = AIBoardTile(pieces[i], actualRow + 1, actualCol - 1, 1, -1, PieceTypes.Black);
                }
            }
        }
    }
Exemplo n.º 3
0
 private void UpdateScores(int val, int row, int col)
 {
     RowsEval[row] += val;
     ColsEval[col] += val;
     if (row == col)
     {
         DiagsEval[0] += val;
     }
     if (row + col == BoardState.GetLength(0) - 1)
     {
         DiagsEval[1] += val;
     }
 }
Exemplo n.º 4
0
    bool OnBoardLimits(int row, int column)
    {
        if (row < 0 || row >= board.GetLength(0))
        {
            return(false);
        }

        if (column < 0 || column >= board.GetLength(1))
        {
            return(false);
        }

        return(true);
    }
Exemplo n.º 5
0
        /// <summary>
        /// Transposes an array (turns rows to columns and columns to rows).
        /// </summary>
        /// <param name="boardArray">Original untransposed array.</param>
        /// <returns></returns>
        public BoardTile[,] Transpose2DArray(BoardTile[,] boardArray)
        {
            int w = boardArray.GetLength(0);
            int h = boardArray.GetLength(1);

            BoardTile[,] result = new BoardTile[h, w];

            for (int i = 0; i < w; i++)
            {
                for (int j = 0; j < h; j++)
                {
                    result[j, i] = boardArray[i, j];
                }
            }

            return(result);
        }
Exemplo n.º 6
0
 //Updates the visual board
 private void UpdateBoard()
 {
     //Loop over each label
     for (int i = 0; i < bdtBoard.GetLength(0); i++)
     {
         for (int j = 0; j < bdtBoard.GetLength(1); j++)
         {
             //Get the current tile and its corresponding label
             BoardTile bdtCurTile = bdtBoard[i, j];
             Label     lblCurTile = lblTiles[i, j];
             //Update the label's text and colors to reflect the symbol that it has
             lblCurTile.Text      = bdtCurTile.GetDescription();
             lblCurTile.BackColor = SystemColors.Control;
             lblCurTile.ForeColor = bdtCurTile.GetCorrespondingColor();
         }
     }
 }
Exemplo n.º 7
0
        public GeneratedMove(bool isHorizontal, int startIndex, int endIndex, int[] anchor, Dictionary <BoardTile, CharTile> tilesUsed, BoardTile[,] boardBeforeMove, Rack rack)
        {
            IsHorizontal             = isHorizontal;
            StartIndex               = startIndex;
            EndIndex                 = endIndex;
            Anchor                   = anchor;
            TilesUsed                = tilesUsed;
            Word                     = GetWord();
            BoardBeforeMove          = new BoardTile[boardBeforeMove.GetLength(0), boardBeforeMove.GetLength(1)];
            RackTilesUsedCoordinates = new List <int[]>();
            ExtraWordsPlayed         = new List <List <BoardTile> >();

            //Creates a copy of the original board before move generation
            //Used to get the scores of it and words connected.
            for (int i = 0; i < BoardBeforeMove.GetLength(0); i++)
            {
                for (int j = 0; j < BoardBeforeMove.GetLength(1); j++)
                {
                    BoardBeforeMove[i, j] = new BoardTile
                    {
                        BoardLocationX = boardBeforeMove[i, j].BoardLocationX,
                        BoardLocationY = boardBeforeMove[i, j].BoardLocationY,
                        BoardTileType  = boardBeforeMove[i, j].BoardTileType,
                        CharTile       = boardBeforeMove[i, j].CharTile,
                        IsFilled       = boardBeforeMove[i, j].IsFilled
                    };
                    foreach (var tileUsed in TilesUsed)
                    {
                        if (BoardBeforeMove[i, j].BoardLocationX == tileUsed.Key.BoardLocationX &&
                            BoardBeforeMove[i, j].BoardLocationY == tileUsed.Key.BoardLocationY &&
                            BoardBeforeMove[i, j].CharTile == null)
                        {
                            RackTilesUsedCoordinates.Add(new int[] { i, j });
                            BoardBeforeMove[i, j].CharTile = tileUsed.Value;
                        }
                    }
                }
            }
            BoardAfterMove = BoardBeforeMove;
            Score          = GetScore();
            Rack           = new Rack {
                Rack_CharTiles = new List <Rack_CharTile>(rack.Rack_CharTiles)
            };
            RackScore = GetRackScore(Rack);
        }
Exemplo n.º 8
0
 public bool TileExists(Vector2 coords)
 {
     if (coords.X >= 0 && coords.X < boardTiles.GetLength(0) && coords.Y >= 0 && coords.Y < boardTiles.GetLength(1))
     {
         return(Tile(coords) != null);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 9
0
        public ChessBoard()
        {
            grid = new BoardTile[8, 8];

            bool flag = true;

            for (int i = 0; i < grid.GetLength(0); i++)
            {
                for (int j = 0; j < grid.GetLength(1); j++)
                {
                    Label temp;

                    temp          = new Label();
                    temp.AutoSize = false;

                    Color tempColor;
                    if (flag)
                    {
                        tempColor = Color.PeachPuff;
                    }
                    else
                    {
                        tempColor = Color.Peru;
                    }


                    temp.Size        = new Size(50, 50);
                    temp.Location    = new Point((i * 50) + 120, ((j * 50) + 70));
                    temp.Visible     = true;
                    temp.BorderStyle = BorderStyle.Fixed3D;


                    temp.Name  = "Square";
                    grid[i, j] = new BoardTile(temp, tempColor);

                    //GridArea(grid[i, j]);
                    flag = !flag;
                }
                flag = !flag;
            }
        }
Exemplo n.º 10
0
 public void OriginalColorSquare()
 {
     for (int i = 0; i < grid.GetLength(0); i++)
     {
         for (int j = 0; j < grid.GetLength(1); j++)
         {
             grid[i, j].GetSquare().BackColor = grid[i, j].GetColor();
         }
     }
 }
Exemplo n.º 11
0
    private void GenerateBoard()
    {
        if (board == null)
        {
            return;
        }

        float x = position.x, y = position.y, z = position.z;

        for (int i = 0; i < board.GetLength(0); i++)
        {
            for (int j = 0; j < board.GetLength(1); j++)
            {
                BoardTile tile = board[i, j];

                z = position.z + j * posOffset;

                if (tile.type == BoardTileType.Target)
                {
                    Instantiate(padTarget, new Vector3(x, y, z), Quaternion.identity);
                }
                else if (tile.type == BoardTileType.Path)
                {
                    Instantiate(pad, new Vector3(x, y, z), Quaternion.identity);
                }
                else
                {
                    continue;
                }

                // Check right path
                if (i < board.GetLength(0) - 1)
                {
                    if (tile.rightPath)
                    {
                        Instantiate(path, new Vector3(x + 3, y, z), Quaternion.identity);
                    }
                }

                // Check upper path
                if (j < board.GetLength(1) - 1)
                {
                    if (tile.upPath)
                    {
                        Instantiate(path, new Vector3(x, y, z + 3), Quaternion.Euler(0, 90, 0));
                    }
                }
            }
            x += posOffset;
        }
    }
Exemplo n.º 12
0
        //public static bool IsRackPlayOneWayAndConnected(string[] rackTiles)
        //{
        //    HashSet<int> rowsUsed = new HashSet<int>();
        //    HashSet<int> columnsUsed = new HashSet<int>();
        //    foreach (var tile in rackTiles)
        //    {
        //        string[] tileDetails = GetTileDetails(tile);
        //        rowsUsed.Add(Int32.Parse(tileDetails[0]));
        //        columnsUsed.Add(Int32.Parse(tileDetails[1]));
        //    }
        //    if (rowsUsed.Count > 1 && columnsUsed.Count > 1)
        //    {
        //        return false;
        //    }
        //    return true;
        //}
        //public static bool ValidateStart(BoardTile[,] boardAsArray, string[] playedRackTiles)
        //{
        //    int[] startBoardTileCoordinates = null;
        //    for (int i = 0; i < boardAsArray.GetLength(0); i++)
        //    {
        //        for (int j = 0; j < boardAsArray.GetLength(1); j++)
        //        {
        //            if (boardAsArray[i, j].BoardTileType.Type == "Start")
        //            {
        //                startBoardTileCoordinates = new int[] { i, j };
        //            }
        //            if (boardAsArray[i, j].CharTile != null) return true;
        //        }
        //    }
        //    bool startTileIsFilled = false;
        //    bool tilesBeforeStartFilled = false;
        //    foreach (var tile in playedRackTiles)
        //    {
        //        var tileDetails = GetTileDetails(tile);
        //        var rowIndex = Int32.Parse(tileDetails[0]);
        //        var columnIndex = Int32.Parse(tileDetails[1]);
        //        if (rowIndex == startBoardTileCoordinates[0] && columnIndex == startBoardTileCoordinates[1])
        //        {
        //            startTileIsFilled = true;
        //        }
        //        if (rowIndex < startBoardTileCoordinates[0] || columnIndex < startBoardTileCoordinates[1])
        //        {
        //            tilesBeforeStartFilled = true;
        //        }
        //    }
        //    if (startTileIsFilled && !tilesBeforeStartFilled)
        //    {
        //        return true;
        //    }
        //    return false;

        //}
        //public static bool IsRackPlayConnected(BoardTile[,] boardAsArray, string[] rackTiles)
        //{
        //    HashSet<int> rowsUsed = new HashSet<int>();
        //    HashSet<int> columnsUsed = new HashSet<int>();
        //    foreach (var tile in rackTiles)
        //    {
        //        var tileDetails = GetTileDetails(tile);
        //        var rowIndex = Int32.Parse(tileDetails[0]);
        //        var columnIndex = Int32.Parse(tileDetails[1]);
        //        rowsUsed.Add(rowIndex);
        //        columnsUsed.Add(columnIndex);
        //    }
        //    if (rowsUsed.Count > 1 && columnsUsed.Count > 1)
        //    {
        //        return false;
        //    }
        //    if (rowsUsed.Count == 1 && columnsUsed.Count == 1)
        //    {
        //        var tileIsConnected = false;
        //        var rowIndex = rowsUsed.FirstOrDefault();
        //        var columnIndex = columnsUsed.FirstOrDefault();
        //        if ((boardAsArray[rowIndex + 1, columnIndex] != null && boardAsArray[rowIndex + 1, columnIndex].CharTile != null)
        //            || (boardAsArray[rowIndex - 1, columnIndex] != null && boardAsArray[rowIndex - 1, columnIndex].CharTile != null)
        //            || (boardAsArray[rowIndex, columnIndex + 1] != null && boardAsArray[rowIndex, columnIndex + 1].CharTile != null)
        //            || (boardAsArray[rowIndex, columnIndex - 1] != null && boardAsArray[rowIndex, columnIndex - 1].CharTile != null))
        //        {
        //            tileIsConnected = true;
        //        }
        //        if (!tileIsConnected)
        //        {
        //            return false;
        //        }
        //    }
        //    var directionOfPlay = "";
        //    var rowsUsedSorted = rowsUsed.ToList();
        //    rowsUsedSorted.Sort();
        //    var columnsUsedSorted = columnsUsed.ToList();
        //    columnsUsedSorted.Sort();
        //    var multipleIndexes = rowsUsedSorted.Count > columnsUsedSorted.Count ? rowsUsedSorted : columnsUsedSorted;
        //    var secondaryIndex = rowsUsedSorted.Count > columnsUsedSorted.Count ? columnsUsedSorted : rowsUsedSorted;
        //    directionOfPlay = rowsUsedSorted.Count > columnsUsedSorted.Count ? "transposed" : "untransposed";
        //    for (var i = multipleIndexes[0]; i < multipleIndexes[multipleIndexes.Count - 1]; i++)
        //    {
        //        var checkedTile = directionOfPlay == "untransposed" ? boardAsArray[secondaryIndex[0], i] : boardAsArray[i, secondaryIndex[0]];
        //        if (checkedTile.CharTile == null)
        //        {
        //            var boardTileHasTemporaryPlacedRackTile = false;
        //            foreach (var rackTile in rackTiles)
        //            {
        //                var tileDetails = GetTileDetails(rackTile);
        //                var rowIndex = Int32.Parse(tileDetails[0]);
        //                var columnIndex = Int32.Parse(tileDetails[1]);
        //                if (rowIndex == checkedTile.BoardLocationX && columnIndex == checkedTile.BoardLocationY)
        //                {
        //                    boardTileHasTemporaryPlacedRackTile = true;
        //                    break;
        //                }
        //            }
        //            if (!boardTileHasTemporaryPlacedRackTile)
        //            {
        //                return false;
        //            }
        //        }
        //    }
        //    return true;
        //}


        /// <summary>
        /// Given a tile, checks the vertical word that it forms
        /// </summary>
        /// <param name="board">Board to scan</param>
        /// <param name="rackTileCoordinates">Coordinates of rack tile played</param>
        /// <returns></returns>
        public static List <BoardTile> GetVerticalPlays(BoardTile[,] board, int[] rackTileCoordinates)
        {
            var word             = new List <BoardTile>();
            var upIndexCounter   = rackTileCoordinates[0];
            var downIndexCounter = rackTileCoordinates[0];
            var columnIndex      = rackTileCoordinates[1];

            while (upIndexCounter > 0 && board[upIndexCounter - 1, columnIndex].CharTile != null)
            {
                word.Insert(0, board[upIndexCounter - 1, columnIndex]);
                upIndexCounter--;
            }
            word.Add(board[rackTileCoordinates[0], rackTileCoordinates[1]]);
            while (downIndexCounter < board.GetLength(0) - 1 && board[downIndexCounter + 1, columnIndex].CharTile != null)
            {
                word.Add(board[downIndexCounter + 1, columnIndex]);
                downIndexCounter++;
            }
            if (word.Count < 2)
            {
                return(null);
            }
            return(word);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Builds all possible right parts for given anchor
        /// </summary>
        /// <param name="partialWord">Word preceding right part</param>
        /// <param name="anchor">Tile from which to build up right part</param>
        /// <param name="boardArray">Board to work with</param>
        /// <param name="validCrossChecks">List of valid cross checks for all empty tiles</param>
        /// <param name="validMovesList">List of valid moves that gets updated</param>
        /// <param name="boardIsHorizontal">Board is untransposed or transposed</param>
        /// <param name="boardBeforeMove">Board before any moves were generated</param>
        /// <param name="tileExtendedWith">Tile that was used to extend the right part</param>
        public void ExtendRight(string partialWord, int[] anchor, BoardTile[,] boardArray, Dictionary <BoardTile,
                                                                                                       List <CharTile> > validCrossChecks, HashSet <GeneratedMove> validMovesList, bool boardIsHorizontal, BoardTile[,] boardBeforeMove,
                                CharTile tileExtendedWith = null)
        {
            //If no tile is present..
            if (boardArray[anchor[0], anchor[1]].CharTile == null)
            {
                //If word up until current tile is valid..
                if (Helper.CheckWordValidity(Dawg, partialWord))
                {
                    //If the move (word, row and column indexes) has not been added already..
                    if (!Moves.Any(m => m.Word.Equals(partialWord)))
                    {
                        //Adds generated move to list of valid moves
                        Dictionary <BoardTile, CharTile> tilesUsed = new Dictionary <BoardTile, CharTile>();

                        //Adds tiles that were used in move
                        for (int i = 0; i < partialWord.Length; i++)
                        {
                            var letter    = partialWord[i];
                            var boardTile = boardArray[anchor[0], anchor[1] - partialWord.Length + i];

                            if (boardTile.CharTile != null)
                            {
                                tilesUsed.Add(boardTile, boardTile.CharTile);
                            }
                            else
                            {
                                tilesUsed.Add(boardTile, tileExtendedWith);
                            }
                        }
                        validMovesList.Add(new GeneratedMove(boardIsHorizontal, anchor[1] - partialWord.Length, anchor[1] - 1, anchor, tilesUsed, boardBeforeMove, RackOfCurrentPlayer));
                    }
                }

                //GEts all letters that can follow current right part word
                HashSet <string> labelsOfDawgEdges = new HashSet <string>(new DawgEdgeEqualityComparer());
                var wordsWithCommonPreffix         = Dawg.MatchPrefix(partialWord);
                foreach (var word in wordsWithCommonPreffix)
                {
                    labelsOfDawgEdges.Add(word.Key.Substring(partialWord.Length));
                }
                foreach (var label in labelsOfDawgEdges)
                {
                    //If the valid letter is in our rack and can be played on the board tile, places it and extends right again
                    //with the newly filled board tile used as anchor if board limit is not reached
                    if (label == "")
                    {
                        continue;
                    }
                    if (RackOfCurrentPlayer.CheckIfTileIsInRack(label[0], true) &&
                        (!validCrossChecks.Any(c => c.Key == boardArray[anchor[0], anchor[1]]) ||
                         validCrossChecks.Any(c => c.Key == boardArray[anchor[0], anchor[1]] && c.Value.Any(x => x.Letter == label[0]))))
                    {
                        CharTile tileToWorkWith = null;
                        if (RackOfCurrentPlayer.CheckIfTileIsInRack(label[0], false))
                        {
                            tileToWorkWith = Dictionary.CharTiles.Where(c => c.Letter == label[0] && c.Score != 0).FirstOrDefault();
                        }
                        else
                        {
                            tileToWorkWith = Dictionary.CharTiles.Where(c => c.Letter == '*').FirstOrDefault();
                        }
                        RackOfCurrentPlayer.SubstractFromRack(tileToWorkWith);
                        boardArray[anchor[0], anchor[1]].CharTile = Dictionary.CharTiles.Where(c => c.Letter == label[0] && c.Score == tileToWorkWith.Score).FirstOrDefault();
                        if (anchor[1] < boardArray.GetLength(1) - 1)
                        {
                            ExtendRight(partialWord + label[0], new int[] { anchor[0], anchor[1] + 1 }, boardArray, validCrossChecks, validMovesList, boardIsHorizontal, boardBeforeMove, tileToWorkWith);
                        }

                        //Otherwise places the tile on the last empty square of the board, checks if its valid and doesn't attempt to extend anymore
                        else
                        {
                            var finalWord = partialWord + boardArray[anchor[0], anchor[1]].CharTile.Letter;
                            if (Helper.CheckWordValidity(Dawg, finalWord))
                            {
                                if (!Moves.Any(m => m.Word.Equals(finalWord)))
                                {
                                    Dictionary <BoardTile, CharTile> tilesUsed = new Dictionary <BoardTile, CharTile>();
                                    for (int i = 0; i < finalWord.Length; i++)
                                    {
                                        var letter    = finalWord[i];
                                        var boardTile = boardArray[anchor[0], anchor[1] - finalWord.Length + 1 + i];
                                        if (boardTile.CharTile != null)
                                        {
                                            tilesUsed.Add(boardTile, boardTile.CharTile);
                                        }
                                        else
                                        {
                                            tilesUsed.Add(boardTile, tileToWorkWith);
                                        }
                                    }
                                    validMovesList.Add(new GeneratedMove(boardIsHorizontal, anchor[1] - finalWord.Length + 1, anchor[1], anchor, tilesUsed, boardBeforeMove, RackOfCurrentPlayer));
                                }
                            }
                        }
                        RackOfCurrentPlayer.AddToRack(tileToWorkWith);
                        boardArray[anchor[0], anchor[1]].CharTile = null;
                    }
                }
            }
            //Otherwise if the current tile is already taken and not empty, used letter from board tile to build to the right again
            else
            {
                var tile = boardArray[anchor[0], anchor[1]].CharTile;
                HashSet <string> labelsOfDawgEdges = new HashSet <string>(new DawgEdgeEqualityComparer());
                var wordsWithCommonPreffix         = Dawg.MatchPrefix(partialWord + tile.Letter);
                foreach (var word in wordsWithCommonPreffix)
                {
                    labelsOfDawgEdges.Add(word.Key.Substring((partialWord + tile.Letter).Length));
                }

                //Extends right if any letters can follow the current right part
                if (labelsOfDawgEdges.Any() && anchor[1] < boardArray.GetLength(1) - 1)
                {
                    ExtendRight(partialWord + tile.Letter, new int[] { anchor[0], anchor[1] + 1 }, boardArray, validCrossChecks, validMovesList, boardIsHorizontal, boardBeforeMove, tile);
                }
            }
        }
Exemplo n.º 14
0
        //public static Dictionary<BoardTile, List<CharTile>> GetValidCrossChecksOneWay(BoardTile[,] boardArray, WordDictionary dictionary)
        //{
        //    var dawg = LoadDawg(dictionary.GameLanguage);
        //    Dictionary<BoardTile, List<CharTile>> validCrossChecks = new Dictionary<BoardTile, List<CharTile>>();
        //    List<int[]> tilesAlreadyChecked = new List<int[]>();
        //    StringBuilder sb = new StringBuilder();
        //    for (int i = 0; i < boardArray.GetLength(0); i++)
        //    {
        //        for (int j = 0; j < boardArray.GetLength(1); j++)
        //        {
        //            sb.Clear();
        //            if (boardArray[i, j].CharTile == null)
        //            {
        //                var upIndexCounter = i;
        //                var downIndexCounter = i;

        //                while (upIndexCounter > 0 && boardArray[upIndexCounter - 1, j].CharTile != null)
        //                {
        //                    sb.Insert(0, boardArray[upIndexCounter - 1, j].CharTile.Letter);
        //                    upIndexCounter--;
        //                }
        //                sb.Append("_");
        //                while (downIndexCounter < boardArray.GetLength(0) - 1 && boardArray[downIndexCounter + 1, j].CharTile != null)
        //                {
        //                    sb.Append(boardArray[downIndexCounter + 1, j].CharTile.Letter);
        //                    downIndexCounter++;
        //                }
        //                if (sb.Length == 1)
        //                {
        //                    continue;
        //                }
        //                else
        //                {
        //                    var wordWithUnderscore = sb.ToString();
        //                    var sbTemp = new StringBuilder(wordWithUnderscore);
        //                    if (!validCrossChecks.ContainsKey(boardArray[i, j]))
        //                    {
        //                        validCrossChecks.Add(boardArray[i, j], new List<CharTile>());
        //                    }
        //                    foreach (var c in dictionary.CharTiles)
        //                    {
        //                        if (c.Score == 0) continue;
        //                        sbTemp.Replace('_', c.Letter);
        //                        if (CheckWordValidity(dawg, sbTemp.ToString()))
        //                        {
        //                            if (validCrossChecks.ContainsKey(boardArray[i, j]))
        //                            {
        //                                if (!validCrossChecks[boardArray[i, j]].Contains(c))
        //                                {
        //                                    validCrossChecks[boardArray[i, j]].Add(c);
        //                                }
        //                            }
        //                        }
        //                        sbTemp.Clear();
        //                        sbTemp.Append(wordWithUnderscore);
        //                    }
        //                }
        //            }
        //        }
        //    }
        //    return validCrossChecks;
        //}

        /// <summary>
        /// Goes through a board and gets all anchors and crosschecks for board tiles
        /// </summary>
        /// <param name="boardArray">Array to go over. May be untransposed or transposed</param>
        /// <param name="dictionary">Collection of CharTiles to look up to</param>
        /// <param name="validCrossChecks">List of valid cross checks to update</param>
        /// <param name="anchors">List of anchors to update</param>
        public static void GetValidCrossChecksAndAnchors(BoardTile[,] boardArray, WordDictionary dictionary, Dictionary <BoardTile, List <CharTile> > validCrossChecks, List <int[]> anchors)
        {
            var           dawg            = LoadDawg(dictionary.GameLanguage);
            StringBuilder sb              = new StringBuilder();
            var           noMovesMadeYet  = false;
            var           startTileRow    = 0;
            var           startTileColumn = 0;

            for (int i = 0; i < boardArray.GetLength(0); i++)
            {
                for (int j = 0; j < boardArray.GetLength(1); j++)
                {
                    ///If board tile has been played on the Start tile, the game hasn't started
                    if (boardArray[i, j].CharTile == null)
                    {
                        if (boardArray[i, j].BoardTileTypeID == BoardTileTypeEnum.Start)
                        {
                            startTileRow    = i;
                            startTileColumn = j;
                            noMovesMadeYet  = true;
                        }


                        ///Gets letters from above and below current tile to form a word with a gap from the currently iterated board tile
                        sb.Clear();
                        var upIndexCounter   = i;
                        var downIndexCounter = i;

                        while (upIndexCounter > 0 && boardArray[upIndexCounter - 1, j].CharTile != null)
                        {
                            sb.Insert(0, boardArray[upIndexCounter - 1, j].CharTile.Letter);
                            upIndexCounter--;
                        }
                        sb.Append("_");
                        while (downIndexCounter < boardArray.GetLength(0) - 1 && boardArray[downIndexCounter + 1, j].CharTile != null)
                        {
                            sb.Append(boardArray[downIndexCounter + 1, j].CharTile.Letter);
                            downIndexCounter++;
                        }

                        //If no word is formed, continue to next board tile
                        if (sb.Length == 1)
                        {
                            continue;
                        }

                        //Else section replaces gap with all letters in alphabet to see which letters would fit to make a valid word
                        //Letters form the valid cross check set
                        //Cross check is stored as a dictionary object of board tile and a collection of char tiles
                        //This means for a given board tile, the following letters from the char tiles are valid
                        //If the collection is empty, no letter is a valid fit for the board tile
                        //If board tile (key) entry doesn't exist in the list, all letters are valid for that board tile (for now)
                        else
                        {
                            var wordWithUnderscore = sb.ToString();
                            var sbTemp             = new StringBuilder(wordWithUnderscore);
                            if (!validCrossChecks.ContainsKey(boardArray[i, j]))
                            {
                                validCrossChecks.Add(boardArray[i, j], new List <CharTile>());
                            }
                            foreach (var c in dictionary.CharTiles)
                            {
                                if (c.Score == 0)
                                {
                                    continue;
                                }
                                sbTemp.Replace('_', c.Letter);
                                if (CheckWordValidity(dawg, sbTemp.ToString()))
                                {
                                    if (validCrossChecks.ContainsKey(boardArray[i, j]))
                                    {
                                        if (!validCrossChecks[boardArray[i, j]].Contains(c))
                                        {
                                            validCrossChecks[boardArray[i, j]].Add(c);
                                        }
                                    }
                                }
                                sbTemp.Clear();
                                sbTemp.Append(wordWithUnderscore);
                            }
                        }
                        //Checks surrounding tiles if they can be used as anchors
                    }
                    else
                    {
                        if (i > 0 && boardArray[i - 1, j].CharTile == null)
                        {
                            if (anchors != null)
                            {
                                var coordinates = new int[] { i - 1, j };
                                if (!anchors.Any(c => c[0] == coordinates[0] && c[1] == coordinates[1]))
                                {
                                    anchors.Add(coordinates);
                                }
                            }
                        }

                        if (i < boardArray.GetLength(0) - 1 && boardArray[i + 1, j].CharTile == null)
                        {
                            if (anchors != null)
                            {
                                var coordinates = new int[] { i + 1, j };
                                if (!anchors.Any(c => c[0] == coordinates[0] && c[1] == coordinates[1]))
                                {
                                    anchors.Add(coordinates);
                                }
                            }
                        }

                        if (j > 0 && boardArray[i, j - 1].CharTile == null)
                        {
                            {
                                var coordinates = new int[] { i, j - 1 };
                                if (!anchors.Any(c => c[0] == coordinates[0] && c[1] == coordinates[1]))
                                {
                                    anchors.Add(coordinates);
                                }
                            }
                        }

                        if (j < boardArray.GetLength(1) - 1 && boardArray[i, j + 1].CharTile == null)
                        {
                            var coordinates = new int[] { i, j + 1 };
                            if (!anchors.Any(c => c[0] == coordinates[0] && c[1] == coordinates[1]))
                            {
                                anchors.Add(coordinates);
                            }
                        }
                    }
                }
            }
            if (noMovesMadeYet)
            {
                anchors.Clear();
                anchors.Add(new int[] { startTileRow, startTileColumn });
            }
            return;
        }