C# 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.
Here is a table of algorithms, the figure, name of the code in the book, 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. The aima-pseudocode project describes all the algorithms from the book.
| Fig | Page | Name (in book) | Code |
|---|---|---|---|
| 2 | 34 | Environment | Environment |
| 2.1 | 35 | Agent | Agent |
| 2 | Random-Agent-Program | RandomAgentProgram | |
| 2 | Random-Vacuum-Agent | RandomVacuumAgent | |
| 2.3 | 36 | Table-Driven-Vacuum-Agent | TableDrivenVacuumAgent |
| 2.7 | 47 | Table-Driven-Agent | TableDrivenAgentProgram |
| 2.8 | 48 | Reflex-Vacuum-Agent | ReflexVacuumAgent |
| 2.10 | 49 | Simple-Reflex-Agent | SimpleReflexAgentProgram |
| 2.12 | 51 | Model-Based-Reflex-Agent | ModelBasedReflexAgentProgram |
| 2 | Model-Based-Vacuum-Agent | ModelBasedVacuumAgent | |
| 3 | 66 | Problem | |
| 3.1 | 67 | Simple-Problem-Solving-Agent | SimpleProblemSolvingAgent |
| 3.2 | 68 | Romania | SimplifiedRoadMapOfPartOfRomania |
| 3.7 | 77 | Tree-Search | TreeSearch |
| 3.7 | 77 | Graph-Search | GraphSearch |
| 3.10 | 79 | Node | Node |
| 3.11 | 82 | Breadth-First-Search | BreadthFirstSearch |
| 3.14 | 84 | Uniform-Cost-Search | UniformCostSearch |
| 3 | 85 | Depth-First-Search | DepthFirstSearch |
| 3.17 | 88 | Depth-Limited-Search | DepthLimitedSearch |
| 3.18 | 89 | Iterative-Deepening-Search | IterativeDeepeningSearch |
| 3 | 90 | Bidirectional-Search | BidirectionalBestFirstSearch |
| 3 | 92 | Best-First-Search | BestFirstSearch |
| 3 | 92 | Greedy-Best-First-Search | GreedyBestFirstSearch |
| 3 | 93 | A* Search | AStarSearch |
| 3 | Iterative-Deepening-A*-Search | IterativeDeepeningAStarSearch | |
| 3.26 | 99 | Recursive-Best-First-Search | RecursiveBestFirstSearch |
| 3 | 101 | SMA* | SMAStarSearch |
| 3 | Grid-Problem | GridProblem | |
| 3 | Pour-Problem | PourProblem | |
| 3 | Traveling-Salesman-Problem | TravelingSalesmanProblem | |
| 4.2 | 122 | Hill-Climbing | HillClimbingSearch |
| 4 | Stochastic-Hill-Climbing | StochasticHillClimbingSearch | |
| 4 | First-Choice-Hill-Climbing | FirstChoiceHillClimbingSearch | |
| 4 | Random-Restart-Hill-Climbing | RandomRestartHillClimbingSearch | |
| 4 | Peak-Finding-Problem | PeakFindingProblem | |
| 4.5 | 126 | Simulated-Annealing | SimulatedAnnealingSearch |
| 4 | Local-Beam-Search | LocalBeamSearch | |
| 4.8 | 129 | Genetic-Algorithm | GeneticAlgorithm |
| 4.11 | 136 | And-Or-Graph-Search | AndOrSearch |
| 4 | 147 | Online-Search-Problem | OnlineSearchProblem |
| 4.21 | 150 | Online-DFS-Agent | OnlineDFSAgent |
| 4.24 | 152 | LRTA*-Agent | LRTAStarAgent |
| 5.3 | 166 | Minimax-Decision | MinimaxSearch |
| 5.7 | 170 | Alpha-Beta-Search | AlphaBetaSearch |
| 5 | Alpha-Beta-Cutoff-Search | AlphaBetaCutoffSearch | |
| 5 | Stochastic-Game | StochasticGame | |
| 5 | Expectiminimax | ExpectiminimaxSearch | |
| 5 | Random-Player | RandomPlayer | |
| 5 | Play-Game | GamePlay | |
| 5.11 (4e) | Monte-Carlo-Tree-Search | MonteCarloTreeSearch | |
| 6 | 202 | CSP | CSP |
| 6.1 | 204 | Map-CSP | MapCSP |
| 6.2 | Cryptarithmetic | NaryCSPExamples | |
| 6 | Map-Coloring-CSP | MapColoringCSP | |
| 6.3 | 209 | AC-3 | AC3Strategy |
| 6.3 | AC-3b | AC3bStrategy | |
| 6 | AC-4 | AC4Strategy | |
| 6 | Arc-Heuristics (dom_j_up) | ArcHeuristic | |
| 6.5 | 215 | Backtracking-Search | AbstractBacktrackingSolver |
| 6.8 | 221 | Min-Conflicts | MinConflictsSolver |
| 6.11 | 224 | Tree-CSP-Solver | TreeCspSolver |
| 6 | N-ary-CSP | NaryCSP | |
| 6 | N-ary-Constraint | NaryConstraint | |
| 6 | AC-Solver (GAC, domain splitting) | ACSolver | |
| 6 | AC-Search-Solver | ACSearchSolver | |
| 6 | GAC-Heuristics (sat_up) | GacHeuristic | |
| 6 | Sudoku | SudokuCSP | |
| 6 | Zebra | ZebraCSP | |
| 6 | Crossword | CrosswordCSP | |
| 6 | Kakuro | KakuroCSP | |
| 7 | 235 | Knowledge-Base | KnowledgeBase |
| 7.1 | 236 | KB-Agent | KBAgent |
| 7.7 | 244 | Propositional-Logic-Sentence | Sentence |
| 7.10 | 248 | TT-Entails | TTEntails |
| 7 | 253 | Convert-to-CNF | ConvertToCNF |
| 7.12 | 255 | PL-Resolution | PLResolution |
| 7.15 | 258 | PL-FC-Entails? | PLFCEntails |
| 7.17 | 261 | DPLL-Satisfiable? | DPLL |
| 7.17 | 261 | DPLL branching heuristics (MOMS, MOMSF, POSIT, ZM, DLIS, DLCS, JW, JW2) | BranchingHeuristics |
| 7 | 263 | CDCL | CDCL |
| 7 | 263 | Two-Watched-Literals | TwoWLClauseDatabase |
| 7 | 263 | Restart strategies (Luby, Glucose) | RestartStrategies |
| 7.18 | 263 | WalkSAT | WalkSAT |
| 7 | 264 | Map-Coloring-SAT | MapColoringSAT |
| 7.20 | 270 | Hybrid-Wumpus-Agent | HybridWumpusAgent |
| 7.22 | 272 | SATPlan | SATPlan |
| 9 | 323 | Subst | |
| 9.1 | 328 | Unify | Unifier |
| 9.1 | 328 | Unify (Martelli-Montanari) | MartelliMontanariUnifier |
| 9.3 | 332 | FOL-FC-Ask | FOLFCAsk |
| 9.3 | 332 | FOL-BC-Ask | FOLBCAsk |
| 9.8 | 341 | Append | Append |
| 9 | 345 | CNF | CNFConverter |
| 9 | 347 | Resolution | FOLTFMResolution |
| 9 | 354 | Demodulation | Demodulation |
| 9 | 354 | Paramodulation | Paramodulation |
| 9 | 345 | Subsumption | SubsumptionElimination |
| 10.1 | 369 | Air-Cargo-Transport-Problem | PlanningProblemFactory |
| 10.2 | 370 | Spare-Tire-Problem | PlanningProblemFactory |
| 10.3 | 371 | Blocks-World | PlanningProblemFactory |
| 10.7 | 380 | Have-Cake-And-Eat-Cake-Too-Problem | PlanningProblemFactory |
| 10 | Forward-State-Space-Search | ForwardPlan | |
| 10 | Backward-State-Space-Search | BackwardPlan | |
| 10 | Planning-Graph | PlanningGraph | |
| 10.9 | 383 | Graphplan | GraphPlan |
| 10 | Linearize | Linearize | |
| 10.13 | Partial-Order-Planner | PartialOrderPlanner | |
| 10 | SATPlan (planning problem) | SATPlanner | |
| 10 | CSPlan | CSPlan | |
| 11.1 | 402 | Job-Shop-Scheduling-Problem | JobShopSchedulingProblem |
| 11.4 | 407 | Refinement-High-Level-Actions | HighLevelAction |
| 11.5 | 409 | Hierarchical-Search | HierarchicalSearchAlgorithm |
| 11.8 | 414 | Angelic-Search | AngelicSearchAlgorithm |
| 11.10 | Doubles-Tennis-Problem | PlanningProblemFactory | |
| 13.1 | 484 | DT-Agent | DTAgent |
| 13 | 484 | Probability-Model | |
| 13 | 487 | Probability-Distribution | ProbabilityTable |
| 13 | 490 | Full-Joint-Distribution | FullJointDistribution |
| 14 | 510 | Bayesian-Network | |
| 14.9 | 525 | Enumeration-Ask | EnumerationAsk |
| 14.11 | 528 | Elimination-Ask | EliminationAsk |
| 14.13 | 531 | Prior-Sample | PriorSample |
| 14.14 | 533 | Rejection-Sampling | RejectionSampling |
| 14.15 | 534 | Likelihood-Weighting | LikelihoodWeighting |
| 14.16 | 537 | Gibbs-Ask | |
| 14 | 510 | Bayesian Network | BayesNet |
| 14 | Hybrid-Bayesian-Network | ContinuousBayesNode | |
| 14 | Read-BIF | BIFReader | |
| 14.16 | 537 | GIBBS-Ask | GibbsAsk |
| 15.4 | 576 | Forward-Backward | HMMForwardBackward |
| 15 | 578 | Hidden-Markov-Model | |
| 15.6 | 580 | Fixed-Lag-Smoothing | FixedLagSmoothing |
| 15 | Viterbi | Viterbi | |
| 15 | Kalman-Filter | KalmanFilter | |
| 15 | DBN-Unrolling | DBNUnrolling | |
| 15 | 590 | Dynamic-Bayesian-Network | |
| 15.17 | 598 | Particle-Filtering | ParticleFiltering |
| 15 | 578 | Hidden Markov Model | HMM |
| 15 | 590 | Dynamic Bayesian Network | DynamicBayesNet |
| 15.5 (4e) | OUPM | CitationWorld | |
| 15.6 (4e) | Net-Visa | SeismicWorld | |
| 15.9 (4e) | Radar | RadarWorld | |
| 15.11 (4e) | Generate-Image | GenerateImage | |
| 15.15 (4e) | Generate-Markov-Letters | GenerateMarkovLetters | |
| 16.9 | 632 | Information-Gathering-Agent | InformationGatheringAgent |
| 17 | 647 | Markov-Decision-Process | |
| 17 | 647 | Markov Decision Process | MDP |
| 17.4 | 653 | Value-Iteration | ValueIteration |
| 17.7 | 657 | Policy-Iteration | PolicyIteration |
| 17.9 | 663 | POMDP-Value-Iteration | POMDPValueIteration |
| 17 | Dynamic-Decision-Network | DynamicDecisionNetwork | |
| 18.2 (4e) | Iterated-Dominance | NormalFormGame | |
| 18.2 (4e) | Pure-Nash-Equilibria | NormalFormGame | |
| 18.2 (4e) | Zero-Sum-Game (LP) | NormalFormGame | |
| 18.3 (4e) | Shapley-Value | CooperativeGame | |
| 18.3 (4e) | Core | CooperativeGame | |
| 18.4 (4e) | Voting (plurality, Borda, Condorcet) | SocialChoice | |
| 18.4 (4e) | Vickrey-Auction | Mechanisms | |
| 18.4.1 (4e) | Contract-Net-Protocol | Mechanisms | |
| 18.4.4 (4e) | Alternating-Offers-Bargaining | Mechanisms | |
| 18.5 | 702 | Decision-Tree-Learning | DecisionTreeLearner |
| 18.8 | 710 | Cross-Validation-Wrapper | CrossValidation |
| 18.11 | 717 | Decision-List-Learning | DecisionListLearner |
| 18.24 | 734 | Back-Prop-Learning | NeuralNetworkLearner |
| 18.34 | 751 | AdaBoost | AdaBoostLearner |
| 18 | K-Nearest-Neighbors | KNearestNeighborsLearner | |
| 18 | Linear-Regression | LinearRegression | |
| 18 | Logistic-Regression | LogisticRegression | |
| 18 | Perceptron | PerceptronLearner | |
| 18 | Support-Vector-Machine (SMO) | SVC | |
| 18 | Support-Vector-Regression | SVR | |
| 18 | Ensemble-Learning | EnsembleLearner | |
| 18 | Random-Forest | RandomForestLearner | |
| 18 | Weighted-Replicate | ReplicatedWeightedLearner | |
| 19.2 | 771 | Current-Best-Learning | CurrentBestLearning |
| 19.3 | 773 | Version-Space-Learning | VersionSpaceLearning |
| 19.8 | 786 | Minimal-Consistent-Det | MinimalConsistentDet |
| 19.12 | 793 | FOIL | FOILContainer |
| 20 | Naive-Bayes | NaiveBayesLearner | |
| 20 | Gaussian-Naive-Bayes | GaussianNaiveBayesLearner | |
| 20 | Counting-Probability-Distribution | CountingProbDist | |
| 20 | EM (Mixture of Gaussians) | GaussianMixtureEM | |
| 20 | EM (Bayes net hidden variable) | NaiveBayesEM | |
| 20 | Baum-Welch | BaumWelch | |
| 21.1 (4e) | Dense-Network (back-propagation) | DenseNetwork | |
| 21 (4e) | Stochastic-Gradient-Descent | StochasticGradientDescent | |
| 21 (4e) | Adam | Adam | |
| 21.3 (4e) | Convolution, Pooling, Batch-Normalization | ConvLayer1D | |
| 21.2 | 834 | Passive-ADP-Agent | PassiveADPAgent |
| 21.4 | 837 | Passive-TD-Agent | PassiveTDAgent |
| 21.8 | 844 | Q-Learning-Agent | QLearningAgent |
| 21 | Passive-DUE-Agent | PassiveDUEAgent | |
| 21 | SARSA-Agent | SARSAAgent | |
| 22 | N-Gram-Word-Model | NgramWordModel | |
| 22 | N-Gram-Char-Model | NgramCharModel | |
| 22 | Viterbi-Segmentation | ViterbiSegmentation | |
| 22 | IR-System | IRSystem | |
| 22 | Shift-Decoder | ShiftDecoder | |
| 22.1 | 871 | HITS | HITS |
| 22 | Grammar | Grammar | |
| 23 | Probabilistic-Grammar | ProbGrammar | |
| 22 | Chart-Parse | Chart | |
| 23 | Parsing-As-Search (A*, beam) | TextParsing | |
| 23.5 | 894 | CYK-Parse | CYK |
| 23.6 | 895 | Sentence-Tree | Treebank |
| 24 | Edge-Detection | ImageProcessing | |
| 24 | Histogram-Of-Oriented-Gradients | ImageProcessing | |
| 24 | Optical-Flow (sum of squared differences) | ImageProcessing | |
| 24 | Segmentation (contours, k-means, minimum cut) | Segmentation | |
| 24 | ROI-Pooling | Segmentation | |
| 25.9 | 982 | Monte-Carlo-Localization | MonteCarloLocalization |
| 29.1 | Powers-Of-2 | PowersOfTwo |
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 | OneDimStateSpace |
| 6.1 | australia_map | |
| 7.13 | wumpus_world_inference | |
| 7.16 | horn_clauses_KB | |
| 17.1 | sequential_decision_environment | CellWorldFactory |
| 18.2 | waiting_decision_tree |
aima-python · aima-java · aima-scala · aima-julia · aima-lisp · aima-javascript · aima-pseudocode · aima-exercises · aima-data · aima-glossary