Example #1
0
        private static void BoardTest7()
        {
            Debug.WriteLine( "Testing generate interface..." );

            // There's no way to exhaustively test this interface in a repeatable
            // way since the SudokuEngine uses random number generation. The best
            // we can do is exercise the interface a statistically-relevant number
            // of times and hope that any bugs show themselves in the sampling.
            for ( int i = 0; i < 10; ++i )
            {
                SudokuEngine.Board board = new SudokuEngine.Board();
                board.generate();
                Debug.WriteLine( "Generated board:" );
                Debug.WriteLine( board );
                board.solve();
                Debug.WriteLine( "Solved board:" );
                Debug.WriteLine( board );
                verifyBoard( board );
            }
        }
Example #2
0
        /// <summary>
        /// Make a new board.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void newToolStripMenuItem_Click( object sender, EventArgs e )
        {
            this.Cursor = Cursors.WaitCursor;

            // Gneerate a new board.
            gameBoard.generate();
            solutionBoard = gameBoard.deepCopy();
            solutionBoard.solve();

            // Display the new board.
            for ( int row = 0; row < gameBoard.Rows; ++row )
            {
                for ( int col = 0; col < gameBoard.Columns; ++col )
                {
                    if ( gameBoard[ row, col ].Entry != 0 )
                        gameBoard[ row, col ].Locked = true;
                    else
                        gameBoard[ row, col ].Locked = false;

                    updateCellDisplay( row, col );
                }
            }

            this.Cursor = Cursors.Default;
        }