Hi there everyone, I'm a final year computer science student starting to
move into the world of computational intelligence (just signed up for a
masters degree!). And I'm impressed with Jess so far...
However the following problem is causing me a lot of grief so your
thoughts are appreciated.
----------------------------------------
In my definitions I create a 2x2 'board' of cells, composed of a (r)ow
and (c)olumn.
(deftemplate Cell
(slot r)
(slot c)
)
(deffacts init-board
(Cell (r 1) (c 1))
(Cell (r 1) (c 2))
(Cell (r 2) (c 1))
(Cell (r 2) (c 2))
)
----------------------------------------
Each cell can have zero or more 'Small' assertions, this is actually a
reference to a 'Small number' in Sudoku puzzles!
(deftemplate Small
(slot r)
(slot c)
(slot v)
)
----------------------------------------
If a cell has exactly 1 Small with the same r/c I would like a rule to
fire. For which I have written the following.
(defrule oneSmall
(Cell (r ?r) (c ?c))
(test (= (count-query-results numSmalls ?r ?c) 1))
=>
(printout t ?r"x"?c " has 1 small number crlf)
)
(defquery numSmalls
(declare (variables ?r ?c))
(Small (r ?r) (c ?c))
)
But the rule never fires.
----------------------------------------
I thought it was me until I confirmed that the following works as
expected:
I.e. I get a list of 4 TRUE/FALSE statements.
(defrule smallCount
(Cell (r ?r) (c ?c))
=>
(printout t (= (count-query-results numcandidates ?r ?c) 1) crlf)
)
----------------------------------------
Is this a known issue or am I over looking something here?
I just don't see how the (test) can return TRUE and the rule not fire.
Cheers for your time.
--
Dave Tapley <[EMAIL PROTECTED]>
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------