///////////////////////////////////////////////////////////////// ////// 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 }
// [2016.12.01] // [SC] put a given tile on a specified board position; validCheck is true then verify if the move conforms to game rules protected int putTileOnBoard(int rowIndex, int colIndex, TileZeroTile tile, bool validCheck) { return(virtualBoard.addTile(rowIndex, colIndex, tile, validCheck, null)); }