Python implementation of algorithms from Russell And Norvig's "Artificial Intelligence - A Modern Approach"
Jupyter Notebook Python Other
Failed to load latest commit information.
aima-data @ a21fc10 gets latest updates (adds MNIST data) from aima-data submodule Jul 12, 2016
images adds aima3e image to readme (#245) Jul 16, 2016
js Added TicTacToe to notebook (#213) Apr 10, 2016
tests Added implementation of the cake problem, tests for cake and three to… Sep 27, 2016
.gitignore Add .gitignore Mar 3, 2016
.gitmodules Rollback to one folder organization Mar 10, 2016
.travis.yml modified travis file to install jupyter before executing travis script Apr 5, 2016 Edited a link in (#249) Aug 25, 2016
LICENSE Include MIT license Mar 6, 2016 Adding HITS algorithm to completed table (#277) Jan 16, 2017
agents.ipynb added wumpus environment to agents.ipynb Mar 29, 2016 Import turn_heading from since it is used in (#281) Jan 23, 2017 Style: address pep8 warnings in main code. Jun 20, 2016
csp.ipynb Explain backtracking_search parameters Jun 22, 2016 Style: address pep8 warnings in main code. Jun 20, 2016
games.ipynb cleans games notebook and interactive TTT, notebooks imports like 'fr… Jun 7, 2016 Style: address pep8 warnings in main code. Jun 20, 2016
grid.ipynb cleared the outputs in all notebooks Mar 19, 2016 Minor cleanup (#206) Apr 9, 2016
index.ipynb adds 4th edition search notebook May 29, 2016
intro.ipynb Added Info and Binder Badge May 27, 2016 Style: address pep8 warnings. Apr 17, 2016
learning.ipynb adds SVM classifier on MNIST in SkLearn Aug 29, 2016 Used learning_rate in gradient update for w (#284) Mar 1, 2017
logic.ipynb Update logic.ipynb for |'==>'| Apr 12, 2016 Style: address pep8 warnings in main code. Jun 20, 2016
mdp.ipynb Trait Error Fix for older versions of ipywidgets (#241) Jun 14, 2016 Style: address pep8 warnings. Apr 17, 2016
nlp.ipynb cleared the outputs in all notebooks Mar 19, 2016 Implementing HITS algorithm (#244) Sep 7, 2016
planning.ipynb cleared the outputs in all notebooks Mar 19, 2016 Added implementation of the cake problem, tests for cake and three to… Sep 27, 2016
probability-4e.ipynb Update probability-4e.ipynb Jul 31, 2016
probability.ipynb Added Section on Approximate Inference Jul 13, 2016 Added __repr__ to ProbDist Jun 30, 2016
requirements.txt Added networkx in requirements.txt. It is now only used for notebook … Jun 8, 2016
rl.ipynb Added QLearning to IPy Notebook (#221) Apr 12, 2016 Style: address pep8 warnings in main code. Jun 20, 2016
search-4e.ipynb used sgb-words from aimadata rather than downloading a local copy Jun 13, 2016
search.ipynb commits after running all visualisations Jul 1, 2016 Style: address pep8 warnings in main code. Jun 20, 2016
text.ipynb cleared the outputs in all notebooks Mar 19, 2016 Added Default Parameter to Support Smoothing (#246) Sep 7, 2016 Shorthand for True False Aug 6, 2016

aima-python Build Status Binder

Python code for the book Artificial Intelligence: A Modern Approach. You can use this in conjunction with a course on AI, or for study on your own. We're looking for solid contributors to help.

Python 3.4

This code is in Python 3.4 (Python 3.5, also works, but Python 2.x does not). You can install the latest Python version or use a browser-based Python interpreter such as

Structure of the Project

When complete, this project will have Python code for all the pseudocode algorithms in the book. For each major topic, such as logic, we will have the following three files in the main branch:

  • Implementations of all the pseudocode algorithms, and necessary support functions/classes/data.
  • logic.ipynb: A Jupyter (IPython) notebook that explains and gives examples of how to use the code.
  • tests/ A lightweight test suite, using assert statements, designed for use with py.test.

Index of Code

Here is a table of algorithms, the figure, name of the code in the book and in the repository, and the file where they are implemented in the code. This chart was made for the third edition of the book and needs to be updated for the upcoming fourth edition. Empty implementations are a good place for contributors to look for an issue.

Figure Name (in 3rd edition) Name (in repository) File
2.1 Environment Environment
2.1 Agent Agent
2.3 Table-Driven-Vacuum-Agent TableDrivenVacuumAgent
2.7 Table-Driven-Agent TableDrivenAgent
2.8 Reflex-Vacuum-Agent ReflexVacuumAgent
2.10 Simple-Reflex-Agent SimpleReflexAgent
2.12 Model-Based-Reflex-Agent ReflexAgentWithState
3 Problem Problem
3 Node Node
3 Queue Queue
3.1 Simple-Problem-Solving-Agent SimpleProblemSolvingAgent
3.2 Romania romania
3.7 Tree-Search tree_search
3.7 Graph-Search graph_search
3.11 Breadth-First-Search breadth_first_search
3.14 Uniform-Cost-Search uniform_cost_search
3.17 Depth-Limited-Search depth_limited_search
3.18 Iterative-Deepening-Search iterative_deepening_search
3.22 Best-First-Search best_first_graph_search
3.24 A*-Search astar_search
3.26 Recursive-Best-First-Search recursive_best_first_search
4.2 Hill-Climbing hill_climbing
4.5 Simulated-Annealing simulated_annealing
4.8 Genetic-Algorithm genetic_algorithm
4.11 And-Or-Graph-Search and_or_graph_search
4.21 Online-DFS-Agent online_dfs_agent
4.24 LRTA*-Agent LRTAStarAgent
5.3 Minimax-Decision minimax_decision
5.7 Alpha-Beta-Search alphabeta_search
6.3 AC-3 AC3
6.5 Backtracking-Search backtracking_search
6.8 Min-Conflicts min_conflicts
6.11 Tree-CSP-Solver tree_csp_solver
7.1 KB-Agent KB_Agent
7.7 Propositional Logic Sentence Expr
7.10 TT-Entails tt_entials
7.12 PL-Resolution pl_resolution
7.14 Convert to CNF to_cnf
7.15 PL-FC-Entails? pl_fc_resolution
7.17 DPLL-Satisfiable? dpll_satisfiable
7.18 WalkSAT WalkSAT
7.20 Hybrid-Wumpus-Agent
7.22 SATPlan SAT_plan
9 Subst subst
9.1 Unify unify
9.3 FOL-FC-Ask fol_fc_ask
9.6 FOL-BC-Ask fol_bc_ask
9.8 Append
10.1 Air-Cargo-problem
10.2 Spare-Tire-Problem
10.3 Three-Block-Tower
10.7 Cake-Problem
10.9 Graphplan
10.13 Partial-Order-Planner
11.1 Job-Shop-Problem-With-Resources
11.5 Hierarchical-Search
11.8 Angelic-Search
11.10 Doubles-tennis
13 Discrete Probability Distribution ProbDist
13.1 DT-Agent DTAgent
14.9 Enumeration-Ask enumeration_ask
14.11 Elimination-Ask elimination_ask
14.13 Prior-Sample prior_sample
14.14 Rejection-Sampling rejection_sampling
14.15 Likelihood-Weighting likelihood_weighting
14.16 Gibbs-Ask gibbs_ask
15.4 Forward-Backward forward_backward
15.6 Fixed-Lag-Smoothing fixed_lag_smoothing
15.17 Particle-Filtering particle_filtering
16.9 Information-Gathering-Agent
17.4 Value-Iteration value_iteration
17.7 Policy-Iteration policy_iteration
17.7 POMDP-Value-Iteration
18.5 Decision-Tree-Learning DecisionTreeLearner
18.8 Cross-Validation cross_validation
18.11 Decision-List-Learning DecisionListLearner
18.24 Back-Prop-Learning BackPropagationLearner
18.34 AdaBoost AdaBoost
19.2 Current-Best-Learning
19.3 Version-Space-Learning
19.8 Minimal-Consistent-Det
19.12 FOIL
21.2 Passive-ADP-Agent PassiveADPAgent
21.4 Passive-TD-Agent PassiveTDAgent
21.8 Q-Learning-Agent QLearningAgent
23 Chart-Parse Chart
23.5 CYK-Parse CYK_parse
25.9 Monte-Carlo-Localization

Index of data structures

Here is a table of the implemented data structures, the figure, name of the implementation in the repository, and the file where they are implemented.

Figure Name (in repository) File
3.2 romania_map
4.9 vacumm_world
4.23 one_dim_state_space
6.1 australia_map
7.13 wumpus_world_inference
7.16 horn_clauses_KB
17.1 sequential_decision_environment
18.2 waiting_decision_tree


Many thanks for contributions over the years. I got bug reports, corrected code, and other support from Darius Bacon, Phil Ruggera, Peng Shao, Amit Patil, Ted Nienstedt, Jim Martin, Ben Catanzariti, and others. Now that the project is on GitHub, you can see the contributors who are doing a great job of actively improving the project. Many thanks to all contributors, especially @darius, @SnShine, and @reachtarunhere.