Skip to content

Tal-Raveh/SudoCat

Repository files navigation

SudoCat Project

Grumpy cat has mastered Sudoku in heaven. Now he is back to solve your Sudoku puzzles!

The following repository include a Sudoku puzzle game. The game interface consist of three main options:
Gcat_MI

  1. Player game mode - Enable playing a random Sudoku game from a database of 10,000 different puzzles.
  2. Recursive solver - show an example of how to solve the current puzzle using a recursive method.
  3. CNN solver - Provide a solution to the current puzzle using a trained CNN algorithm. The network learned from a database of 100,000 different puzzles and solutions.

Each solved puzzle can be verified by its own solution provided by the database.

Gcat1 How to play

First, download the whole repository to a folder. Then locate the file 'gui_sudoku.py' and run it using any python console.

That's it, you are ready to play SudoCat! Be sure to check the different options...

Gcat2 Player game mode

Player mode is the defualt mode, it means you can write a number in each cell and check if you got it right. If you get it wrong, you get an error messege:

Gcat_ex

Gcat3 Recursive solver

Recursive method to solve any Sudoku puzzle:
Recursive example

The file responsible for this section - 'recursive_solver.py'.

Gcat4 CNN solver

We created a model with 2 dense layer's plus a dense layer for each cell in the sudoku (2 + 81 = 83 in total). We trained the model over 100,000 sudokus and 10 epochs. We got 99% correct sudokus over 10,000 testing data (data = sudokus):

Cnn1

If you want to load our trained model and test it:

  1. Download the whole repository to a folder.
  2. Unzip 'sudoku_trained-100000.part1.rar' and 'sudoku_trained-100000.part2.rar' to the main folder.
  3. Run "main_cnn.py".

If you want to train the model all you need to do is:

  1. Download the whole repository to a folder.
  2. Change the num_train_data and num_test_data as you wish.
  3. Open the file 'main_cnn.py' and make sure to uncomment "solver = train(...)", line 91.
  4. Uncomment "solver.save(NAME)", line 95 (Not obligatory, do it only if you want to save the model).
  5. Comment line 98, this line loads our model.

FYI : All the solved sudokus by the CNN model were saved in a csv file, so when you press solve, you get the solution from the csv file. We made it that way only to speed up the program.

About

Final project - Sudoku solver

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages