Skip to content

dan4am/SudokuSolver

Repository files navigation

1. Description.

Sudoku solver is a project encompasses 3 sub-projects:

  1. A sudoku game and a solver.
  2. An android solver.
  3. A sudoku generator that reads the screen of an android device.

Prerequisites

To launch the scripts, execute in a command prompt:

python3 main_with_multiprocessing

or

python3 main_with_multithreading

this litle GUI will appear:

Sudoku Solver GUI

1.1. Sudoku game + solver.

The sudoku game is a classic sudoku game, each time it is launched it starts with a different grid chosen in a database of over 1 million grids.

Pygame window

The solver algorithm is a customized iterative Crosshatching algorithm that fills x number of cells at each iteration. For all the empty cells in a given line, column or sub-grid of the sudoku grid, the algorithm tries each number from 1 to 9 and fills the cell with a number if the number is the only possible solution.

crosshatching illustration

a. commands

esc → Clear the grid.

s → Launch the solver.

r → Load a random grid.

1.2. Android solver.

prerequisite.

This module requires the user to have Fassor sudoku android app installed on his android device.

This module also requires the user to install ADB (Android Debbuging Bridge) on his computer and connect his android device to the computer.

In order to execute adb commands in a python script, the user has to install the pure-python-adb library by executing the following command :

pip install -U pure-python-adb

adb permits the user (among other things) to take screen shots of the android device and saves it on the computer. This module leverages that feature to take screen shots of the sudoku app and to convert it into an array of integers using openCV for image porcessing and pytesseract for character recognition.

The solver will then solve the sudoku directly on the android device by sending touch instructions through adb.

Getting started.

To launch the module, the user must specify whether his device is connected to the computer by WiFi or via USB. If the device is connected via WiFi, the user must specify the ip address of the device, here is how to retrieve it.

connect with device android solver.

If all necessary preparations have been done, the user can push the start button. After aproximatively 30 seconds, the solver will start solving the sudoku grid on the user's android device.

1.3. Android sudoku generator.

prerequisite.

Getting started.

This module uses the same librairies as the previous one, but instead of solving the sudoku grid, this module will copy the current sudoku grid from the android device to the pygame GUI on the computer.

To launch the module, the user must specify whether his device is connected to the computer by WiFi or via USB. If the device is connected via WiFi, the user must specify the ip address of the device, here is how to retrieve it.

connect with device

If all necessary preparations have been done, the user can push the start button. a pygame window will appear with the same grid as the one on the android device.

grid from device

About

Sudoku game+ solver + android solver

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages