Example #1
0
        /**
         *  Helper for updating board display object when state has changed
         */
        private static BoardDisplay UpdateBoardDisplay(BoardDisplay boardDisplay, Move[,] board)
        {
            for (int m = 0; m < _gameMetrics.GetM(); m++)
            {
                string preRow = "", row = "", postRow = "", lineRow = "";
                bool   isLastRow = m != _gameMetrics.GetM() - 1;

                for (int n = 0; n < _gameMetrics.GetN(); n++)
                {
                    bool isLastCol = n != _gameMetrics.GetN() - 1;

                    preRow  += String.Format("{0}{1}", boardDisplay.LONG, isLastCol ? "|" : "");
                    row     += String.Format("{0}{1}{2}{3}", boardDisplay.SHORT, board[m, n], boardDisplay.SHORT, isLastCol ? "|" : "");
                    postRow += String.Format("{0}{1}", boardDisplay.LONG, isLastCol ? "|" : "");

                    if (isLastRow)
                    {
                        lineRow += String.Format("{0}{1}", boardDisplay.SPLIT, isLastCol ? "-" : "");
                    }
                }

                boardDisplay.SetRowByIndex(m, new BoardDisplay.Row(preRow, row, postRow, lineRow));
            }

            return(boardDisplay);
        }
Example #2
0
 /**
  *  Helper for displaying current board state to console
  */
 private static void PrintBoardDisplay(BoardDisplay boardDisplay)
 {
     Console.ForegroundColor = ConsoleColor.Gray;
     for (int row = 0; row < boardDisplay.GetNumRows(); row++)
     {
         BoardDisplay.Row curRow = boardDisplay.GetRowByIndex(row);
         Console.WriteLine(curRow.GetPreRow());
         Console.WriteLine(curRow.GetRow());
         Console.WriteLine(curRow.GetPostRow());
         Console.WriteLine(curRow.GetLineRow());
     }
 }