// A game can be constructed with the default board, or a specified
 // board.
 public OwariLogic()
 {
     // Create a new default board.
     GameBoard board = new OwariBoard();
     // Create the game state using the board we generated.
     this.state = new OwariGameState(board);
 }
        // Return a full copy.
        public override GameBoard Copy()
        {
            OwariBoard b = new OwariBoard();

            for (int i = 0; i < this.buckets.Length; i++)
            {
                b.buckets[i] = this.buckets[i];
            }
            return b;
        }
            // Constructor parses a message string into a BoardState object.
            // Throws an exception if the message string does not represent a
            // valid BoardState message.
            public BoardState(string msg)
            {
                if (!GameMessage.IsBoardState(msg))
                    throw new Exception("This is not a BoardState message.");

                // Remove all whitespace from the message string.
                string msgString = RemoveAllWhiteSpace(msg);

                this.data = msgString;

                // Strip packet wrapper.
                string boardString = GameMessage.GetMessageData(msg);

                boardString = boardString.Substring(1, boardString.Length - 2);

                this.board = GetBoardStateFromString(msgString);
            }
            // Parse a message string into a OwariBoard object.
            private OwariBoard GetBoardStateFromString(string msg)
            {
                OwariBoard board = new OwariBoard();

                // Strip packet wrapper.
                string boardString = OwariMessage.GetMessageData(msg);

                // Parse the string.
                string[] pits = Regex.Split(boardString, ",");

                for (int i = 0; i < board.Buckets.Length; i++)
                    board.Buckets[i] = Int32.Parse(pits[i]);

                return board;
            }
            // Constructor to instantiate a new BoardState based on the
            // specified OwariBoard object.
            public BoardState(OwariBoard aBoard)
            {
                this.data = GetStringFromBoardState(aBoard);

                this.board = (OwariBoard)aBoard.Copy();
            }