What's new? | Help | Directory | Sign in
Google
aima-python
Python implementation of algorithms from Russell and Norvig's 'Artificial Intelligence: A Modern Approach'
  
  
  
  
    
Search
for
Updated Oct 01, 2007 by peter.norvig
Labels: Featured, Phase-Deploy
ReadMe  
How to use the aima-python project.

Introduction

This file gives an overview of the Python code for the algorithms in the textbook Artificial Intelligence: A Modern Approach, also known as AIMA. The code is offered free for your use under the MIT License. As you may know, the textbook presents algorithms in pseudo-code format; as a supplement we provide this code. The intent is to implement all the algorithms in the book, but we are not done yet.

How to Browse the Code

You can get some use out of the code here just by browsing, starting at the root of the source tree or by clicking on the links in the index on the project home page. The source code is in the .py files; the .txt files give examples of how to use the code.

How to Install the Code

If you like what you see, install the code using either one of these methods:

  1. From a command shell on your computer, execute the svn checkout command given on the source tab of the project. This assumes you have previously installed the version control system Subversion (svn).
  2. Download and unzip the zip file listed as a "Featured download"on the right hand side of the project home page.

You'll also need to install the data files from the aima-data project. These are text files that are used by the tests in the aima-python project, and may be useful for yout own work.

You can put the code anywhere you want on your computer, but it should be in one directory (you might call it aima but you are free to use whatever name you want) with aima-python as a subdirectory that contains all the files from this project, and data as a parallel subdirectory that contains all the files from the aima-data project.

How to Test the Code

First, you need to install Python (version 2.2 or later). Python comes preinstalled on most versions of Linux and Mac OS. Versions are also available for Windows, Solaris, and other operating systems. If your system does not have Python installed, you can download and install it for free.

In the aima-python directory, execute the command

python doctests.py -v *.py

The "-v" is optional; it means "verbose". Various output is printed, but if all goes well there should be no instances of the word "Failure", nor of a long line of "". If you do use the "-v" option, the last line printed should be "Test passed."

How to Run the Code

You're on your own -- experiment! Create a new python file, import the modules you need, and call the functions you want.

Acknowledgements

Many thanks for the bug reports, corrected code, and other support from Phil Ruggera, Peng Shao, Amit Patil, Ted Nienstedt, Jim Martin, Ben Catanzariti, and others.


Comment by esmarin, Dec 12, 2007

Hi,

I just downloaded the zip files and found some problems. Some tests failed because they point to ../data instead of ../aima-data (fixed that with a symbolic link) . Then other tests failed because of missing files (../data/wordlist, ../data/flat11.txt).
I was wondering before in install svn if the code in the zip files differs from what svn is going to give me.
By the way, GREAT BOOK!
Thanks

Comment by ulfada, Feb 12, 2008

Just wanted to note that on my machine (MacBook? Pro with Python 2.5), about 7 tests fail because of different ordering for dicts and such. Sort of an annoying part of the way doctests is set up. I can get you details if you'd like. I tried making the tests general enough to handle these issues, but it got nonsensical pretty quickly. I'm hoping to come up with some additional code to fill in some of the missing algorithms, so feel free to add me to the project.


Sign in to add a comment