sudoku
Class PlayEngine

java.lang.Object
  extended by sudoku.PlayEngine

public class PlayEngine
extends java.lang.Object

The guts of Sudoku. The PlayEngine is capable of finding correct moves.


Constructor Summary
PlayEngine(Field field)
          Create a PlayEngine to play the given field.
 
Method Summary
 Field playRandomlyUntilSolvedOrQuit()
          Alternative solver that makes random choices at random locations to create a new solution, typically from an empty field.
 Field playUntilSolvedOrQuit()
          Main playing routine.
 void setCheckMultiples(boolean check)
          Call this method with an argument of true to have the PlayEngine check for multiple solutions and give an exception if found.
 void setNoBacktrack()
          Call this method if PlayEngine is to disallow backtracking.
static SolutionType verify(Field f)
          Play out the argument field to see if it is solvable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PlayEngine

public PlayEngine(Field field)
Create a PlayEngine to play the given field.

Parameters:
field -
Method Detail

setNoBacktrack

public void setNoBacktrack()
Call this method if PlayEngine is to disallow backtracking. This means that the puzzle must be solvable with only obvious moves.


setCheckMultiples

public void setCheckMultiples(boolean check)
Call this method with an argument of true to have the PlayEngine check for multiple solutions and give an exception if found. We only want to create puzzles with unique solutions, I guess.

Parameters:
check -

verify

public static SolutionType verify(Field f)
Play out the argument field to see if it is solvable. An EASY_SOLUTION has only obvious moves (no backtracking necessary).

Parameters:
f -
Returns:
NO_SOLUTION, EASY_SOLUTION, or HARD_SOLUTION

playUntilSolvedOrQuit

public Field playUntilSolvedOrQuit()
                            throws MultipleSolutionException
Main playing routine. Plays until solved, depending on backtracking if enabled.

Returns:
Solved field, if one exists, or null if none exists.
Throws:
MultipleSolutionException - if checkMultiples(true) called first and there is more than one solution possible.

playRandomlyUntilSolvedOrQuit

public Field playRandomlyUntilSolvedOrQuit()
Alternative solver that makes random choices at random locations to create a new solution, typically from an empty field. Never checks for multiple solutions since the goal is to find a single random solution.

Returns:
solved field or null if none found.