Sudoku solver is a project encompasses 3 sub-projects:
- A sudoku game and a solver.
- An android solver.
- A sudoku generator that reads the screen of an android device.
- python 3.9
- pygame 2.0.1
- numpy 1.20.3
- opencv-python 4.5
- pytesseract 0.3.7
- pure-python-adb 0.3.0
- Fassor sudoku android app
To launch the scripts, execute in a command prompt:
python3 main_with_multiprocessing
or
python3 main_with_multithreading
this litle GUI will appear:
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.
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.
esc
→ Clear the grid.
s
→ Launch the solver.
r
→ Load a random grid.
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.
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.
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.
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.
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.