heh.. nice.. I will add the Wii mote (<a href="http://en.wikipedia.org/wiki/Wii_Remote">http://en.wikipedia.org/wiki/Wii_Remote</a>) support for that game, it&#39;s pretty easy. I have an example working.<br><br><div class="gmail_quote">
On Mon, Nov 16, 2009 at 11:55 AM, Mark Proctor <span dir="ltr">&lt;<a href="mailto:mproctor@codehaus.org">mproctor@codehaus.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
For anyone interested i just did an initial commit for the rudementary<br>
implementation parts for a Pacman game. Loads a Grid  and a Character<br>
into the working memory and listens to the arrow keys to move the<br>
Character around (text output only). It only accepts valid directions<br>
and the Character cannot move off the grid, and score is updated as it<br>
eats Food.<br>
<br>
It also demostrates entry and exit points. For instance this rule has<br>
it&#39;s &quot;KeyListener&quot; entry point hooked up to a KeyListener impl that<br>
inserts KeyEvents. From the KeyEvent it creates a Derived (not in<br>
working memory) possible Direction, validates that Direction. If valid<br>
the old Direction is retracted and the new one inserted. I use the<br>
exitpoint to send print information to a channel, which is appended to<br>
the GUI.<br>
<br>
/**<br>
 * Detects a new keypress (release). Creates derived possible Direction<br>
and validates it.<br>
 * If the Direction is valid, delete the old Direction and replace with<br>
the new one.<br>
 */<br>
rule keyListenerRule dialect &quot;mvel&quot; when<br>
    $keyEvent : KeyEvent() from entry-point &quot;KeyListener&quot;<br>
    $l : Location()<br>
    $newD : Direction() from createDirection( $l.character, $keyEvent )<br>
    $target : Cell( row == ($l.row + $newD.vertical), col == ($l.col +<br>
$newD.horizontal) )<br>
    CellContents( cell == $target, cellType != CellType.WALL )<br>
    $oldD : Direction( character == $l.character )<br>
then<br>
    exitPoints[&quot;ConsoleExitPoint&quot; ].insert( &quot;insert &quot; + $newD + &quot;\n&quot; );<br>
    retract( $keyEvent );<br>
    retract( $oldD );<br>
    insert( $newD );<br>
end<br>
<br>
As the Tick, simulated time, increases we attempt to change it&#39;s<br>
Location based on the given Direction. We make sure the new Location is<br>
valid, and if so schedule the new Location, in time with the Tick.<br>
/**<br>
 * Checks that the current Direction moves to a valid location, i.e. not<br>
a WALL.<br>
 * It does not set the new direction straight away, this is because we<br>
need movement to be intime<br>
 * with the Tick increase, so we schedule the new Location instead.<br>
 */<br>
rule validDirection dialect &quot;mvel&quot; when<br>
    $l : Location( )<br>
    $d : Direction( character == $l.character )<br>
    $target : Cell( row == ($l.row + $d.vertical), col == ($l.col +<br>
$d.horizontal) )<br>
    CellContents( cell == $target, cellType != CellType.WALL )<br>
    not ScheduledLocationUpdate( location == $l )<br>
    $t : Tick()<br>
then<br>
    insert( new ScheduledLocationUpdate($l, $l.row += $d.vertical,<br>
$l.col += $d.horizontal, $t.tock + 1) );<br>
end<br>
<br>
/**<br>
 * When the Tick increases, update any Locations from inserted scheduled<br>
updates.<br>
 */<br>
rule setNewDirection dialect &quot;mvel&quot; when<br>
    $s : ScheduledLocationUpdate()<br>
    $l : Location( this == $s.location )<br>
    Tick( tock == $s.tock )<br>
then<br>
   exitPoints[&quot;ConsoleExitPoint&quot;].insert( &quot;set new Location &quot; + $l +<br>
&quot;\n&quot;  );<br>
   modify( $l ) { row = $s.row, col = $s.col };<br>
   retract( $s );<br>
end<br>
<br>
Notice the whole thing id driven relationally, because everything is<br>
linked relationally we can exploit that to drive the engine<br>
declaratively with only a few rules.<br>
<br>
I&#39;ve committed everything to drools-examples for now, you&#39;ll need drools<br>
trunk, as there are a few fixes necessary for this to work:<br>
<a href="http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/pacman/" target="_blank">http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/pacman/</a><br>

<a href="http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/resources/org/drools/examples/pacman/" target="_blank">http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/resources/org/drools/examples/pacman/</a><br>

<a href="http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/pacman/" target="_blank">http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/pacman/</a><br>

<br>
The grid1.dat holds the grid layout, it&#39;s a declarative symbol layout,<br>
trivial to change to explore new grids.<br>
<br>
It&#39;s still very basic. Next I want to work on variable speed for<br>
characters, then I&#39;ll start to add Monsters and power pellets. Once we<br>
have the full backend working, the idea is to hook it up to an existing<br>
pacman gui such as SwtPacman. SwtPacman source code is available here:<br>
<a href="http://www.jboss.org/community/wiki/pacman" target="_blank">http://www.jboss.org/community/wiki/pacman</a><br>
<br>
I&#39;ll probably blog this later, as a few more bits are added. But<br>
hopefully this will start to demonstrate to people some more complex<br>
problems, and also help drive the drools team on how to improve our<br>
language and engine.<br>
<br>
Mark<br>
<br>
_______________________________________________<br>
rules-dev mailing list<br>
<a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
</blockquote></div><br><br clear="all"><br>-- <br> - <a href="http://salaboy.wordpress.com">http://salaboy.wordpress.com</a><br> - <a href="http://www.jbug.com.ar">http://www.jbug.com.ar</a><br> - Salatino &quot;Salaboy&quot; Mauricio -<br>