Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [AI] Java Rules engines - especially Rete-based  (Read 8727 times)
0 Members and 1 Guest are viewing this topic.
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Posted 2004-02-14 19:00:36 »

Does anyone have experiences (+ve or -ve) of any Java-based rules engines? In particular, I'm looking for Rete-based systems (of which Drools seems to be the only free one with much exposure).

Drools is XML based, which is horrible, and my previous fumblings with it suggest it's pretty crummy - but I'd appreciate input from anyone who's used it seriously.

We've got our own rules engine, and I'd like to swap out the basic inference class (which mainly does simple pattern matching) for a Rete system. We've experimented with doing our own Rete-clone (not precisely the same) in the past, but re-using a standard impl of the algorithm would be an interesting comparison.

Performance is very much an issue!

malloc will be first against the wall when the revolution comes...
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #1 - Posted 2004-02-15 01:19:06 »

Have you seen http://www.jcp.org/en/jsr/detail?id=094
You could email the spec lead to see if he has any references for you.
It also mentions http://www.dfki.uni-kl.de/ruleml/

Offline Bombadil

Senior Member





« Reply #2 - Posted 2004-02-15 06:24:48 »

http://www.visual-rules.de/
(press the "english button" for english site)

The tool is pretty cool but it's just free for personal use.

Perfomance is excellent because the tool produces Java code from your visual rule system: JARs actually which you can neatly plug-in to your Java application/game.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline bmyers

Junior Member





« Reply #3 - Posted 2004-03-01 20:18:18 »

Check out JESS (Java Expert System Shell).

Full Rete implementation, and free.  Not sure whether it's the fastest, but it is nicely done.


Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #4 - Posted 2004-03-02 00:16:04 »

Quote
Check out JESS (Java Expert System Shell).

Full Rete implementation, and free.  Not sure whether it's the fastest, but it is nicely done.

Free?

Quote
Jess can be licensed for commercial use, and is available for academic use. Contact Craig Smith at casmith@sandia.gov for prices and commercial licensing terms, or for a research based academic license. A trial download is also available.

Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #5 - Posted 2004-03-02 14:51:29 »

Indeed, JESS is far from free. You aren't even allowed to develop software to support or work with it (we've asked them about a license that lets us support any customers who choose to use it, but had no response so far).

At the moment, JESS continues to be "an interesting academia project" (it's free for bona fide academics) unless you don't mind paying through the nose. As it stands, the latest info I've seen (2nd hand - they don't publish prices) on licensing costs suggests JESS might not actually saev enough in the long run to be worth it to us (nb: we've already done a rete-ish inference engine, and have people who've written AST compilers etc before, so we're not exactly starting from scratch).

malloc will be first against the wall when the revolution comes...
Offline jherber

Junior Member




Java games rock!


« Reply #6 - Posted 2004-03-07 03:05:16 »

mandarax looks promising, though i don't think it is rete based.  http://sourceforge.net/projects/mandarax
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #7 - Posted 2004-03-07 16:10:58 »

Quote
mandarax looks promising, though i don't think it is rete based.  http://sourceforge.net/projects/mandarax



Thanks. FYI, it's actually the opposite of rete Smiley.

malloc will be first against the wall when the revolution comes...
Offline bmyers

Junior Member





« Reply #8 - Posted 2004-03-10 17:43:25 »

oops, my bad... Embarrassed

Quote

Free?



Offline duncanIdaho

Junior Member




invert mouse


« Reply #9 - Posted 2004-04-19 18:26:33 »

For what it's worth I used JESS on a project about 3 years ago.  We optimized our code to death and it was still too slow for needs.  We were running an extraction engine on a news feed and the JESS component was at the end of the pipeline.  Ultimately we decided on a homegrown XML rule language which was translated into compilable code giving us the flexibility of a rule language and the speed of a hardcoded solution.

The inventor of RETE has made a RETE2 algorithm which he claims is faster for large amounts of data.
Rete II: http://www.pst.com/rete2.htm
OPSJ: http://www.pst.com/opsjbro.htm ( the java based Rete II engine )
There's a development license but no runtime license.  Might be worth looking into.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #10 - Posted 2004-04-19 23:10:14 »

Quote
For what it's worth I used JESS on a project about 3 years ago.  We optimized our code to death and it was still too slow for needs.


What would be *really* useful would be some basic stats on number of rules, rate-of-change, etc. This seems to be the main problem for using rete-engines: they're tuned to the wrong traffic patterns (although we're experimenting with moulding the input feed to suit Rete; the question is, does the "moulding" + a commercial Rete out-do our custom from-scratch Rete-esque-but-significantly-different inference engine?)

Also, in JESS's defence, reading the version history two things become clear:
 1. It's been pretty sensitive to some of the areas where Sun's been concentrating on massively increasing JVM performance recently; hence it could achieve great gains from late 1.4.x and 1.5.x JVm's.
 2. The early implementations appear to have been architected *ahem* less than wisely, w.r.t performance.

Quote

We were running an extraction engine on a news feed and the JESS component was at the end of the pipeline.


If you're able to go into more detail, I'd be interested to chat further about this (I have some friends who've worked on high-performance news-feed processing, and it's quite interesting).

Perhaps you could get in touch ceo @ grexengine.com

Quote

The inventor of RETE has made a RETE2 algorithm which he ...There's a development license but no runtime license.  Might be worth looking into.


Yes, spotted that a while back. It's a bit too "if I told you anything about this, I'd have to kill you, so you'll just have to trust me - it's a million times faster than anything anyone else has ever done, and no-one else could even come close" for my liking. What I really need is detailed info on how it behaves on different traffic patterns, but it appears you need to have paid a significant number of thousands of dollars before you'll get any non-trivial data (possibly because you can infer the algorithm once you've seen what it works well on?)

NB please humour me when I say "traffic" patterns; hopefully everyone knows what I mean...

malloc will be first against the wall when the revolution comes...
Offline javawillie

Junior Member




Hola, Paco.


« Reply #11 - Posted 2004-04-21 21:41:48 »

A tried using JESS a few years back for a cognitive tutor project.  (Uses JESS to generate context-specific hints for learners engaged in some problem solving activity.)  Ultimately I went with a custom solution instead of JESS because there was no way that I could see to make the rules engine to "unapply" a rule that it had already applied.  (The way the feedback/hints are generated is to have the rules engine find the best rule given the current problem state.  But once you find the rule, you need to be able to unapply the rule so that your model reflects the learner's current state.)

I've never done game AI using a rules engine, so I don't know whether the same kind of issue can come up, but I mention it since I happen to have had some limited experience with JESS.  :-P

Willie
Offline gregorypierce

Senior Member




I come upon thee like the blue screen of death....


« Reply #12 - Posted 2004-10-13 00:52:23 »

Quote
Check out JESS (Java Expert System Shell).

Full Rete implementation, and free.  Not sure whether it's the fastest, but it is nicely done.




Jess is very very far from free. Get ready to spit out 10s of thousands.

http://www.gregorypierce.com

She builds, she builds oh man
When she links, she links I go crazy
Cause she looks like good code but she's really a hack
I think I'll run upstairs and grab a snack!
Offline gregorypierce

Senior Member




I come upon thee like the blue screen of death....


« Reply #13 - Posted 2004-10-13 01:19:35 »

Let me give you a dump on using rules engine for games. We evaluated several engines including Mandarax, JESS, Drools, JRules. Drools and Mandarax are the only 2 open source ones that were really alive and showed some sign of what could be considered 'great architecture'. Mandarax is a backwards chaining rules engine, and that may not matter to you if you don't have a large number of rules (something that RETE is designed to handle well). Drools is a straightforward RETE implementation. Its semantic layer is excellent, allowing you to use Groovy, Java, etc. as the language for rule logic. JESS is 'interesting'. The syntax of JESS is just nasty, especially if you don't have a background in lisp like languages. I personally wouldn't want to touch JESS with a 10 foot pole, but that's not my decision. JRules is straightforward and has a lot more syntactic goodness than Drools. One thing that Drools does do , however, is compile the rules into bytecode using janino - which gives it excellent performance. In fact, its one of the faster engines we tested both open source and commercially. Drools is still somewhat young though, and its documentation needs some help. It has a fairly simply view of rules engines at the syntax level. However, Drools is certainly a very active project and the users list has maybe a 24-48 hour turn around on questions to the list.

Using a rule engine did bring about some very interesting questions which some people here may have already solved. Even with salience its sometimes difficult to get rules to fire in the order you wanted them to, and have the side effects make sense. In addition - rule engines are NOT the fastest things in the world. You can write custom code that will outperform any of the ones on the market right now... .but it will be a very custom solution.

I wouldn't really spend a lot of time screwing with JSR-94. Its an 'interesting' JSR, but when the rubber hits the road you will find it extremely limiting.

http://www.gregorypierce.com

She builds, she builds oh man
When she links, she links I go crazy
Cause she looks like good code but she's really a hack
I think I'll run upstairs and grab a snack!
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #14 - Posted 2004-10-13 05:14:00 »

Quote
Let me give you a dump on using rules engine for games.


Thanks. Of those, Mandarax is now the only one I haven't looked at. I hadn't noticed that Drools compiled to bytecode - their site, docs, and XML scripting were shockingly bad every time I looked, and I lost interest fast.

Quote

The syntax of JESS is just nasty, especially if you don't have a background in lisp like languages.


That wasn't a problem Smiley. Compared to Drools, it was much faster for us to get it running - but that probably says more about our backgrounds than the two libraries?

Quote

Using a rule engine did bring about some very interesting questions which some people here may have already solved. Even with salience its sometimes difficult to get rules to fire in the order you wanted them to, and have the side effects make sense. In addition -


c.f. below, but much more deterministic control over ordering is one of the things that we've built-in to our next algo, because it's so important in game-logic.

Quote

rule engines are NOT the fastest things in the world. You can write custom code that will outperform any of the ones on the market right now... .but it will be a very custom solution.


That's what we already have - a custom proprietary system (as a prototype only at the moment) - and it's fast and effective but I'd hoped to find a better one already in existence. FYI I made the first prototype as almost exactly a rete system having never heard of rete - it just seemed an obvious approach I thought up off the top of my head (over the course of a few weeks) for doing this kind of thing *fast*. I believe we've got a significantly faster algorithm too - althought not prototyped yet - which is more customized towards our particular use-cases (i.e. frequency of queries, number of rules, number of rule-changes per second, etc)...but it's going to take many months to get that to production quality, and I wanted to try out various 3rd party inference engines first. I was quite disappointed how unadvanced/immature the state of open-source/free engines was, given how ancient the rete algorithm itself is.

For the stuff we're using it for (coding ALL game logic) performance is critical yet the payoffs for using an inference engine *of some kind* are immense, in terms of reduced costs of code maintenance and feature-addition and even making frequent and complex changes to the game logic. The main use is to make it much cheaper to "balance" the logic / game-rules for complex games to make a good game rather than a one-sided game.

malloc will be first against the wall when the revolution comes...
Offline gregorypierce

Senior Member




I come upon thee like the blue screen of death....


« Reply #15 - Posted 2004-10-14 01:18:56 »

I unfortunately can't talk much about our particular uses of it, but when we went shopping for an engine - we pretty much knew that we weren't going to use  a custom engine for a variety of reason, much of which goes in line with supporting it versus people in that space who actually care.

I'm surprised you didn't like Drools. It took less than an hour to understand exactly what Drools was trying to do. There is so little XML in the system and even it is a bagillion times more intuitive than anything in Clips derivative Jess (there was a long debate, which is somewhat still going on, about the Jess/Drools decision). Drools is just an excellent architecture with its pluggable semantics. You could write your own AI language, plug it into Drools and Drools would function just fine. We liked our rules in Java, however, since we have lots of people who understand Java/C/Pascal/etc and that language syntax. It takes no time for someone completely unfamiliar with our system to be able to read our .drl files and understand what its doing and write new rules. That by itself was a major selling point. But then again our end product will have more 'regular programmers' writing declarative rules for our product. Your mileage may vary based on your use cases.

To be honest I'm actually amazed to hear anyone find Drools syntax to be difficult.

Quote

I was quite disappointed how unadvanced/immature the state of open-source/free engines was, given how ancient the rete algorithm itself is.


If you have a special case use for a rules engine, it is extremely easy to optimize for those cases - but they will have side effects that are bad for a more general purpose engine. Drools is a more general purpose engine, though I've been impressed with its performance. Drool's java semantics and its groovy semantic use janino.net's open source compiler to turn their AI rules into byte code so it will run pretty fast. When I talk about speed I'm talking about relative to a specialized engine for particular tasks. Most people will likely find Drools to be of acceptable performance - though its not the type of thing you'd call every frame Smiley

My architecture has the notion of a Planner which also holds WorkingMemory. While the game is taking place the planner's working memory is updated periodically for high level decisions and this causes the rules to fire and decisions to be made. The actions from these decisions is usually not defined in the rules - they usually just set a state that determines what an entities goals are. While I liked the idea of Drools giving me the functionality to put actual java code in the consequences and acutally giving me the ability to drive the game right from the rules - that isn't an ideal seperation.

Quote

For the stuff we're using it for (coding ALL game logic) performance is critical yet the payoffs for using an inference engine *of some kind* are immense, in terms of reduced costs of code maintenance and feature-addition and even making frequent and complex changes to the game logic. The main use is to make it much cheaper to "balance" the logic / game-rules for complex games to make a good game rather than a one-sided game.


Our use cases are the same though we didn't find it reasonable to put all game logic in the rules engine. Some things just work well that far seperated from the engine core. While we're weaving our rule engine in using Aspects (something its unfortunate that Sun doesn't seem to understand or use), moving stuff in and out of working memory, updating objects in the working store, and some light synchronizing of data makes doing everything in the rules engine somewhat impractical. Now maybe your use cases will point to something different, but for us after we tried and tried to make that the use case - performance dictated that putting everything in the rules impractical.

http://www.gregorypierce.com

She builds, she builds oh man
When she links, she links I go crazy
Cause she looks like good code but she's really a hack
I think I'll run upstairs and grab a snack!
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #16 - Posted 2004-10-14 13:22:29 »

Quote

I'm surprised you didn't like Drools.


You've convinced me to have another look. Maybe personally I was too affected by "oh no, here goes ANT all over again", although my memory is that documentation was the real killer - we just don't use stuff which has poor or non-existent documentation.

Quote

for us after we tried and tried to make that the use case - performance dictated that putting everything in the rules impractical.


Yes, our prototypes needed a mix and match approach too, and this is partly why I wanted to investigate dedicated engines side-by-side.

If it were ONLY a case of developing a pure (but proprietary) engine  then I wouldnt' be worried, but the prospect of something that is both proprietary and a non-clean arbitrarily mix-and-match (so that game code may get moved back and forth between the rules engine and outside it) is deeply disturbing (nightmares of code maintenance problems come to mind - which is one of the primary things this was supposed to be solving in the first place Sad).

malloc will be first against the wall when the revolution comes...
Offline jherber

Junior Member




Java games rock!


« Reply #17 - Posted 2004-10-15 02:26:50 »

blah, thought not java-based (in 'c'), you may find some optimization hints in soar's rete implementation.  (http://sourceforge.net/projects/soar/)  the ICCM'04  soar tutorial given by john laird was very impressive.  soar is an agent cognitive architecture that is production rule based with working memory and lots of other features.  
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #18 - Posted 2004-10-15 08:54:29 »

Thanks; I'll add that to the list to re-evaluate Smiley.

malloc will be first against the wall when the revolution comes...
Offline Matlu

Junior Member




Hasta La Victoria Siempre!


« Reply #19 - Posted 2004-10-15 12:59:37 »

Hi,

we are trying to use Drools in our product.

There is one big problem with it: - it's performance is completely unpredictable. If you run the engine, it can sometimes take 10 seconds, and sometimes 10 minutes to finish - for exactly some data.
I created something like "bug report" or "change request" on their page and some developer replied, that they know about this problem, and that they "currently work on performance".

We tried to fix this problem ourselves and we succeded (basically all it takes is to replace every HashSet in drools sources with LinkedHashSet)

So now the engine's performance is at least deterministic.
To me it appears that it is quite slow (but maybe it's ok, our data set is really big, and I never tried any other Rete engine, so I cannot compare)
Except the problem with performace it works quite fine.

Lubo


Multiplayer Online Games
http://www.duelboard.com
Offline gregorypierce

Senior Member




I come upon thee like the blue screen of death....


« Reply #20 - Posted 2004-10-15 20:41:42 »

Quote
Hi,

we are trying to use Drools in our product.

There is one big problem with it: - it's performance is completely unpredictable. If you run the engine, it can sometimes take 10 seconds, and sometimes 10 minutes to finish - for exactly some data.


If you've got a sample of that you should send it to the developers. We haven't had any issue with the evaluation of rules taking different amount of times outside of the first run when janino is compiling our java semantic code into bytecode. After that, performance is constant if we send the same data through over and over and over agaain.

Quote

I created something like "bug report" or "change request" on their page and some developer replied, that they know about this problem, and that they "currently work on performance".

We tried to fix this problem ourselves and we succeded (basically all it takes is to replace every HashSet in drools sources with LinkedHashSet)


That's already done in the CVS head as best I can tell. Are you using the version from CVS or the beta-17 binary distro?

http://www.gregorypierce.com

She builds, she builds oh man
When she links, she links I go crazy
Cause she looks like good code but she's really a hack
I think I'll run upstairs and grab a snack!
Offline dselman

Innocent Bystander




Java games rock!


« Reply #21 - Posted 2004-11-17 11:58:14 »

There is an extensive list of rules engines at:
http://www.javarules.org

(Look under the Web Links section).

As a point of reference ILOG JRules also JITs rules to bytecode. I believe this is also the case of Blaze Advisor, for example.

JRules also includes the sequential algorithm for cases where RETE is not required. In these cases sequential mode will run much faster than RETE.

What are you trying to do with a rule engine?

Sincerely,

Dan
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #22 - Posted 2004-11-21 08:54:27 »

Quote
There is an extensive list of rules engines at:
http://www.javarules.org

(Look under the Web Links section).


Thanks. The site looks pretty and I suspect may have lots of useful info, but it has a very badly designed UI, it's a complete PITA to find anything there or even to really work out what's on the site Sad.

Quote

As a point of reference ILOG JRules also JITs rules to bytecode. I believe this is also the case of Blaze Advisor, for example.


Indeed. And it looks like things have changed a fair bit since I was previously researching this.

Quote

What are you trying to do with a rule engine?


Aggressive stuff with very complex game logic. Logic so complex it's unmaintainable by human programmers. Logic so complex it needs to be implemented using basic rules. Logic that is used so frequently those rules need to be compiled so that the 10% of rules that are used 99% of the time have been compiled into things that are quick to fire (or, at least, quick to recognise).


malloc will be first against the wall when the revolution comes...
Offline greg_barton

Junior Newbie




Java games rock!


« Reply #23 - Posted 2005-03-28 04:21:53 »

Anyone still interested in performance characteristics of the RETE2 (and now RETE3) algorithms?
Offline greg_barton

Junior Newbie




Java games rock!


« Reply #24 - Posted 2005-03-28 04:27:19 »

Oh, and if you're interested in logic that's incomprehensible to humans and can only be handled by an inference engine, you may want to check out my project, REAT. (Rete Evolution of Augmenting Topologies)  There's not much there at the moment, but in a few months I hope to have an alpha version out.  Basically it'll be a method of generating RETE networks through evolution using the techniques of Ken Stanley's NEAT, (NeuroEvolution of Augmenting Topologies) which is currently used to evolve neural networks.
Offline greg_barton

Junior Newbie




Java games rock!


« Reply #25 - Posted 2005-03-28 04:29:47 »

Oops.  Link. Smiley

https://sourceforge.net/projects/reat/
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Riven (15 views)
2014-07-29 18:09:19

Riven (10 views)
2014-07-29 18:08:52

Dwinin (10 views)
2014-07-29 10:59:34

E.R. Fleming (28 views)
2014-07-29 03:07:13

E.R. Fleming (10 views)
2014-07-29 03:06:25

pw (40 views)
2014-07-24 01:59:36

Riven (39 views)
2014-07-23 21:16:32

Riven (27 views)
2014-07-23 21:07:15

Riven (29 views)
2014-07-23 20:56:16

ctomni231 (59 views)
2014-07-18 06:55:21
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!