// constructor of MemoryGameLogic, initialize MemoryBoard and number of rows and columns internal MemoryGameLogic(int i_NumOfRows, int i_NumOfColumns, bool i_IsComputerPlaying) { m_Board = new MemoryBoard(i_NumOfRows, i_NumOfColumns); m_NumOfRows = i_NumOfRows; m_NumOfColumns = i_NumOfColumns; m_Random = new Random(); m_IsComputerPlaying = i_IsComputerPlaying; if (i_IsComputerPlaying) { m_UnExposeCells = new Dictionary <Tuple <int, int>, char>(); m_AIMemory = new Dictionary <Tuple <int, int>, char>(); } }
// given a board, prints the board in the required format as needed. internal static void printBoardToScreen(MemoryBoard i_Board) { StringBuilder boardToPrint = new StringBuilder(); int rowLength = i_Board.GetNumberOfRows(); int colLength = i_Board.GetNumberOfColumns(); // prints the first row for (int i = 0; i <= colLength; i++) { if (i == 0) { boardToPrint.Append(" "); } else { boardToPrint.Append((char)(k_FirstColumnIndex + i - 1)); boardToPrint.Append(" "); } } helperPrinter(colLength, ref boardToPrint); for (int i = 0; i < rowLength; i++) { boardToPrint.Append((char)(k_FirstRowIndex + i)); boardToPrint.Append(" | "); for (int j = 0; j < colLength; j++) { string strToAppend = i_Board.GetBoolExpose(i, j) ? i_Board.GetCellValue(i, j).ToString() : (" "); boardToPrint.Append(strToAppend); boardToPrint.Append(" | "); } helperPrinter(colLength, ref boardToPrint); } Console.Write(boardToPrint); }