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 Digits. The problem facts are rows, columns and blocks (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:
- Implement a
moveFactorythat changes therowonly if it is immutable. This method is not documented. - If the
rowis not equal to afixed_row, break a hard constraint. - Use
@ValueRangeFromPlanningProperty. Let the immutable entities have avalue_rangeof 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:
Option 5: https://issues.jboss.org/browse/JBRULES-3359