|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
A strategy is an algorithm that solves Su Doku problems. At each timestep, a strategy has to calculate a 'best' move (x,y):=z, which means that it will almost certainly choose to iterate over a three-dimensional space. Most strategies follow a least-candidates principle, which means that they will iterate over two dimensions (not necessarily x and y - any two abstract dimensions of the solver's choice will do) and select the value that gives rise to the smallest number of candidates in the third dimension.
Method Summary | |
boolean |
explainsReasoning()
Indicates whether the strategy explains its reasoning. |
int |
findCandidates()
Finds a set of candidates for the next move. |
java.lang.String |
getBestReason()
Returns the reason behind the best candidate move. |
int |
getBestValue()
Returns the value of the best candidate move. |
int |
getBestX()
Returns the x-coordinate of the best candidate move. |
int |
getBestY()
Returns the y-coordinate of the best candidate move. |
int |
getLastWrittenMove()
Returns the number of moves made at the last point where two or more alternatives had existed. |
int |
getNumberOfCandidates()
Returns the number of candidates generated by findCandidates(). |
java.lang.String |
getReason(int move)
Returns all the reasoning behind the thread. |
java.lang.String |
getReasonCandidate(int n)
Returns the reason behind the candidate generated by findCandidates(). |
int |
getScore()
Returns a measure of the confidence the strategy has in its candidates. |
int |
getThreadLength()
Returns the number of moves stored on the thread. |
int |
getThreadX(int move)
Returns the x-coordinate of the move at the given thread position. |
int |
getThreadY(int move)
Returns the y-coordinate of the move at the given thread position. |
int |
getValueCandidate(int n)
Returns the value-coordinates of the candidates generated by findCandidates(). |
int |
getXCandidate(int n)
Returns the x-coordinates of the candidates generated by findCandidates(). |
int |
getYCandidate(int n)
Returns the y-coordinates of the candidates generated by findCandidates(). |
void |
reset()
Resets the grid to its state before the strategy had been invoked. |
void |
reset(int move)
Resets the grid to its state before the given move. |
void |
selectCandidate()
Selects a single candidate from the set generated by findCandidates(), which it stores internally to be accessed by the functions getBestX(), getBestY() and getBestValue(). |
void |
setCandidate()
Sets the move chosen by selectCandidate() in the grid. |
void |
setup(Grid grid)
Sets up the strategy state variables to solve the given grid. |
java.lang.String |
toString()
Lists the moves in the current thread. |
boolean |
unwind(int newNMoves,
boolean reset)
Unwinds the most recent move and reverts the state grids. |
void |
updateState(int x,
int y,
int value,
java.lang.String reason,
boolean writeState)
Tells the strategy to update its internal state variables to account for the move (x,y):= value. |
Method Detail |
public void setup(Grid grid) throws java.lang.Exception
grid
- grid to be solved
java.lang.Exception
public int findCandidates()
getXCandidate(int)
,
getYCandidate(int)
,
getValueCandidate(int)
,
getReasonCandidate(int)
public int getScore()
public void selectCandidate()
findCandidates()
,
getBestX()
,
getBestY()
,
getBestValue()
,
getBestReason()
public void setCandidate()
selectCandidate()
public void updateState(int x, int y, int value, java.lang.String reason, boolean writeState) throws java.lang.Exception
writeState
- whether the updated state should be written to the stack
java.lang.Exception
public boolean unwind(int newNMoves, boolean reset)
newNMoves
- the point to which the stack should unwindreset
- whether to erase intervening moves from the grid
public void reset()
public void reset(int move)
public int getBestX()
public int getBestY()
public int getBestValue()
public java.lang.String getBestReason()
public int getNumberOfCandidates()
findCandidates()
public int getXCandidate(int n)
findCandidates()
public int getYCandidate(int n)
findCandidates()
public int getValueCandidate(int n)
findCandidates()
public java.lang.String getReasonCandidate(int n)
findCandidates()
public int getThreadLength()
public int getThreadX(int move)
public int getThreadY(int move)
public java.lang.String getReason(int move)
public boolean explainsReasoning()
public int getLastWrittenMove()
public java.lang.String toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |