Exemplo n.º 1
0
        /////////////////////////////////////////////////////////////////
        ////// START: A code for creating all possible permutations of board positions
        ////// of tiles in given list, starting from left-most tile in the array

        private void boardPosPermAddChildNodes(CandidateTileSeq candTileSeq, int currTileIndex, TreeNode parentNode, TileZeroTile[,] tileArray, VirtualBoard virtualBoard)
        {
            if (currTileIndex >= candTileSeq.getTileCount())
            {
                return;
            }

            TileZeroTile tile = candTileSeq.getTileAt(currTileIndex);

            for (int currRowIndex = 0; currRowIndex < tileArray.GetLength(0); currRowIndex++)
            {
                for (int currColIndex = 0; currColIndex < tileArray.GetLength(1); currColIndex++)
                {
                    int resultScore = virtualBoard.isValidMove(currRowIndex, currColIndex, tile, true, tileArray, false);

                    if (resultScore != Cfg.NONE)
                    {
                        TileZeroTile[,] newTileArray = Cfg.createBoardCopy(tileArray);
                        virtualBoard.addTile(currRowIndex, currColIndex, tile, false, newTileArray);
                        TreeNode childNode = parentNode.addChildNodeValue(new AbstractPos(currTileIndex, currRowIndex, currColIndex, resultScore));
                        boardPosPermAddChildNodes(candTileSeq, currTileIndex + 1, childNode, newTileArray, virtualBoard);
                    }
                }
            }

            boardPosPermAddChildNodes(candTileSeq, currTileIndex + 1, parentNode, tileArray, virtualBoard); // [SC][2016.12.08] new code
        }
Exemplo n.º 2
0
 public bool isOrderedSubsetOf(CandidateTileSeq cts)
 {
     if (getTileCount() > cts.getTileCount())
     {
         return(false);
     }
     else
     {
         for (int tileIndex = 0; tileIndex < getTileCount(); tileIndex++)
         {
             if (!getTileAt(tileIndex).sameVisTile(cts.getTileAt(tileIndex)))
             {
                 return(false);
             }
         }
         return(true);
     }
 }