Hi,
   
  Just as a (newbie) exercise, I was trying to consider a simplified version of 
the "Miss Manners" example (from Drools site).
My simplified version requires:
-  Given 4 guests (exactly), try to seat them in a line
-  Each pair of adjacent guests should have shared hobies
   
  Now, my question:
Since the number of guests is known in advance (4), I was hoping to write a 
simple rule with 4 parameters :
     <parameter identifier="guest1">...
     <parameter identifier="guest2">...
     <parameter identifier="guest3">...
     <parameter identifier="guest4">...
  (As opposed to the Miss Manners example, where number of guests isn't given 
in advance, so you must work pretty hard just to build the tuples).
  
So I came up with something like this
  (all params are of class "Guest"):
     < parameter identifier="g1" > 
   < parameter identifier="g2" >
   < parameter identifier="g3" >
   < parameter identifier="g4" >
   < condition > g1.hasSharedHobies(g2) < / condition >
   < condition > g2.hasSharedHobies(g3) < / condition >
   < condition > g3.hasSharedHobies(g4) < / condition >
     < consequence > System.out.println(g1+g2+g3+g4); < / consequence >
   
  However, I don't like the condition duplication (g1 shares hobies with g2, g2 
shares hobies with g3, etc... too much "cut & paste").
Is there a more elegant way to do this ?
   
  I did consider arrays:
    < condition > checkLine(g1,g2,g3,g4) < / condition >
Using a function:
        boolean checkLine(Guest g1, Guest g2, Guest g3, Guest g4){
           Guest[] all={g1,g2,g3,g4};
           // ... loop over array and check every adjacent pair
        }

  Unfortunately, this "array" approach would give horrible performance, because 
it doesn't take advantage of the way Rete algorithm works...
  I would greatly appreciate other ideas...
   
  Thanks very much.
  
 

                        
---------------------------------
 Yahoo! Mail
 Use Photomail to share photos without annoying attachments.

Reply via email to