[jboss-svn-commits] JBL Code SVN: r33292 - labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/pacman.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Jun 1 18:23:13 EDT 2010
Author: mark.proctor at jboss.com
Date: 2010-06-01 18:23:12 -0400 (Tue, 01 Jun 2010)
New Revision: 33292
Modified:
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/pacman/key-handlers.drl
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/pacman/pacman.drl
Log:
-added count check for KeyEvent
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/pacman/key-handlers.drl
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/pacman/key-handlers.drl 2010-06-01 20:58:06 UTC (rev 33291)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/pacman/key-handlers.drl 2010-06-01 22:23:12 UTC (rev 33292)
@@ -54,11 +54,20 @@
insert( $newD );
end
+rule KeyEventCount dialect "mvel" salience -5 when
+ $n : Number() from accumulate(
+ $keyEvent : KeyEvent() from entry-point "KeyListener",
+ count( $keyEvent ) )
+then
+ System.out.println( "count : " + $n ) ;
+end
+
+
/**
* Retract all KeyEvents, ideally we should have expirs 0s, but that doesn't work
- */
rule KeyListenerRuleRetractEvent dialect "mvel" salience -5 when
$keyEvent : KeyEvent() from entry-point "KeyListener"
then
retract( $keyEvent );
-end
\ No newline at end of file
+end
+ */
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/pacman/pacman.drl
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/pacman/pacman.drl 2010-06-01 20:58:06 UTC (rev 33291)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/pacman/pacman.drl 2010-06-01 22:23:12 UTC (rev 33292)
@@ -1,9 +1,25 @@
package org.drools.examples.pacman
/**
+ * By increasing the tick we slow down the time to the next move.
+ * I use the CE 'or' here rathre than an infix "in" to maximise node sharing
+ * with both the EatFood and EatPowerPill rules.
+ */
+rule SlowWhenEating dialect "mvel" no-loop salience 10when
+ $char : Character( name == "Pacman" )
+ $l : Location( character == $char )
+ $target : Cell( row == $l.row, col == $l.col)
+ (or $contents : CellContents( cell == $target, cellType == CellType.FOOD )
+ $contents : CellContents( cell == $target, cellType == CellType.POWER_PILL ) )
+ $update : ScheduledLocationUpdate( character == $char )
+then
+ modify ( $update ) { tock += 2 };
+end
+
+/**
* When we move onto a FOOD cell, increase the score by 1
*/
-rule EatFood dialect "mvel" no-loop when
+rule EatFood dialect "mvel" when
$char : Character( name == "Pacman" )
$l : Location( character == $char )
$target : Cell( row == $l.row, col == $l.col)
@@ -17,7 +33,7 @@
/**
* When we move onto a POWER_PILL cell, increase the score by 5
*/
-rule EatPowerPill dialect "mvel" no-loop when
+rule EatPowerPill dialect "mvel" when
$char : Character( name == "Pacman" )
$l : Location( character == $char )
$target : Cell( row == $l.row, col == $l.col)
@@ -28,22 +44,8 @@
modify( $s ) { score += 5 };
end
-/**
- * By increasing the tick we slow down the time to the next move.
- * I use the CE 'or' here rathre than an infix "in" to maximise node sharing
- * with both the EatFood and EatPowerPill rules.
- */
-rule SlowWhenEating dialect "mvel" no-loop when
- $char : Character( name == "Pacman" )
- $l : Location( character == $char )
- $target : Cell( row == $l.row, col == $l.col)
- (or $contents : CellContents( cell == $target, cellType == CellType.FOOD )
- $contents : CellContents( cell == $target, cellType == CellType.POWER_PILL ) )
- $update : ScheduledLocationUpdate( character == $char )
-then
- modify ( $update ) { tock += 2 };
-end
+
rule MonsterCollision dialect "mvel" no-loop when
$pac : Character( name == "Pacman" )
$pacLoc : Location( character == $pac )
More information about the jboss-svn-commits
mailing list