[jboss-svn-commits] JBL Code SVN: r15357 - labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Sep 25 05:31:56 EDT 2007
Author: michael.neale at jboss.com
Date: 2007-09-25 05:31:55 -0400 (Tue, 25 Sep 2007)
New Revision: 15357
Modified:
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/golf.drl
Log:
modified the golf example to be clearer, and use features from Drools 4
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/golf.drl
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/golf.drl 2007-09-25 09:31:12 UTC (rev 15356)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/golf.drl 2007-09-25 09:31:55 UTC (rev 15357)
@@ -1,52 +1,52 @@
package org.drools.examples;
+dialect "mvel"
+
import org.drools.examples.GolfingExample.Golfer;
rule "find solution"
when
- // There is a golfer named Fred,
+ // There is a golfer named Fred,
// Whose positions is $p1
- $fred : Golfer( $fredsName : name == "Fred",
- $fredsPosition : position,
- $fredsColor : color )
+ $fred : Golfer( name == "Fred" )
- // Joe is in position 2
- $joe : Golfer( $joesName : name == "Joe",
- $joesPosition : position == 2,
- position != $fredsPosition,
- $joesColor : color != $fredsColor )
+ // Joe is in position 2
+ $joe : Golfer( name == "Joe",
+ position == 2,
+ position != $fred.position,
+ color != $fred.color )
- // Bob is wearing plaid pants
- $bob : Golfer( $bobsName : name == "Bob",
- $bobsPosition : position != $fredsPosition,
- position != $joesPosition,
- $bobsColor : color == "plaid",
- color != $fredsColor,
- color != $joesColor )
-
+ // Bob is wearing plaid pants
+ $bob : Golfer( name == "Bob",
+ position != $fred.position,
+ position != $joe.position,
+ color == "plaid",
+ color != $fred.color,
+ color != $joe.color )
+
// Tom isn't in position 1 or 4
- // and isn't wearing orange
- $tom : Golfer( $tomsName : name == "Tom",
- $tomsPosition : position != 1,
+ // and isn't wearing orange
+ $tom : Golfer( name == "Tom",
+ position != 1,
position != 4,
- position != $fredsPosition,
- position != $joesPosition,
- position != $bobsPosition,
- $tomsColor : color != "orange",
- color != "blue",
- color != $fredsColor,
- color != $joesColor,
- color != $bobsColor )
-
+ position != $fred.position,
+ position != $joe.position,
+ position != $bob.position,
+ color != "orange",
+ //color != "blue",
+ color != $fred.color,
+ color != $joe.color,
+ color != $bob.color )
+
// The golfer to Fred's immediate right
// is wearing blue pants
- $fn : Golfer( position == ( $fredsPosition + 1 ),
+ Golfer( position == ( $fred.position + 1 ),
color == "blue",
this in ( $joe, $bob, $tom ) )
then
- System.out.println( "Fred " + $fredsPosition + " " + $fredsColor );
- System.out.println( "Joe " + $joesPosition + " " + $joesColor );
- System.out.println( "Bob " + $bobsPosition + " " + $bobsColor );
- System.out.println( "Tom " + $tomsPosition + " " + $tomsColor );
-end
+ System.out.println( "Fred " + $fred.getPosition() + " " + $fred.getColor() );
+ System.out.println( "Joe " + $joe.getPosition() + " " + $joe.getColor() );
+ System.out.println( "Bob " + $bob.getPosition() + " " + $bob.getColor() );
+ System.out.println( "Tom " + $tom.getPosition() + " " + $tom.getColor() );
+end
More information about the jboss-svn-commits
mailing list