Prolog Sudoku Solver

From UBC Wiki

Authors:

Zhe Li, Yifei Chen, Yixin Wang

What is the problem?

This project intends to construct a Sudoku solver to help player solve the sudoko game. The player can construct a sudoku by putting an array of position and number pair. The solver consumes the input from player, and computes the solution. Player can ask the computer for hints or solution.

What is the something extra?

A hint is to give the first empty cell in the present sudoku while a solution is present the solution computed by the solver directed on the screen. Player can do the sudoku and give his/her intermediate step to the solver to check if he/she is on the right track, which means if that number is placed on that position, then the solver will check whether there is one possible solution. When there is no solution, the solver will report to the player that there is something wrong in the Sudoku.

We now build a GUI using Java as our frontend and our Prolog functions as our backend. This enables the user to interact with the program much more conveniently.

What did we learn from doing this?

Since we also did the Sudoku for Project1, we make some improvements for our Project2.

Algorithm: We improve our algorithm, still using brute-force, and the speed of running complex Sudokus (even the input is none) has been improved. Comparing with Haskell, we think that Prolog is not as good as Haskell to implement our project, because Haskell highly depends on natural recusion which makes the logic much easier to understand. Also Haskell has the I/O library which makes it convenient to interact with the user while Prolog can only be input with the entire query.

GUI: We now build a GUI using Java as our frontend and our Prolog functions as our backend. Instead of typing the value and positions by hand in the terminal, we can ask the user to input the value on the textfield which also gives user a clear output than just returning a list in the terminal.

Links to code etc

https://github.com/lizhe918/CPSC312-2019WT1-Project2