[rules-dev] Prolog Style Backward Chaining - First Cut

Wolfgang Laun wolfgang.laun at gmail.com
Mon Apr 18 12:08:31 EDT 2011


This doesn't seem to be quite correct.

   - There's a fact "location" and another one "Location" - are they the
   same?
   - Query "look" is defined; query "look2" is referenced.
   - How is the fact L/location defined?

Regards
Wolfgang




On 18 April 2011 16:57, Mark Proctor <mproctor at 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 at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-dev/attachments/20110418/108bf899/attachment.html 


More information about the rules-dev mailing list