com.act365.sudoku
Class StrategyBase

java.lang.Object
  extended bycom.act365.sudoku.StrategyBase
Direct Known Subclasses:
FirstAvailable, LeastCandidatesCell, LeastCandidatesHybrid, LeastCandidatesNumber, MostCandidates

public abstract class StrategyBase
extends java.lang.Object

StrategyBase handles several thread-related function common to most implementors of IStrategy.

See Also:
IStrategy

Method Summary
 boolean explainsReasoning()
          Indicates whether the strategy explains its reasoning.
 java.lang.String getBestReason()
          Returns the reason for the best 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 that had been made at the last point where two alternative moves existed.
 int getNumberOfCandidates()
          Returns the umber of candidates.
 java.lang.String getReason(int move)
          Returns the reasoning behind the given move.
 java.lang.String getReasonCandidate(int index)
          Reasons the reason behind the given candidate.
 int getScore()
          Returns a measure of the confidence the strategy holds in its candidates.
 int getThreadLength()
          Returns thread length.
 int getThreadX(int move)
          Returns x-coordinate of move at given thread position.
 int getThreadY(int move)
          Returns y-coordinate of move at given thread position.
 int getValueCandidate(int index)
          Returns the value-coordinate of the given candidate.
 int getXCandidate(int index)
          Returns the x-coordinate of the given candidate.
 int getYCandidate(int index)
          Returns the y-coordinate of the given candidate.
 void reset()
          Resets each cell that appears on the thread.
 void reset(int move)
          Resets each cell that appears on the thread after the given move.
 void selectCandidate()
          Selects a single candidate from the available list.
 void setCandidate()
          Sets the value chosen by findCandidates().
 java.lang.String toString()
          Dumps the thread to the given output stream.
 boolean unwind(int newNMoves, boolean reset)
          Unwinds the the thread and reinstates state variables.
 void updateState(int x, int y, int value, java.lang.String reason, boolean writeState)
          Updates state variables.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

selectCandidate

public void selectCandidate()
Selects a single candidate from the available list.


setCandidate

public void setCandidate()
Sets the value chosen by findCandidates().

See Also:
IStrategy.setCandidate()

updateState

public void updateState(int x,
                        int y,
                        int value,
                        java.lang.String reason,
                        boolean writeState)
                 throws java.lang.Exception
Updates state variables.

Throws:
java.lang.Exception
See Also:
IStrategy.updateState(int,int,int,String,boolean)

unwind

public boolean unwind(int newNMoves,
                      boolean reset)
Unwinds the the thread and reinstates state variables.

See Also:
IStrategy.unwind(int,boolean)

reset

public void reset()
Resets each cell that appears on the thread.

See Also:
IStrategy.reset()

reset

public void reset(int move)
Resets each cell that appears on the thread after the given move.

See Also:
IStrategy.reset(int)

getBestX

public int getBestX()
Returns the x-coordinate of the best candidate move.

See Also:
IStrategy.getBestX()

getBestY

public int getBestY()
Returns the y-coordinate of the best candidate move.

See Also:
IStrategy.getBestY()

getBestValue

public int getBestValue()
Returns the value of the best candidate move.

See Also:
IStrategy.getBestValue()

getBestReason

public java.lang.String getBestReason()
Returns the reason for the best move.

See Also:
IStrategy.getBestReason()

getXCandidate

public int getXCandidate(int index)
Returns the x-coordinate of the given candidate.


getYCandidate

public int getYCandidate(int index)
Returns the y-coordinate of the given candidate.


getValueCandidate

public int getValueCandidate(int index)
Returns the value-coordinate of the given candidate.


getReasonCandidate

public java.lang.String getReasonCandidate(int index)
Reasons the reason behind the given candidate.


getNumberOfCandidates

public int getNumberOfCandidates()
Returns the umber of candidates.


getThreadLength

public int getThreadLength()
Returns thread length.

See Also:
IStrategy.getThreadLength()

getThreadX

public int getThreadX(int move)
Returns x-coordinate of move at given thread position.

See Also:
IStrategy.getThreadX(int)

getThreadY

public int getThreadY(int move)
Returns y-coordinate of move at given thread position.

See Also:
IStrategy.getThreadY(int)

getReason

public java.lang.String getReason(int move)
Returns the reasoning behind the given move.

See Also:
IStrategy.getReason(int)

explainsReasoning

public boolean explainsReasoning()
Indicates whether the strategy explains its reasoning.


getScore

public int getScore()
Returns a measure of the confidence the strategy holds in its candidates.

See Also:
IStrategy.getScore()

getLastWrittenMove

public int getLastWrittenMove()
Returns the number of moves that had been made at the last point where two alternative moves existed.


toString

public java.lang.String toString()
Dumps the thread to the given output stream.