I am making a (2X2) Sudoku game and I need to complete a puzzle. That means that some digits are immutable (they cannot be moved out of place.
In a 2X2 game, there are 16 Digit
s. The problem facts are row
s, column
s and block
s (get it?). The row
is the only planning variable.
I specified boolean fixed
as attribute for Digit
. But (as per the user guide), I found no place to implement it.
What are the ways to actually make some planning entities immutable?
I find these methods:
moveFactory
that changes the row
only if it is immutable. This method is not documented.row
is not equal to a fixed_row
, break a hard constraint.@ValueRangeFromPlanningProperty
. Let the immutable entities have a value_range
of a single element, and the mutable entities have have a list that excludes the fixed rows. This seems unsustainable for anything larger than a Sudoku project, right? And there are (my?) alleged pitfalls that derail the solver?Extra question: is method #3 the recommended way for something like a timetabling problem (allocate subject-teacher to a possible period)?
Option 4: The fixed digits are problem facts: instances of a class that does not have a @PlanningEntity annotation. The non-fixed digits are planning entities: instances of a class that does have a @PlanningEntity.
If you'd like to reuse the same class for both for design purposes: