com.act365.sudoku
Class Traversal

java.lang.Object
  extended bycom.act365.sudoku.Traversal

public class Traversal
extends java.lang.Object

A Traversal object is used to store the moves made during an attempt to solve a Su Doku puzzle. All moves are recorded, even those that are subsequently unwound. The object isn't used in anger anywhere throughout the project but it provides useful debug.


Constructor Summary
Traversal(int capacity, int maxElims)
           
 
Method Summary
 boolean addMove(int mx, int my, int mz)
          Adds the move represented by the state trio (mx,my,mz) to the traversal.
 int capacity()
          Returns the traversal capacity.
 int depth()
          Returns the current size.
 int find(int[] findX, int[] findY, int[] findZ, int nFindMoves)
          Looks for the sequence of moves (findX,findY,findZ) of length nFindMoves anywhere within the traversal.
 int find(int start, int end, int[] findX, int[] findY, int[] findZ, int nFindMoves)
          Looks for the sequence of moves (findX,findY,findZ) of length nFindMoves within the traversal between the position start and end.
 void reset()
          Resets the traversal.
 int size()
          Returns the current size.
 java.lang.String toString()
          Returns a string representation of the traversal that lists each move made.
 boolean unwind()
          Unwinds the last move from the traversal.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Traversal

public Traversal(int capacity,
                 int maxElims)
Parameters:
capacity -
Method Detail

addMove

public boolean addMove(int mx,
                       int my,
                       int mz)
Adds the move represented by the state trio (mx,my,mz) to the traversal. The trio could represent the move (mx,my):=mz, however, e.g. in the case of Least Candidates Number, it might have another meaning. The Traversal doesn't care.


unwind

public boolean unwind()
Unwinds the last move from the traversal. (Of course, the move is still recorded, but the traversal progresses as though the move weren't there.)


find

public int find(int start,
                int end,
                int[] findX,
                int[] findY,
                int[] findZ,
                int nFindMoves)
Looks for the sequence of moves (findX,findY,findZ) of length nFindMoves within the traversal between the position start and end. A match is considered to have a occurred if some non-trivial subset of the moves is found. The returned value is the end position where the match occurred. When no match is found, -1 will be returned.


find

public int find(int[] findX,
                int[] findY,
                int[] findZ,
                int nFindMoves)
Looks for the sequence of moves (findX,findY,findZ) of length nFindMoves anywhere within the traversal. A match is considered to have a occurred if some non-trivial subset of the moves is found. The returned value is the end position where the match occurred. When no match is found, -1 will be returned.


reset

public void reset()
Resets the traversal.


size

public int size()
Returns the current size.


depth

public int depth()
Returns the current size.


capacity

public int capacity()
Returns the traversal capacity.


toString

public java.lang.String toString()
Returns a string representation of the traversal that lists each move made.