Well, this works, but it does show some limitations in the code. I'm adding this to my examples/ directory. Thanks for the pointer.
use strict;
use warnings;
use aliased 'AI::Prolog::Parser';
use aliased 'AI::Prolog::Term';
use aliased 'AI::Prolog::Engine';
my $database = Parser->consult(<<'END_PROLOG');
perform(grasp,
state(middle, middle, onbox, hasnot),
state(middle, middle, onbox, has)).
perform(climb,
state(MP, BP, onfloor, H),
state(MP, BP, onbox, H)).
perform(push(P1,P2),
state(P1, P1, onfloor, H),
state(P2, P2, onfloor, H)).
perform(walk(P1,P2),
state(P1, BP, onfloor, H),
state(P2, BP, onfloor, H)).
/* getfood(state(_,_,_,has)). */
/* I'll have to fix this soonish! */
getfood(state(Bogus1,Bogus2,Bogus3,has)).
getfood(S1) :- perform(Act, S1, S2),
nl, print(S1), print(Act),
getfood(S2).
END_PROLOG
my $parser = Parser->new("getfood(state(atdoor,atwindow,onfloor,hasnot
+)).");
my $query = Term->new($parser);
my $engine = Engine->new($query,$database);
print $engine->run;
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.