com.act365.sudoku
Class FirstAvailable

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

public class FirstAvailable
extends StrategyBase
implements IStrategy

The 'FirstAvailable' strategy always selects the first valid choice it finds in any situation - it doesn't make any attempt to rank the various alternatives. It is the only strategy implemented in Releases 1.0 and 1.1.


Constructor Summary
FirstAvailable()
          Creates a new FirstAvailable instance.
 
Method Summary
 int findCandidates()
          Locates the nearest empty cell, finds its lowest valid value and stores the result.
 void selectCandidate()
          Selects the single available candidate.
 void setup(Grid grid)
          Prepares the strategy to solve the given grid..
 boolean unwind(int newNMoves, boolean reset)
          Removes the current cell coordinates from the thread.
 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, getLastWrittenMove, getNumberOfCandidates, getReason, getReasonCandidate, getScore, getThreadLength, getThreadX, getThreadY, getValueCandidate, getXCandidate, getYCandidate, reset, reset, 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, getLastWrittenMove, getNumberOfCandidates, getReason, getReasonCandidate, getScore, getThreadLength, getThreadX, getThreadY, getValueCandidate, getXCandidate, getYCandidate, reset, reset, setCandidate, toString
 

Constructor Detail

FirstAvailable

public FirstAvailable()
Creates a new FirstAvailable instance.

Method Detail

setup

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

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

findCandidates

public int findCandidates()
Locates the nearest empty cell, finds its lowest valid value and stores the result.

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

selectCandidate

public void selectCandidate()
Selects the single available candidate.

Specified by:
selectCandidate in interface IStrategy
Overrides:
selectCandidate in class StrategyBase
See Also:
com.act365.sudoku

updateState

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

Specified by:
updateState in interface IStrategy
Overrides:
updateState in class StrategyBase
Parameters:
writeState - is ignored
See Also:
IStrategy.updateState(int,int,int,String,boolean)

unwind

public boolean unwind(int newNMoves,
                      boolean reset)
Removes the current cell coordinates from the thread.

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