All code examples in Prolog and C/C++ are provided for personal and educational use only. You may modify or distribute the code in source or compiled form for similar purposes so long as the original source is clearly identified.
These code examples were written for the First Edition of the AI Book, and have been modified minimally since then to cope with changes to run with Tau-Prolog, so that you can try them out within the browser.
If you wish to use any of the code examples, in part or whole, for commercial purposes please contact Alan Dix.
Most are written principally with ease of comprehension in mind and are not necessarily the most efficient coding of the algorithm. In particular, Prolog code, especially the early examples, try to avoid ‘clever’ Prolog tricks. However, the nature of the examples, means that sequential code achieved using cuts and mutable store achieved using assert/retract is often necessary.
Code examples are being added incrementally. If you have any problems with the existing code, or if critical examples are too slow appearing, please contact Alan Dix who will try to correct/add to the code as appropriate in a reasonable time!
Some of the prolog examples use predicates defined in utility files.
|tbirds.p||chapter 1||page 16: representing logic|
|prod.p||chapter 1||pages 19–20: production rules|
|network.p||chapter 1||page 22: semantic networks and inheritance|
|frames.p||chapter 1||pages 23–24: frames and slots|
|forback.p||chapter 2||pages 33–34: forwards and backwards reasoning|
|tms.p||chapter 2||page 35: non-monotonic reasoning|
TMS – truth maintenace system
|bayes.p||chapter 2||page 36: Baysian inference|
|bayes2.p||chapter 2||page 36: Baysian inference|
|certf.p||chapter 2||pages 37–38: certainty factors|
|fuzzy.p||chapter 2||pages 39–40: fuzzy set theory|
|gentest.p||chapter 3||pages 49–50: generate and test|
|prune.p||chapter 3||pages 50–51:search tree pruning|
|hanext.p||chapter 3||pages 52–53: hanoi search graph 1|
|hanint.p||chapter 3||pages 52–53: hanoi search graph 2|
|proof.p||chapter 3||pages 53–54: addition proof graph|
pages 62–63: closed lists
|eximages.p||chapter 8||image processing utilities|
images from examples in book
|filter.p||chapter 8||pages 169–172: digital filters|
pages 174–175: gradient filters
|gimage.p||chapter 8||image processing utilities|
the ‘gimage’ representation of a pixel image
|image.p||chapter 8||image processing utilities|
simple representation of a pixel image
|threshold.p||chapter 8||pages 166–167: thresholding|
|meansend.p||chapter 9||pages 205–207: means-end analysis|
|blackboard.p||chapter 10||pages 236–238: blackboard architecture|
|life.p||chapter 10||pages 240–241: Conway’s game of Life|