- In Eclipse:
- File -> New -> Java Project
- Uncheck ‘Use Default Location’
- Click ‘Browse’ and select my ‘AI’ folder, then click on ‘Ok’ then ‘Finish’
“input.txt” and “output.txt” are located inside AI . My solver uses the output file of the generator ( a random generated puzzle ) as the input file. If you want to use your own input file for the solver:
- replace it with the original “output.txt”
- in Sudoku.java: comment out lines: 29, 31, 33
- so instead of:
//uses a generated puzzle as input
Generator gen = new Generator();
File output = new File("output.txt");
File input = new File("input.txt");
gen.generate(input, output);
solver.readInputFile(output);we would have:
//Generator gen = new Generator();
File output = new File("output.txt");
//File input = new File("input.txt");
//gen.generate(input, output);
solver.readInputFile(output);- Right click on AI in the ‘package explorer’ section
- Run As -> Java Application
- Answer the questions in Console to select which program to run.
After choosing the solver (by answering the question in Console section): answer the new question to select a heuristic (you can enter a time limit or keep the default one)
I divided the problem into three classes: Generator, Solver, and Sudoku
- Generator: generates a random standard Sudoku. It takes two file parameters (matching the given specifications)
- Solver: attempts solving a given standard Sudoku. It gets data from an input file. It uses: Backtracking and Bactracking+ForwardChecking
-
using junit:
... Sudoku\SRC> java -cp .;../lib/junit-4.12.jar;../lib/hamcrest-core-1.3.jar org.junit.runner.JUnitCore GeneratorTest