smithers.logicpuzzles
Class SlitherlinkSolver

java.lang.Object
  extended by smithers.logicpuzzles.AbstractPuzzleSolver<Slitherlink,SlitherlinkState>
      extended by smithers.logicpuzzles.SlitherlinkSolver
All Implemented Interfaces:
PuzzleSolver<Slitherlink,SlitherlinkState>

public class SlitherlinkSolver
extends AbstractPuzzleSolver<Slitherlink,SlitherlinkState>

Solver for slitherlink puzzles.


Field Summary
 
Fields inherited from class smithers.logicpuzzles.AbstractPuzzleSolver
puzzle, state
 
Constructor Summary
SlitherlinkSolver(Slitherlink puzzle)
          Creates a new solver for the specified puzzle.
SlitherlinkSolver(SlitherlinkState state)
          Creates a new solver to work from the specified state.
 
Method Summary
 SlitherlinkState makeState(Slitherlink puzzle)
          Makes a new state for the specified puzzle.
 boolean nextStep()
          Advances to the next step of solving the puzzle.
 int solveStep()
          Attempts to solve the current step of the puzzle.
 void start()
          Restarts the solving process.
 
Methods inherited from class smithers.logicpuzzles.AbstractPuzzleSolver
getPuzzle, getState, pass, solve, step
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SlitherlinkSolver

public SlitherlinkSolver(Slitherlink puzzle)
Creates a new solver for the specified puzzle.

Parameters:
puzzle - the puzzle to solve

SlitherlinkSolver

public SlitherlinkSolver(SlitherlinkState state)
Creates a new solver to work from the specified state.

Parameters:
state - the puzzle state to work from
Method Detail

makeState

public SlitherlinkState makeState(Slitherlink puzzle)
Description copied from class: AbstractPuzzleSolver
Makes a new state for the specified puzzle. Usually this will simply call a constructor which takes puzzle as an argument.

Specified by:
makeState in class AbstractPuzzleSolver<Slitherlink,SlitherlinkState>
Parameters:
puzzle - the puzzle to create a state for
Returns:
a state for the given puzzle

start

public void start()
Description copied from interface: PuzzleSolver
Restarts the solving process. This method should set the solver's internal status to reflect any changes made to the state.


solveStep

public int solveStep()
Description copied from class: AbstractPuzzleSolver
Attempts to solve the current step of the puzzle. This method must return 0 if it made no changes, 1 if it made a change to its internal data, but no change to the state of the puzzle, or any number greater than 1 if a change has been made to the state.

Specified by:
solveStep in class AbstractPuzzleSolver<Slitherlink,SlitherlinkState>
Returns:
the return value described above

nextStep

public boolean nextStep()
Description copied from class: AbstractPuzzleSolver
Advances to the next step of solving the puzzle.

Specified by:
nextStep in class AbstractPuzzleSolver<Slitherlink,SlitherlinkState>
Returns:
true iff the solver has started a new 'pass'