com.act365.sudoku
Class LeastCandidatesHybrid

java.lang.Object
  extended bycom.act365.sudoku.StrategyBase
      extended bycom.act365.sudoku.LeastCandidatesHybrid
All Implemented Interfaces:
IStrategy

public class LeastCandidatesHybrid
extends StrategyBase
implements IStrategy

LeastCandidatesHybrid combines the Least Candidates Cell and Least Candidates Number strategies.


Constructor Summary
LeastCandidatesHybrid(boolean randomize)
          Sets up a LeastCandidatesHybrid strategy with an optional random element.
LeastCandidatesHybrid(boolean randomize, boolean checkInvulnerable, boolean explain)
          Sets up a LeastCandidatesHybrid strategy with an optional random element.
 
Method Summary
 int findCandidates()
          Finds candidates for the next move.
 int getLastWrittenMove()
          Determines the last move for which two or more alternatives existed.
 void setup(Grid grid)
          Sets up the strategy to solve the given grid.
 boolean unwind(int newNMoves, boolean reset)
          Unwind the stack.
 void updateState(int x, int y, int value, java.lang.String reason, boolean writeState)
          Updates state variables.
 
Methods inherited from class com.act365.sudoku.StrategyBase
explainsReasoning, getBestReason, getBestValue, getBestX, getBestY, getNumberOfCandidates, getReason, getReasonCandidate, getScore, getThreadLength, getThreadX, getThreadY, getValueCandidate, getXCandidate, getYCandidate, reset, reset, selectCandidate, setCandidate, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.act365.sudoku.IStrategy
explainsReasoning, getBestReason, getBestValue, getBestX, getBestY, getNumberOfCandidates, getReason, getReasonCandidate, getScore, getThreadLength, getThreadX, getThreadY, getValueCandidate, getXCandidate, getYCandidate, reset, reset, selectCandidate, setCandidate, toString
 

Constructor Detail

LeastCandidatesHybrid

public LeastCandidatesHybrid(boolean randomize,
                             boolean checkInvulnerable,
                             boolean explain)
Sets up a LeastCandidatesHybrid strategy with an optional random element.

Parameters:
randomize - whether the final candidates should be chosen randomly from its peers
checkInvulnerable - indicates whether the moves should be post-filtered using the Invulnerable state grid.
explain - whether explanatory debug should be produced

LeastCandidatesHybrid

public LeastCandidatesHybrid(boolean randomize)
Sets up a LeastCandidatesHybrid strategy with an optional random element.

Method Detail

setup

public void setup(Grid grid)
           throws java.lang.Exception
Sets up the strategy to solve the given grid.

Specified by:
setup in interface IStrategy
Throws:
java.lang.Exception
See Also:
IStrategy.setup(Grid)

findCandidates

public int findCandidates()
Finds candidates for the next move. The LeastCandidatesCell search is performed before the LeastCandidatesNumber search because it will find a result much quicker in the very common case that very few candidates exist.

Specified by:
findCandidates in interface IStrategy
Returns:
number of candidates
See Also:
IStrategy.findCandidates()

updateState

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

Specified by:
updateState in interface IStrategy
Overrides:
updateState in class StrategyBase
Throws:
java.lang.Exception
See Also:
IStrategy.updateState(int,int,int,String,boolean)

unwind

public boolean unwind(int newNMoves,
                      boolean reset)
Unwind the stack.

Specified by:
unwind in interface IStrategy
Overrides:
unwind in class StrategyBase
See Also:
IStrategy.unwind(int,boolean)

getLastWrittenMove

public int getLastWrittenMove()
Determines the last move for which two or more alternatives existed.

Specified by:
getLastWrittenMove in interface IStrategy
Overrides:
getLastWrittenMove in class StrategyBase