A GUI for PROLOG Sudoku Puzzles

by Todd Klasik

This program will dump the results from the Sudoku puzzle you give it to a text file named sudoku_puzzle.pl in the folder where you ran "java SudokuGUI".

The file will be encoded in the following PROLOG format for the squares you input. The squares are numbers from 0 to 81 and the square(Sqr,Value) predicate stores the square number and its value:

puzzle(9,7) :- 
assertz(square(7,1)),
assertz(square(9,6)),assertz(square(11,3)),assertz(square(13,7)),
assertz(square(21,4)),assertz(square(23,2)),assertz(square(25,9)),assertz(square(26,9)),
assertz(square(27,5)),assertz(square(32,8)),
assertz(square(37,3)),assertz(square(38,2)),assertz(square(40,5)),assertz(square(42,1)),assertz(square(43,6)),
assertz(square(48,1)),assertz(square(53,2)),
assertz(square(54,7)),assertz(square(55,4)),assertz(square(57,9)),assertz(square(59,3)),
assertz(square(67,1)),assertz(square(69,9)),assertz(square(71,7)),
assertz(square(73,1)).

You can either load the file directly into prolog or copy and paste it into the prolog_puzzles.pl file and add puzzle (9,7) (while commenting out puzzle(9,6)). And you are ready to go. Please send any bugs or sugguestions to me at todd.klasik@trincoll.edu.

Source Code

  • SudokuGUI.java
  • QueryBox.java

    To Run

    1. Download the source code.
    2. Compile: javac SudokuGUI.java
    3. Run: java SudokuGUI