com.act365.sudoku
Class LeastCandidatesNumber

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

public class LeastCandidatesNumber
extends StrategyBase
implements IStrategy

The LeastCandidatesNumber strategy calculates, for each combination of number and sector (where a sector is a generic term that covers rows, columns and subgrids), the number of valid candidate cells and fills the the sectors with the least number of possible candidate cells first.


Constructor Summary
LeastCandidatesNumber(boolean randomize)
          Creates a new LeastCandidatesNumber instance to solve the given grid.
LeastCandidatesNumber(boolean findMany, boolean randomize, boolean explain)
          Creates a new LeastCandidatesNumber instance to solve the given grid.
 
Method Summary
 int findCandidates()
          Find the values and sectors 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

LeastCandidatesNumber

public LeastCandidatesNumber(boolean randomize)
Creates a new LeastCandidatesNumber instance to solve the given grid.

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

LeastCandidatesNumber

public LeastCandidatesNumber(boolean findMany,
                             boolean randomize,
                             boolean explain)
Creates a new LeastCandidatesNumber instance to solve the given grid.

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()
Find the values and sectors that have the least number of candidates. As the code stands, there might well be duplicates.

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