Giter Site home page Giter Site logo

sudoku's Introduction

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:

  • Puzzles are always generating using a sort of reverse backtrace (ie. filling in diagonal using random permutation, solving puzzle, and then removing cells). This means that sometimes generating the puzzle takes longer than solving it (especially for big puzzles). The unit test times only the solver function
  • During the class demo, in the speed test, our first puzzle took an order of magnitude longer to solve for the backtracer than the other 9 puzzles. Upon investigation, it turns out that this was likely because of the constant random seed (there is significant variability in time to solve puzzles for backtracer, the Alternating Projections approach seems to be less variable for given puzzle configuration)

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

sudoku's People

Contributors

molson2 avatar alexizydorczyk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.