On 18 April 2011 16:57, Mark Proctor
<mproctor@codehaus.org>
wrote:
Here is a more friendly example based around "Adventures
in Proglog"'s
"Nani Search". This is just a sampling of queries and rules,
which it
uses to provide an adventure like game environment. The "?"
means to
pull results, rather than the normal reactive nature of
patterns.
http://www.amzi.com/AdventureInProlog/
query niceFood( String thing, String location )
location(thing, location) and
edible(thing)
end
query connect( String x, String y )
door(x, y;)
or
door(y, x;)
end
query look(String place, List things, List exits)
things : List() from accumulate( Location(thing, place;) ,
collectList( thing ) )
food : List() from accumulate( ?niceFood(thing, place;) ,
collectList(
thing ) )
exits : List() from accumulate( ?connect(place, exit;) ,
collectList(
[place, exit] ) )
end
rule reactiveLook when
Here( place : location)
?look2(place, things, exits)
then System.out.println( " You are in the " + place );
System.out.println( " You can see " + things );
System.out.println( " You can eat" + eat );
System.out.println( " You can go to " + exits );
end
-----Output----
You are in the kitchen
You can see [crackers, broccoli, apple]
You can eat[crackers, apple]
You can go to [[kitchen, dining room], [kitchen, cellar]]
_______________________________________________
rules-dev mailing list
rules-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev