/*This module checks the board and returns the cell number * for computer player to click using Randomization algorithms. * * 1. Check the current status of the game board. * 2. Pick random number from 0-5 for row. * 3. Pick random number from 0-5 for column. * 4. Check if the cell with picked row and column number is available. * 5. If the chosen cell is taken then produce another random cell until empty cell is chosen. * 6. Return the row and column number of the cell as an integer array. * * */ private int[] easyMove() { int[] cell = { -1, -1 }; Boolean checking = true; Random rand = new Random(); int randRow = rand.Next(0, 6), randCol = rand.Next(0, 6); while (checking) { if (gameBoard.getGameMatrix()[randRow, randCol] == 0) { checking = false; } else { randCol = rand.Next(0, 6); randRow = rand.Next(0, 6); } } cell[0] = randRow; cell[1] = randCol; return(cell); }
/******************************************************************************** * Creates board network nodes reflecting the gameBoard passed in as a parameter * ********************************************************************************/ void CreateBoardNodes(Board gameBoard) { int[,] boardMatrix = gameBoard.getGameMatrix(); for (int r = 0; r < NUM_ROW; r++) { for (int c = 0; c < NUM_COL; c++) { boardNetwork[r, c] = new BoardNode(boardMatrix[r, c], r, c); } } }
public Board(Board board) { gameBoard = board.getGameMatrix(); calculateScore(); }