Hello
I have an Java-Class BiddingHistory containing a vector of abstract
data types (composed of an Enum and an int).
The Vector is only changed by java functions.
At the moment I convert the Vector to a jess List, translating each
entry to a jess symbol. So I can use it easily in rules.
But I think about whether it is better to use the class as a shadow
fact. I then would have a multislot by the method
public Object[] getHistory() {
return vector.toArray();
}
When I do this in jess:
(deftemplate BiddingHistory
(declare (from-class BiddingHistory)))
(bind ?a (new BiddingHistory (PlayerPosition.SOUTH)))
(add ?a)
(facts)
I get this:
f-0 (MAIN::BiddingHistory (class <Java-Object:java.lang.Class>)
(dealer <Java-Object:PlayerPosition>) (history ) (lastNormalBid nil)
(lastPartnerBid nil) (OBJECT <Java-Object:BiddingHistory>))
because the vector is empty.
When I now fill the vector
(bind ?bid (new Bid (Denomination.SPADE) 1))
(call ?a addBid ?bid)
(facts)
I get an error:
Async Error: Jess reported an error in routine DefinstanceList.updateShadowFact.
Message: Invalid argument.
...
Caused by: java.lang.IllegalArgumentException: Argument is not an array
...
The addBid-Method looks like this:
public void addBid(Bid bid) {
Vector old = new Vector(this.bids);
this.bids.add(bid);
pcs.firePropertyChange("history", old, bids);
}
Do I something wrong? How can I use Vectors in shadow facts?
I thougt also about the performance. When I want to match the content
of the Vector, I have to create the ADT:
(defrule rulename
"description"
(MAIN::BiddingHistory (history
$?leading
?bid&:(eq ?bid (new (Bid (Denomination.SPADE) 1)))
))
=>
actions
)
So perhaps from a performance viewpoint, it could be better to use
symbols. But I think this is more error-prone than using shadow facts.
I am interested in your opinion about this.
Helge
--------------------------------------------------------------------
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]
--------------------------------------------------------------------