This is the recommended way. Incidentally, since (time) returns time in seconds, not milliseconds, you can use (integer) instead of (long), and the resulting code will be a bit more efficient.
The rule "check-time" is a bit fragile, since it performs its action only at exactly a certain time (it uses "="). Since you never know precisely when a rule will fire, or what series of values the timestamp will take, it'd definitely be safer to use (test (>= ?timestamp ?time)) . I think Vincent Wolowski wrote: [Charset iso-8859-1 unsupported, filtering to ASCII...] > Hi all, > > I use Jess and Jade for building a multiagentsystem. > Some of my agent rules should do a timebased firing. > > I am not sure, what the best way is to do this. > > As an example, I try it in the following way: > > > (assert(the-first-fact)) > > (bind ?timestamp (long(time))) > (assert(timevalue ?timestamp)) > > (bind ?time (+ 5 (long(time)))) > (assert(timemarke ?time)) > > > (facts) > > (defrule check-time > ?f <- (the-first-fact) > (timevalue ?timestamp) > (timemarke ?time) > (test(= ?time ?timestamp)) > => > (retract ?f) > (bind ?time (long(time))) > (printout t "It fired at : "?time crlf) > ) > > > (defrule update-rule > (declare (salience -100)) > ?f <- (timevalue ?timestamp) > => > (retract ?f) > (bind ?timestamp (long(time))) > (assert (timevalue ?timestamp)) > ;;(printout t "?timestamp : "?timestamp crlf) > ) > > > (run) > > > Is this a good way to do temporal reasoning? > Do I need the salience at rule update-rule? > > Thanks very much for help, > Vincent > ______________________________________________________________________________ > FreeMail in der Premiumversion! Mit mehr Speicher, mehr Leistung, mehr > Erlebnis und mehr Pramie. Jetzt unter http://club.web.de/?mc=021105 > > > -------------------------------------------------------------------- > 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] > -------------------------------------------------------------------- > --------------------------------------------------------- Ernest Friedman-Hill Distributed Systems Research Phone: (925) 294-2154 Sandia National Labs FAX: (925) 294-2234 Org. 8920, MS 9012 [EMAIL PROTECTED] PO Box 969 http://herzberg.ca.sandia.gov Livermore, CA 94550 -------------------------------------------------------------------- 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] --------------------------------------------------------------------
