AlexIzydorczyk / sudoku

C++ sudoku game
83 stars 50 forks source link

sudoku

C++ sudoku game

Program Use

Game can be started by compiling (with makefile) and running sudoku

  1. Default action is to start interactive, 9x9 game

  2. To fill in cell, enter the column number, row number, and value you want to enter (1 based). Separate with spaces, commas, or any other delimiter (besides an integer of course)

  3. At any time, enter "Solve" to have the backtracer solve the game for you based on your current position.

  4. If you've walked yoursel into an impossible configuration you will be prompted to first clear the board

  5. Once solved, you will be asked if you want to play again

  6. Run speed test / alternate game configurations using command flags below

Command line flags can be used to configure the game

-s --seed Set the random seed to replicate results -u --Unittest Runs unit (speed) test with both solvers. Specify number of times to run -g --gamesize Integer value to specify game size ie 9 for 9x9 game, 16 for 16x16 etc. -n --nobs Specify number of pre-filled values to include (ie. immutable Sudoku cells) -v --verbose Add flag with no argument for verbose output after every unit test. No effect if game played in interactive mode

Notes:

Items to grade:

  1. Game Logic/ Gameplay of the interactive game + command line tools/speed tests
  2. Back-tracking solver (the "solve" function in solve.cpp)
  3. Alternating projection solver (the "DR" function in altproj.cpp)

Project Contributions

  1. Matt:

    • implemented two Sudoku solvers: backtracking and alternating projections
    • implemented function to generate a Sudoku puzzle
  2. Alex:

    • implements actual game-play and game-play logic (taking user input, printing/formatting to screen etc.)
    • implemented comamnd line flags and associated functions(ie. unit testing / timing functions)

Notes on Building Project

Build reqiures the armadillo library. You can download it from the website http://arma.sourceforge.net/.

References

  1. Pseudo-code for backtracking algorithm

  2. Idea to use Douglas-Rachford splitting to solve Sudoku

    • "Recent Results on Douglas–Rachford Methods for Combinatorial Optimization Problems"
  3. Function timing code