com.act365.sudoku
Class Solver

java.lang.Object
  extended byjava.lang.Thread
      extended bycom.act365.sudoku.Solver
All Implemented Interfaces:
java.lang.Runnable

public class Solver
extends java.lang.Thread

A Solver instance solves a grid on a thread that exits gracefully if interrupted.


Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Solver(Grid grid, IStrategy strategy)
          Creates a Solver instance.
Solver(Grid grid, IStrategy strategy, IStrategy composeSolver, int composeSolverThreshold, int maxSolns, java.io.PrintStream debug)
          Creates a Solver instance.
Solver(java.lang.String threadName, Composer composer, int index, Grid grid, IStrategy strategy, IStrategy composeSolver, int composeSolverThreshold, int maxSolns, int maxUnwinds, int maxComplexity, java.io.PrintStream debug, boolean useNative)
          Creates a Solver instance.
 
Method Summary
 int getComplexity()
          Determines the complexity figure for a puzzle.
 int getNumberOfSolutions()
          Returns the number of solutions found.
 int getNumberOfUnwinds()
          Returns the number of times the tree had to be unwound in order to solve the grid.
static void main(java.lang.String[] args)
          Command-line app to solve Su Doku puzzles.
 void run()
          Runs the solver on a thread.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Solver

public Solver(java.lang.String threadName,
              Composer composer,
              int index,
              Grid grid,
              IStrategy strategy,
              IStrategy composeSolver,
              int composeSolverThreshold,
              int maxSolns,
              int maxUnwinds,
              int maxComplexity,
              java.io.PrintStream debug,
              boolean useNative)
Creates a Solver instance.

Parameters:
threadName - thread name
composer - composer object to which to report
index - composer-defined index number for solver
grid - grid to be solved
strategy - strategy to be used to complete the grid
composeSolver - solver to be used at each step by the composer in order to check solution uniqueness
maxSolns - the maximum number of solutions to find before exit (0 for unlimited solutions)
maxUnwinds - the maximum permitted number of unwinds (0 for no limit)
maxComplexity - the maximum permitted complexity (0 for no limit)
debug - (optional) destination for debug info

Solver

public Solver(Grid grid,
              IStrategy strategy,
              IStrategy composeSolver,
              int composeSolverThreshold,
              int maxSolns,
              java.io.PrintStream debug)
Creates a Solver instance.

Parameters:
grid - grid to be solved
strategy - strategy to be used to complete the grid
composeSolver - solver to be used at each step by the composer in order to check solution uniqueness
maxSolns - the maximum number of solution to find before exit (0 for no limit)
debug - (optional) destination for debug info

Solver

public Solver(Grid grid,
              IStrategy strategy)
Creates a Solver instance.

Parameters:
grid - grid to be solved
strategy - strategy to be used to complete the grid
Method Detail

run

public void run()
Runs the solver on a thread.


getNumberOfSolutions

public int getNumberOfSolutions()
Returns the number of solutions found.


getNumberOfUnwinds

public int getNumberOfUnwinds()
Returns the number of times the tree had to be unwound in order to solve the grid.


getComplexity

public int getComplexity()
Determines the complexity figure for a puzzle.


main

public static void main(java.lang.String[] args)
Command-line app to solve Su Doku puzzles.
Solver [-m max solutions] [-s strategy] [-v] [-u max unwinds]
[-m max solutions] stipulates the maximum number of solutions to be reported. The default is for all solutions to be reported.
[-s strategy] stipulates the strategy to be used. the default is Least Candidates Hybrid.
[-v] stipulates whether the app should execute in verbose mode. The default is no.
The puzzle will be read from standard input.