smithers.logicpuzzles
Interface PuzzleSolver<P extends Puzzle,Q extends PuzzleState<P>>

All Known Implementing Classes:
AbstractPuzzleSolver, HanjieSolver, MosaicSolver, SlitherlinkSolver

public interface PuzzleSolver<P extends Puzzle,Q extends PuzzleState<P>>

Interface representing a solver for a certain type of logic puzzle. The solver may assume that if any other object modifies the state then the method start() will be called before the solving methods are used again.


Method Summary
 P getPuzzle()
          Returns the puzzle which is being solved.
 Q getState()
          Returns the state of the solution attempt.
 boolean pass()
          Performs a single pass through the puzzle.
 boolean solve()
          Attempts to completely solve the puzzle.
 void start()
          Restarts the solving process.
 boolean step()
          Performs a single step in the solving process.
 

Method Detail

getPuzzle

P getPuzzle()
Returns the puzzle which is being solved.

Returns:
the Puzzle which this PuzzleSolver relates to.

getState

Q getState()
Returns the state of the solution attempt. This method should always return the same object, with updates being made to it as the solution progresses.

Returns:
the Puzzle which this State relates to.

start

void start()
Restarts the solving process. This method should set the solver's internal status to reflect any changes made to the state.


step

boolean step()
Performs a single step in the solving process. This method should do the smallest amount of work which results in a change being made to puzzle.

Returns:
true iff a change was made

pass

boolean pass()
Performs a single pass through the puzzle. This method should perform some small amount of the solution to the puzzle. Typically, this method should perform roughly a single pass through the clues of the puzzle, or through one subcollection of the clues (such as the row or column clues). The work done by this method should ideally lie somewhere between step and solve. If no intermediate is available, this should perform the same function as step. Note that unlike the other solving methods, this method may return false even when this solver can still make further deductions.

Returns:
true iff a change was made

solve

boolean solve()
Attempts to completely solve the puzzle. If the puzzle cannot be solved, this ahould solve as much as is possible. Calling this method should be equivalent to while (this.step()); and to while (this.pass());

Returns:
true iff a change was made