|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object smithers.logicpuzzles.HanjieSolver
public class HanjieSolver
Class containing a solver for hanjie puzzles. This solver uses methods that
only look at a single row or column (called a "line") at once. The solving
methods print messages on System.out
if they find lines which are
impossible.
Constructor Summary | |
---|---|
HanjieSolver(Hanjie puzzle)
Constructs a new solver for the given puzzle. |
|
HanjieSolver(HanjieState puzzleState)
Constructs a new solver to work from a given state. |
Method Summary | |
---|---|
int |
getLastChange()
Returns the location of the last change. |
boolean |
getLastWasRow()
Returns whether or not the last change was a row. |
Hanjie |
getPuzzle()
Returns the puzzle which is being solved. |
HanjieState |
getState()
Returns the state of the solution attempt. |
void |
nextLine()
Advances to the next line (row/column). |
boolean |
pass()
Performs a single pass through either the rows or columns. |
boolean |
solve()
Attempts to completely solve the puzzle. |
int |
solveLine()
Solves the current line (row/column) as much as possible. |
void |
start()
Restarts the solving process. |
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 |
Constructor Detail |
---|
public HanjieSolver(Hanjie puzzle)
puzzle
- the puzzle to solvepublic HanjieSolver(HanjieState puzzleState)
puzzleState
- the puzzle state to work fromMethod Detail |
---|
public Hanjie getPuzzle()
PuzzleSolver
getPuzzle
in interface PuzzleSolver<Hanjie,HanjieState>
Puzzle
which this PuzzleSolver
relates to.public HanjieState getState()
PuzzleSolver
getState
in interface PuzzleSolver<Hanjie,HanjieState>
Puzzle
which this State
relates to.public void start()
PuzzleSolver
start
in interface PuzzleSolver<Hanjie,HanjieState>
public boolean step()
PuzzleSolver
puzzle
.
step
in interface PuzzleSolver<Hanjie,HanjieState>
true
iff a change was madepublic boolean pass()
pass
in interface PuzzleSolver<Hanjie,HanjieState>
true
iff a change was madepublic boolean solve()
PuzzleSolver
while (this.step());
and to
while (this.pass());
solve
in interface PuzzleSolver<Hanjie,HanjieState>
true
iff a change was madepublic int getLastChange()
public boolean getLastWasRow()
true
iff the last change was a rowpublic void nextLine()
public int solveLine()
0
if no change was made, 1
if a hidden change
was made, 3
if a change was made or -1
if the
line was impossible.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |