Skip to content

Latest commit

History

1,076 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation



aima-pythonBuild StatusBinder

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.

Structure of the Project

When complete, this project will have Python implementations for all the pseudocode algorithms in the book, as well as tests and examples of use. For each major topic, such as nlp (natural language processing), we provide the following files:

  • nlp.py: Implementations of all the pseudocode algorithms, and necessary support functions/classes/data.
  • tests/test_nlp.py: A lightweight test suite, using assert statements, designed for use with py.test, but also usable on their own.
  • nlp.ipynb: A Jupyter (IPython) notebook that explains and gives examples of how to use the code.
  • nlp_apps.ipynb: A Jupyter notebook that gives example applications of the code.

Python 3.4 and up

This code requires Python 3.4 or later, and does not run in Python 2. You can install Python or use a browser-based Python interpreter such as repl.it. You can run the code in an IDE, or from the command line with python -i filename.py where the -i option puts you in an interactive loop where you can run Python functions. All notebooks are available in a binder environment. Alternatively, visit jupyter.org for instructions on setting up your own Jupyter notebook environment.

Installation Guide

To download the repository:

git clone https://github.com/aimacode/aima-python.git

You also need to fetch the datasets from the aima-data repository:

cd aima-python
git submodule init
git submodule update

Wait for the datasets to download, it may take a while. Once they are downloaded, you need to install pytest, so that you can run the test suite:

pip install pytest

Then to run the tests:

py.test

And you are good to go!

Index of Algorithms

Here is a table of algorithms, the figure, name of the algorithm in the book and in the repository, and the file where they are implemented in the repository. This chart was made for the third edition of the book and is being updated for the upcoming fourth edition. Empty implementations are a good place for contributors to look for an issue. The aima-pseudocode project describes all the algorithms from the book. An asterisk next to the file name denotes the algorithm is not fully implemented. Another great place for contributors to start is by adding tests and writing on the notebooks. You can see which algorithms have tests and notebook sections below. If the algorithm you want to work on is covered, don't worry! You can still add more tests and provide some examples of use in the notebook!

FigureName (in 3rd edition)Name (in repository)FileTestsNotebook
2Random-Vacuum-AgentRandomVacuumAgentagents.pyDoneIncluded
2Model-Based-Vacuum-AgentModelBasedVacuumAgentagents.pyDoneIncluded
2.1EnvironmentEnvironmentagents.pyDoneIncluded
2.1AgentAgentagents.pyDoneIncluded
2.3Table-Driven-Vacuum-AgentTableDrivenVacuumAgentagents.pyDoneIncluded
2.7Table-Driven-AgentTableDrivenAgentagents.pyDoneIncluded
2.8Reflex-Vacuum-AgentReflexVacuumAgentagents.pyDoneIncluded
2.10Simple-Reflex-AgentSimpleReflexAgentagents.pyDoneIncluded
2.12Model-Based-Reflex-AgentReflexAgentWithStateagents.pyDoneIncluded
3ProblemProblemsearch.pyDoneIncluded
3NodeNodesearch.pyDoneIncluded
3QueueQueueutils.pyDoneNo Need
3.1Simple-Problem-Solving-AgentSimpleProblemSolvingAgentsearch.pyDoneIncluded
3.2Romaniaromaniasearch.pyDoneIncluded
3.7Tree-Searchdepth/breadth_first_tree_searchsearch.pyDoneIncluded
3.7Graph-Searchdepth/breadth_first_graph_searchsearch.pyDoneIncluded
3.11Breadth-First-Searchbreadth_first_graph_searchsearch.pyDoneIncluded
3.14Uniform-Cost-Searchuniform_cost_searchsearch.pyDoneIncluded
3.17Depth-Limited-Searchdepth_limited_searchsearch.pyDoneIncluded
3.18Iterative-Deepening-Searchiterative_deepening_searchsearch.pyDoneIncluded
3.22Best-First-Searchbest_first_graph_searchsearch.pyDoneIncluded
3.24A*-Searchastar_searchsearch.pyDoneIncluded
3.26Recursive-Best-First-Searchrecursive_best_first_searchsearch.pyDoneIncluded
4.2Hill-Climbinghill_climbingsearch.pyDoneIncluded
4.5Simulated-Annealingsimulated_annealingsearch.pyDoneIncluded
4.8Genetic-Algorithmgenetic_algorithmsearch.pyDoneIncluded
4.11And-Or-Graph-Searchand_or_graph_searchsearch.pyDoneIncluded
4.21Online-DFS-Agentonline_dfs_agentsearch.pyDoneIncluded
4.24LRTA*-AgentLRTAStarAgentsearch.pyDoneIncluded
5.3Minimax-Decisionminimax_decisiongames.pyDoneIncluded
5.7Alpha-Beta-Searchalphabeta_searchgames.pyDoneIncluded
6CSPCSPcsp.pyDoneIncluded
6.3AC-3AC3csp.pyDoneIncluded
6.5Backtracking-Searchbacktracking_searchcsp.pyDoneIncluded
6.8Min-Conflictsmin_conflictscsp.pyDoneIncluded
6.11Tree-CSP-Solvertree_csp_solvercsp.pyDoneIncluded
7KBKBlogic.pyDoneIncluded
7.1KB-AgentKB_AgentProgramlogic.pyDoneIncluded
7.7Propositional Logic SentenceExprutils.pyDoneIncluded
7.10TT-Entailstt_entailslogic.pyDoneIncluded
7.12PL-Resolutionpl_resolutionlogic.pyDoneIncluded
7.14Convert to CNFto_cnflogic.pyDoneIncluded
7.15PL-FC-Entails?pl_fc_resolutionlogic.pyDoneIncluded
7.17DPLL-Satisfiable?dpll_satisfiablelogic.pyDoneIncluded
7.18WalkSATWalkSATlogic.pyDoneIncluded
7.20Hybrid-Wumpus-AgentHybridWumpusAgent
7.22SATPlanSAT_planlogic.pyDoneIncluded
9Substsubstlogic.pyDoneIncluded
9.1Unifyunifylogic.pyDoneIncluded
9.3FOL-FC-Askfol_fc_asklogic.pyDoneIncluded
9.6FOL-BC-Askfol_bc_asklogic.pyDoneIncluded
10.1Air-Cargo-problemair_cargoplanning.pyDoneIncluded
10.2Spare-Tire-Problemspare_tireplanning.pyDoneIncluded
10.3Three-Block-Towerthree_block_towerplanning.pyDoneIncluded
10.7Cake-Problemhave_cake_and_eat_cake_tooplanning.pyDoneIncluded
10.9GraphplanGraphPlanplanning.pyDoneIncluded
10.13Partial-Order-PlannerPartialOrderPlannerplanning.pyDoneIncluded
11.1Job-Shop-Problem-With-Resourcesjob_shop_problemplanning.pyDoneIncluded
11.5Hierarchical-Searchhierarchical_searchplanning.pyDoneIncluded
11.8Angelic-Searchangelic_searchplanning.pyDoneIncluded
11.10Doubles-tennisdouble_tennis_problemplanning.pyDoneIncluded
13Discrete Probability DistributionProbDistprobability.pyDoneIncluded
13.1DT-AgentDTAgentprobability.pyDoneIncluded
14.9Enumeration-Askenumeration_askprobability.pyDoneIncluded
14.11Elimination-Askelimination_askprobability.pyDoneIncluded
14.13Prior-Sampleprior_sampleprobability.pyDoneIncluded
14.14Rejection-Samplingrejection_samplingprobability.pyDoneIncluded
14.15Likelihood-Weightinglikelihood_weightingprobability.pyDoneIncluded
14.16Gibbs-Askgibbs_askprobability.pyDoneIncluded
15.4Forward-Backwardforward_backwardprobability.pyDoneIncluded
15.6Fixed-Lag-Smoothingfixed_lag_smoothingprobability.pyDoneIncluded
15.17Particle-Filteringparticle_filteringprobability.pyDoneIncluded
16.9Information-Gathering-AgentInformationGatheringAgentprobability.pyDoneIncluded
17.4Value-Iterationvalue_iterationmdp.pyDoneIncluded
17.7Policy-Iterationpolicy_iterationmdp.pyDoneIncluded
17.9POMDP-Value-Iterationpomdp_value_iterationmdp.pyDoneIncluded
18.5Decision-Tree-LearningDecisionTreeLearnerlearning.pyDoneIncluded
18.8Cross-Validationcross_validationlearning.py*
18.11Decision-List-LearningDecisionListLearnerlearning.py*
18.24Back-Prop-LearningBackPropagationLearnerlearning.pyDoneIncluded
18.34AdaBoostAdaBoostlearning.pyDoneIncluded
19.2Current-Best-Learningcurrent_best_learningknowledge.pyDoneIncluded
19.3Version-Space-Learningversion_space_learningknowledge.pyDoneIncluded
19.8Minimal-Consistent-Detminimal_consistent_detknowledge.pyDoneIncluded
19.12FOILFOIL_containerknowledge.pyDoneIncluded
21.2Passive-ADP-AgentPassiveADPAgentrl.pyDoneIncluded
21.4Passive-TD-AgentPassiveTDAgentrl.pyDoneIncluded
21.8Q-Learning-AgentQLearningAgentrl.pyDoneIncluded
22.1HITSHITSnlp.pyDoneIncluded
23Chart-ParseChartnlp.pyDoneIncluded
23.5CYK-ParseCYK_parsenlp.pyDoneIncluded
25.9Monte-Carlo-Localizationmonte_carlo_localizationprobability.pyDoneIncluded

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.

FigureName (in repository)File
3.2romania_mapsearch.py
4.9vacumm_worldsearch.py
4.23one_dim_state_spacesearch.py
6.1australia_mapsearch.py
7.13wumpus_world_inferencelogic.py
7.16horn_clauses_KBlogic.py
17.1sequential_decision_environmentmdp.py
18.2waiting_decision_treelearning.py

Acknowledgements

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, @reachtarunhere, @MrDupin, @Chipe1, @ad71 and @MariannaSpyrakou.

About

Python implementation of algorithms from Russell And Norvig's "Artificial Intelligence - A Modern Approach"

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages