|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object smithers.logicpuzzles.AbstractPuzzleSolver<P,Q>
public abstract class AbstractPuzzleSolver<P extends Puzzle,Q extends PuzzleState<P>>
Class to aid implementations of PuzzleSolver
.
Field Summary | |
---|---|
protected P |
puzzle
|
protected Q |
state
|
Constructor Summary | |
---|---|
AbstractPuzzleSolver(P puzzle)
Creates a new solver for the specified puzzle. |
|
AbstractPuzzleSolver(Q state)
Creates a new solver to work from the specified state. |
Method Summary | |
---|---|
P |
getPuzzle()
Returns the puzzle which is being solved. |
Q |
getState()
Returns the state of the solution attempt. |
abstract Q |
makeState(P puzzle)
Makes a new state for the specified puzzle. |
abstract boolean |
nextStep()
Advances to the next step of solving the puzzle. |
boolean |
pass()
Performs a single pass through the puzzle. |
boolean |
solve()
Attempts to completely solve the puzzle. |
abstract int |
solveStep()
Attempts to solve the current step of the puzzle. |
boolean |
step()
Performs a single step in the solving process. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface smithers.logicpuzzles.PuzzleSolver |
---|
start |
Field Detail |
---|
protected P extends Puzzle puzzle
protected Q extends PuzzleState<P> state
Constructor Detail |
---|
public AbstractPuzzleSolver(P puzzle)
puzzle
- the puzzle to solvepublic AbstractPuzzleSolver(Q state)
state
- the puzzle state to work fromMethod Detail |
---|
public P getPuzzle()
getPuzzle
in interface PuzzleSolver<P extends Puzzle,Q extends PuzzleState<P>>
Puzzle
which this PuzzleSolver
relates to.public Q getState()
getState
in interface PuzzleSolver<P extends Puzzle,Q extends PuzzleState<P>>
Puzzle
which this State
relates to.public abstract Q makeState(P puzzle)
puzzle
as an argument.
puzzle
- the puzzle to create a state for
public abstract int solveStep()
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.
public abstract boolean nextStep()
true
iff the solver has started a new 'pass'public boolean step()
puzzle
.
step
in interface PuzzleSolver<P extends Puzzle,Q extends PuzzleState<P>>
true
iff a change was madepublic boolean pass()
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.
pass
in interface PuzzleSolver<P extends Puzzle,Q extends PuzzleState<P>>
true
iff a change was madepublic boolean solve()
while (this.step());
and to
while (this.pass());
solve
in interface PuzzleSolver<P extends Puzzle,Q extends PuzzleState<P>>
true
iff a change was made
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |