How do you test for fact existence in the RHS of rules in Clips? I'm trying to design a rule that will "score" the current state by counting how many goal facts exist. It's obvious how to test for facts in the LHS, but I can't find how to do the equivalent in the RHS.
I want to do something like this, albeit this isn't valid Clips code:
(defrule score-state ""
?score <- (score (value ?value))
=>
(modify ?score (value (+ (exists (goal-1)) (exists (goal-2)) (exists (goal-3))))))
So that if none of the goal states exist, then there would exist the fact (score (value 0)). Conversely, if all the goal states existed, then there would exist the fact (score (value 3)).
The reference manual mentions the function fact-existp, but this seems to require it's passed a fact address. I tried using it like (fact-existp (goal-1)), but Clips gives me a syntax error.