For those who like to just dive right in, this distribution contains a Prolog shell called aiprolog and two short adventure games, spider.pro and sleepy.pro. If you have installed the aiprolog shell, you can run either game with the command:

aiprolog data/spider.pro
aiprolog data/sleepy.pro

When the aiprolog shell starts, you can type start. to see how to play the game. Typing halt. and hitting return twice will allow you to exit.

See the bin/ and data/ directories in the distribution.

Additionally, you can read AI::Prolog::Article for a better description of how to use AI::Prolog. This document is an article originally published in The Perl Review (http://www.theperlreview.com/) and which they have graciously allowed me to redistribute.

AI::Prolog is a pure Perl predicate logic engine. In predicate logic, instead of telling the computer how to do something, you tell the computer what something is and let it figure out how to do it. Conceptually this is similar to regular expressions.

my @matches = $string =~ /XX(YY?)ZZ/g

If the string contains data that will satisfy the pattern, @matches will contain a bunch of "YY" and "Y"s. Note that you're not telling the program how to find those matches. Instead, you supply it with a pattern and it goes off and does its thing.

To learn more about Prolog, see Roman Barták's "Guide to Prolog Programming" at http://kti.ms.mff.cuni.cz/~bartak/prolog/index.html. Amongst other things, his course uses the Java applet that AI::Prolog was ported from, so his examples will generally work with this module.

Fortunately, Prolog is fairly easy to learn. Mastering it, on the other hand, can be a challenge.

You can get access to the full, raw results by setting raw_results to true. In this mode, the results are returned as an array reference with the functor as the first element and an additional element for each term. Lists are represented as array references.

Turns a Perl list into a Prolog list and makes it suitable for embedding into a program. This will quote individual variables, unless it thinks they are a number. If you wish numbers to be quoted with this method, you will need to quote them manually.

If raw_results is false, the return value will be a "result" object with methods corresponding to the variables. This is currently implemented as a Hash::AsObject so the caveats with that module apply.

None by default. However, for convenience, you can choose ":all" functions to be exported. That will provide you with Term, Parser, and Engine classes. This is not recommended and most support and documentation will now target the AI::Prolog interface.

If you choose not to export the functions, you may use the fully qualified package names instead: