Op 31-01-12 07:51, aitchnyu schreef: > I am making a 2X2 sudoku game, modeled after Nqueens example. A `Digit` class > is assigned a `column` and `row` object. The `row` is the planning entity. > > But a sudoku game also has a `block`, which is to be calculated from `row` > and `column`. Two digits cannot share a block. A block is null when the row > is null, and a numerical value that will be equal for all digits in the row. > > Question: where do I tell the `Digit` object to recalculate it's `block`? Don't. A move just changes the value of a Digit: it's up to the score rules to use score rules to calculate the effect to the Block.
you could do a score rule like this: when Digit($v : value, $b: block, $id) Digit(value == $v, block == $b, id > $id) then // the value $v twice in the same block > I > did it in doMove, but it is misses most places the object is updated (as per > my attempts at logging). Must I set it to update itself when the `row` > property of the object changes, say at `setRow()`? > > A 2X2 sudoku: http://mypuzzle.org/sudoku/kid.html > > private integer block; > ... > public Integer getBlock(){ > return block; > } > public void setBlock(int not_used){ > if(this.row==null) > this.block=null; > else > this.block=10*(this.row.getIndex()/2)+this.column.getIndex()/2; > } > > -- > View this message in context: > http://drools.46999.n3.nabble.com/Where-do-I-code-the-calculation-for-a-derieved-property-of-the-planning-entity-tp3702411p3702411.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > _______________________________________________ > rules-users mailing list > [email protected] > https://lists.jboss.org/mailman/listinfo/rules-users > -- With kind regards, Geoffrey De Smet _______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users
