Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

There are a number of utility methods to perform useful self-evident tasks--see the Javadocs.

  • currentBoard - a field which references the board that is currently being solved.
  • loadStrs -- takes a vector of strings, which are the rows of a puzzle, and translates the strings into the cells of a new current board.  This method is compatible with the puzzle generation utilities, but is not yet hooked up to them.
  • validateBoard - performs a validation check on the current board and returns a string describing the current state of the board.   This method calls validateCellSet on every cell set of the rows, columns and blocks of the board.   Examine this method carefully to get ideas on how to process the board!
    • Important Note: This method should NOT BE USED as part of the solving process!!   It was designed to give textual feedback to the user and not to be part of a solving algorithm.   You will be marked down for using this method and attempting to parse it return string to determine the state of the board.  In fact, it is less effecient to separately check the validity of the board during the reduction and solving  process -- the board reduction algorithm (reduceBoard()) should be able to determine the status of the board as a byproduct of its actions, thus negating the need for a separate validation operation.
  • getSolvedCellValues -- gets a HashSet<Integer> containing all the values from the solved cells in a cell set.   This is used when reducing a cell.
  • countCellChoices -- a utility method that will return the number of choices in all the unsolved cells in a given cell set
  • Wiki Markup
    {{{*}reduceCellSet{*}}} \-\- \[<span style="color: #ff0000"><em>Student implemented</em></span>\]&nbsp; perform a single reduction pass on every cell in a given cell set.
    • Start by having reduceBoard simply call this method on a specific cell set.
  • Wiki Markup
    {{{*}reduceBoard{*}}} \-\- \[<span style="color: #ff0000"><em>Student implemented</em></span>\]&nbsp; perform a single reduction pass on every cell in the board.
  • Wiki Markup
    {{{*}solve{*}}} \-\- \[<span style="color: #ff0000"><em>Student implemented</em></span>\] perform reduction passes on the board until the board is either&nbsp;shown to be solved or unsolvable.&nbsp;&nbsp; This method should be able to handle boards that are reducible, irreducible, or unsolvable.
    • The method is defined as also allowing a return status of "irreducible", though in the final implementation, that should never occur.    This return value is allowed so that you can do a partial implementation of the solve algorithm before you implement solveIrreducibleBoard
  • Wiki Markup
    {{{*}findMinChoiceCell{*}}} \-\- \[<span style="color: #ff0000"><em>Student implemented</em></span>\] Use some heuristic to find the best choice for a cell whose values represent the fastest path to a solution.&nbsp;&nbsp; This method is used when an irreducible board is encountered and the solving process needs to iterate through the choices of a given cell to test for possible solutions.&nbsp;&nbsp; If a board is solvable, on _any_ cell, &nbsp;at least one value choice in an unsolved cell will always lead towards a solution.&nbsp;&nbsp; Other choices may lead to unsolvable boards.\\
  • Wiki Markup
    {{{*}solveIrreducibleBoard{*}}} \-\- \[<span style="color: #ff0000"><em>Student implemented</em></span>\] Given an irreducible board (a board that doesn't change when a reduction pass is performed), looks for a solution by testing the choices of a chosen cell.&nbsp;&nbsp; Note that a particular value choice in a cell could lead to an irreducible board, so this is fundamentally a recursive process\!&nbsp;

...