Reputation: 19
i'm trying to incorporate jess into an existing java system. the part i want jess to replace picks players based rules involving gamesplayed, etc. i have developed rules in a standalone clip file which i execute inside eclipse. i have done this before on a similar system. on the current system when i move the data creation portion to java the data related rules don't fire. I've included samples of data created by java in problem code - f-1, same clp but with hard coded facts - f-10. i have just included one fact from each run to save space.
java is clearly creating valid facts. one difference is MAIN::JCJessPlayer vs MAIN::player. i'm not sure what causes that.
so my question is why are these facts not causing the defrule test-for-a-fact to fire? any help would be appreciated.
john
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; MatchBuilder goals: ; 1) everyone plays same number of games ; 2) player waiting the longest plays next ; 3) minimize teams with same players ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(import com.soundsoftware.boccemgrjess.JCJessPlayer)
(deftemplate player (declare (from-class JCJessPlayer)))
(watch activations)
(defrule start-execution
(declare (salience 50))
=>
; (facts)
(printout t "Executing" crlf))
(defrule test-for-a-fact
(declare (salience 40))
(player (initials ?i))
=>
(printout t "Player" ?i crlf))
(defrule finalize
(declare (salience -10))
=>
(facts)
(printout t "Done" crlf)
)
Java generated facts
==> Activation: MAIN::start-execution : f-0
==> Activation: MAIN::finalize : f-0
Executing
f-0 (MAIN::initial-fact)
f-1 (MAIN::JCJessPlayer (available TRUE) (candidate FALSE) (class <Java-Object:java.lang.Class>) (gamesPlayed 0) (initials "LZA") (key "fe75d3c4-d6fc-483e-b3a9-f90d42b88849") (lastplaytime 100) (picked FALSE) (OBJECT <Java-Object:com.soundsoftware.boccemgrjess.JCJessPlayer>))
For a total of 11 facts in module MAIN. Done
Hard coded deffacts
==> Activation: MAIN::start-execution : f-0
==> Activation: MAIN::finalize : f-0
==> Activation: MAIN::test-for-a-fact : f-1
==> Activation: MAIN::test-for-a-fact : f-2
==> Activation: MAIN::test-for-a-fact : f-3
==> Activation: MAIN::test-for-a-fact : f-4
==> Activation: MAIN::test-for-a-fact : f-5
==> Activation: MAIN::test-for-a-fact : f-6
==> Activation: MAIN::test-for-a-fact : f-7
==> Activation: MAIN::test-for-a-fact : f-8
==> Activation: MAIN::test-for-a-fact : f-9
==> Activation: MAIN::test-for-a-fact : f-10
Executing
PlayerLZA
PlayerJZU
PlayerAZU
PlayerAZJ
PlayerJZC
PlayerPZH
PlayerBZU
PlayerKZU
PlayerMZW
PlayerDZW
f-0 (MAIN::initial-fact)
f-10 (MAIN::player (available true) (candidate false) (class <Java-Object:jess.SerializablePD>) (gamesPlayed 0) (initials "LZA") (key <Java-Object:jess.SerializablePD>) (lastplaytime 10) (picked false) (OBJECT nil))
For a total of 11 facts in module MAIN. Done
So, it appears in deftemplate the variable name must match the class name.
NG (deftemplate player (declare (from-class JCJessPlayer)))
Works (deftemplate JCJessPlayer (declare (from-class JCJessPlayer)))
Upvotes: 0
Views: 37