New AI::Prolog version uploaded (with a game!)

Ovid on 2005-02-13T21:31:47

I just uploaded AI::Prolog 0.05. It's changed quite a bit internally, though it should still be backwards-compatible. The most disappointing aspect of it was the fact that it actually runs a bit slower even though the changes I incorporated should have sped it up a bit (in the way that migrating from WProlog to XProlog should speed things up.) However, Perl's method calls are so slow that I lose any performance benefits :/

New features for this release are the cut operator (!), assert(X), and retract(X) and a simple Prolog shell! If you choose to install it, typing aiprolog $optional_prolog_program will put you in a Prolog shell. Most "real" Prolog programs won't run, but those that are limited to the subset of Prolog I support (documented in AI::Prolog::Builtins) should run without too much trouble. However, be aware that the "assert" functionality is somewhat limited at this point. Only simple facts can be asserted or retracted. Here's an example of a simple session:

[ovid@tomis ai_prolog]$ aiprolog
Welcome to AI::Prolog v 0.5


?- assert(loves(ovid,perl)).
assert(loves(ovid,perl))
More? (y/N)

?- assert(loves(ovid,prolog)).
assert(loves(ovid,prolog))
More? (y/N)

?- loves(ovid,X).
loves(ovid,perl)
More? (y/N) y
loves(ovid,prolog)
More? (y/N) y

More? (y/N)

?- %halt.

Type '?' at the prompt for help.

To further increase people's interest, I've bundled a simple adventure game "spider" in the data/ directory. To play it, just type "aiprolog data/spider.pro". I recommend that you first issue the following shell command:

?- % no more

That command disables the "More? (y/N)" prompt which is useful when you're writing Prolog but pretty darned annoying when you're playing the game.

Then issue the following command:

?- start.

Assuming everything went well, you should see this:

Enter commands using standard Prolog syntax.
Available commands are:
start.                   -- to start the game.
n.  s.  e.  w.  u.  d.   -- to go in that direction.
take(Object).            -- to pick up an object.
drop(Object).            -- to put down an object.
kill.                    -- to attack an enemy.
look.                    -- to look around you again.
instructions.            -- to see this message again.
halt.                    -- to end the game and quit.

You are in a meadow.  To the north is the dark mouth
of a cave; to the south is a small building.  Your
assignment, should you decide to accept it, is to
recover the famed Bar-Abzad ruby and return it to
this meadow.

Playing with the shell and reading the spider code should teach you quite a bit about basic Prolog and show you how easy is really is.