Anyone want to take this on?
-------- Original Message --------
Subject: Unsolicited "Improvements" to the sudoku example
Date: Thu, 6 Nov 2008 04:17:31 +0000 (UTC)
To Whom It May Concern:
Here is an unsolicited patch that addresses some to do items in the
1. The patch combines the two drl files into a single file,
sudokuSolverValidatorWithGuess.drl, and separates them by using
2. It simplifies the checking of whether all possible cells have a
solution by creating an object, basecell, for each cell that needs
a resolved cell and introduces it into the memory space. A rule
then checks baseCells against resolvedCellValues for the memory set.
3. Changes the way issues are raised by removing the issues array and
adding various types of SudokuStatusMessages so that the status of
the solution can be tracked by a separate status listener. This
allows the model to track the status of solution.
4. Provides a solution to the rule 11 guessing rule. This is a little
complex as the process is to identify a cell with multiple
possible values and pick one of them and then run a copy of the
solver to its logical conclusion and identify the result which is
one of the following: solved, in error or indeterminate. The
process is repeated until a solved solution is identified.
Each pass keeps tracks the removal and insertion of memory facts
so that they can be reversed at the end of the logical test. At
the end of each test the effects of the test are reversed and one
of the following is done depending on the result. If the test is
indeterminate; keep testing. If the solution is solved; set the
guessed cell value pair as the only possible value for the cell
and run the base testing routines. If the solution is logically
inconsistent; remove the cell value as a possibleCellValue, if
this leaves only one possibleCellValue then run the base testing
Note, the error cases don’t necessarily solve the puzzle the end
so sometimes you need to guess multiple times.
5. Changed the constants and samples into a strategy pattern that can
support 4x4 and 6x6 grids as well as the 9x9 grid. This was done
to simplify testing as it is easier to test an indeterminate 4x4
grid then a hard 9x9 grid when guessing.
Note: the samples for 4x4 and 6x6 have indeterminate examples which can
end up in multiple solutions. The 4x4 grid can reverse the values 1 and
3 depending order of resolution. The 6x6 can display various behavior,
including solving a subset of the puzzle in one step and eliminating
only one possible cell for several guesses before hitting on a solution.
I hope this helps.
Show replies by date