com.act365.sudoku
Class LeastCandidatesCell

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

public class LeastCandidatesCell
extends StrategyBase
implements IStrategy

The LeastCandidatesCell strategy calculates the number of seemingly valid candidates (of course, for a problem with a unique solution, there is only one strictly valid candidate for each cell - a candidate is deemed 'seemingly valid' if it isn't blatantly contradicted by another cell in that row, column or subgrid) for each cell in the grid, and fills the cells with the least number of possible candidates first.


Constructor Summary
LeastCandidatesCell(boolean randomize)
          Creates a new LeastCandidatesCell instance.
LeastCandidatesCell(boolean findMany, boolean randomize, boolean explain)
          Creates a new LeastCandidatesCell instance.
 
Method Summary
 int findCandidates()
          Finds the cells that have the least number of candidates.
 void setup(Grid grid)
          Sets the state variables.
 
Methods inherited from class com.act365.sudoku.StrategyBase
explainsReasoning, getBestReason, getBestValue, getBestX, getBestY, getLastWrittenMove, getNumberOfCandidates, getReason, getReasonCandidate, getScore, getThreadLength, getThreadX, getThreadY, getValueCandidate, getXCandidate, getYCandidate, reset, reset, selectCandidate, setCandidate, toString, unwind, updateState
 
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, getLastWrittenMove, getNumberOfCandidates, getReason, getReasonCandidate, getScore, getThreadLength, getThreadX, getThreadY, getValueCandidate, getXCandidate, getYCandidate, reset, reset, selectCandidate, setCandidate, toString, unwind, updateState
 

Constructor Detail

LeastCandidatesCell

public LeastCandidatesCell(boolean randomize)
Creates a new LeastCandidatesCell instance.

Parameters:
randomize - whether the final candidate should be randomly chosen from the set of possibles

LeastCandidatesCell

public LeastCandidatesCell(boolean findMany,
                           boolean randomize,
                           boolean explain)
Creates a new LeastCandidatesCell instance.

Parameters:
findMany - whether an entire set of possible values should be found
randomize - whether the final candidate should be randomly chosen from the set of possibles
explain - whether explanatory debug should be produced
Method Detail

setup

public void setup(Grid grid)
           throws java.lang.Exception
Sets the state variables.

Specified by:
setup in interface IStrategy
Throws:
java.lang.Exception

findCandidates

public int findCandidates()
Finds the cells that have the least number of candidates.

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