A complete tutorial on AI overview, intelligent agents, and problem-solving with worked examples and diagrams
What separates a pocket calculator from a chess-playing computer? Both process instructions — but only one can adapt, reason, and learn. That gap is what Artificial Intelligence tries to close. Since Alan Turing asked "Can machines think?" in 1950, AI has evolved from a philosophical curiosity into a field that powers recommendation engines, autonomous vehicles, medical diagnosis, and language translation used by billions every day.
Formally, AI is the study of agents that receive percepts from the environment and perform actions. The field draws from mathematics, psychology, linguistics, neuroscience, and computer science to build systems that exhibit behaviours we would call intelligent if a human performed them.
Before we can build intelligent systems, however, we need to understand the problems AI tries to solve, the techniques it employs, and why even a simple game like Tic-Tac-Toe turns out to be a surprisingly rich AI training ground.
There is no single universally accepted definition. Researchers have historically proposed four categories of definition, arranged in a 2×2 grid based on two axes: human-like vs. rational and thinking vs. acting.
Examiners frequently ask: "What are the four definitions of AI?" Memorise the 2×2 grid. The rational agent approach is the dominant framework in the Russell & Norvig textbook and in modern AI systems.
AI does not tackle all computational problems — it focuses on a specific class where the solution requires intelligence. These problems share two key characteristics: they are typically too complex for direct algorithmic solutions, and their solutions benefit from heuristic or learned knowledge.
| Problem Class | Example | Why It Needs AI | Difficulty |
|---|---|---|---|
| Game Playing | Chess, Go, Tic-Tac-Toe | Combinatorial explosion of possible states | Medium–Hard |
| Natural Language Processing | Machine translation, QA | Ambiguity, context, pragmatics | Hard |
| Computer Vision | Face recognition, object detection | Variation in lighting, angle, occlusion | Hard |
| Planning & Scheduling | Robot navigation, logistics | Large state/action spaces, constraints | Medium–Hard |
| Expert Reasoning | Medical diagnosis, legal advice | Uncertain, incomplete information | Hard |
| Learning | Image classification, GPT | Generalisation from examples | Very Hard |
How does AI actually solve these hard problems? Russell & Norvig describe an AI technique as a method that exploits knowledge in a form that:
An AI technique is a method by which AI programs represent, manipulate, and use knowledge about the world — such that:
This contrasts with brute-force approaches that enumerate all possibilities. A chess program that evaluates every possible game tree (approximately 10120 leaf nodes) is not using an AI technique — it is merely computing. A program that uses heuristics like "control the centre" or "protect the king" is using an AI technique.
Tic-Tac-Toe (also called Noughts & Crosses) is a 3×3 grid game where two players, X and O, alternate placing their mark. The player who first aligns three marks in a row, column, or diagonal wins. If the board fills up without a winner, the game is a draw.
Despite its simplicity, Tic-Tac-Toe is a canonical AI problem because it encapsulates the core challenge: how do we choose the best action among many possible future sequences? It is also a two-player, zero-sum, perfect-information game — all properties that make it mathematically tractable.
A state in Tic-Tac-Toe is any configuration of the 3×3 board. The total number of board configurations is at most 39 = 19,683 (each cell can be X, O, or empty). After eliminating illegal boards (e.g. X moved twice in a row), about 5,478 valid states remain, with 255,168 possible game sequences.
The game tree shows all possible moves from the current state. At the root, X can place in any of 9 cells. At depth 2, O can respond in 8 remaining cells, and so on. The branching factor decreases as the board fills.
AI solves Tic-Tac-Toe using the Minimax algorithm. X is the maximising player (wants highest score), and O is the minimising player (wants lowest score). At terminal nodes: Win = +1, Draw = 0, Loss = −1. The AI propagates values upwards, always choosing the best move at each level.
With perfect play from both sides, Tic-Tac-Toe is always a draw. This is provable by exhaustive minimax search — and was one of the first results in AI game theory.
Tic-Tac-Toe is important not because it is hard, but because it illustrates the core ideas of AI problem solving in a compact, verifiable form: state representation, search, terminal evaluation, and adversarial reasoning. Every harder AI game (chess, Go) uses the same framework.
Now that we understand what AI is, we need a framework for building AI systems. The dominant framework is the agent paradigm. Think of any intelligent entity — a thermostat, a chess program, or a self-driving car. Each one perceives its environment and takes actions. The agent abstraction lets us analyse and design all of these using the same vocabulary.
Building on the rational agent definition from Section 1, we now ask: what is the structure of such an agent? What types of environments can it live in? And how does the structure of the agent match the nature of its environment? These are the core questions of this section.
An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment through actuators.
Examples: A human (sensors = eyes, ears; actuators = hands, mouth), a software agent (sensors = keyboard input, file reads; actuators = screen output, API calls), a robot (sensors = cameras, LIDAR; actuators = motors, grippers).
A percept is the agent's perceptual input at any given instant. The complete history of everything the agent has perceived is the percept sequence. An agent's behaviour is described by its agent function, which maps every percept sequence to an action.
A rational agent is one that, for each possible percept sequence, selects an action expected to maximise its performance measure, given the evidence provided by the percept sequence and any built-in prior knowledge.
Rationality ≠ omniscience. A rational agent makes the best decision with available information. This is a commonly tested distinction.
Before designing an agent, we must specify its task environment using the PEAS framework. This is one of the most commonly tested items in exams.
Performance measure — How do we evaluate success? (e.g., score, time, accuracy)
Environment — What does the agent perceive? (e.g., road, chess board, medical records)
Actuators — How does the agent act? (e.g., steering wheel, chess move, prescription)
Sensors — How does the agent perceive? (e.g., cameras, keyboard, test results)
| Agent Type | Performance Measure | Environment | Actuators | Sensors |
|---|---|---|---|---|
| Autonomous Car | Safety, speed, comfort, legality | Roads, traffic, pedestrians, weather | Steering, accelerator, brakes, signals | Cameras, LIDAR, GPS, speedometer |
| Medical Diagnosis | Correct diagnosis, patient health | Patient symptoms, test results, history | Prescriptions, referrals, test orders | Keyboard input, lab data feeds |
| Tic-Tac-Toe Agent | Win / Draw / Lose (+1/0/−1) | 3×3 board, opponent's moves | Board position selection | Current board state display |
Different environments demand different agent strategies. There are seven key properties by which environments are classified. This table is a very common exam question — memorise all seven dimensions.
| Property | Values | Description | Example |
|---|---|---|---|
| Observability | Fully / Partially / Non-observable | Can the agent access the complete state? | Chess = Full; Poker = Partial |
| Number of Agents | Single / Multi-agent | Is the agent alone or competing/cooperating? | Crossword = Single; Chess = Multi |
| Determinism | Deterministic / Stochastic | Is the next state fully determined by action? | Chess = Det; Taxi driving = Stoch |
| Episodicity | Episodic / Sequential | Does current decision affect future decisions? | Image classification = Epi; Chess = Seq |
| Dynamics | Static / Dynamic / Semi-dynamic | Does the environment change while agent thinks? | Crossword = Static; Taxi = Dynamic |
| Continuity | Discrete / Continuous | Finite or infinite percepts/actions? | Chess = Discrete; Robot arm = Continuous |
| Knowledge | Known / Unknown | Does the agent know the outcome of its actions? | Chess rules = Known; New game = Unknown |
The hardest environments combine partial observability, multiple agents, stochastic dynamics, sequential decisions, and continuous state/action spaces — like real-world robotics or stock trading. Tic-Tac-Toe is fully observable, deterministic, discrete, and sequential — which is why it is tractable.
The agent function is an abstract description. The agent program is its concrete implementation. It runs on an agent architecture (the computational device + sensors + actuators). There are four basic agent program types, each more sophisticated than the last.
A goal-based agent maintains a description of desirable situations — the goal — and chooses actions that lead toward that goal. It requires both a model of the world (how actions change the state) and a search/planning mechanism to find action sequences that achieve the goal.
Unlike a simple reflex agent, a goal-based agent can handle situations where multiple actions are possible and the current state does not directly trigger a rule. It is more flexible but computationally more expensive.
Goals alone cannot distinguish between achieving a goal and achieving it well. A utility-based agent uses a utility function — mapping states to real numbers — to measure how "happy" the agent would be in each state. It then chooses actions that maximise expected utility.
Utility-based agents can handle conflicting goals (e.g., reaching a destination fast vs. safely), partial observability (via expected utility), and continuous state spaces.
All agent types above rely on pre-programmed knowledge. A learning agent can improve its own performance over time by modifying its components based on feedback. It has four sub-components:
Performance Element: Selects actions based on percepts — this is the "core" agent program (reflex, goal-based, or utility-based).
Learning Element: Modifies the performance element based on feedback from the critic. It uses machine learning algorithms (e.g., neural networks, reinforcement learning).
Critic: Evaluates how well the agent is doing with respect to a fixed performance standard and provides feedback to the learning element.
Problem Generator: Suggests actions that may be suboptimal in the short run but will lead to new experiences — enabling exploration vs. exploitation.
A common exam trap: rationality ≠ omniscience. A rational agent maximises expected utility based on what it knows — not actual utility. A rational agent crossing a road checks for traffic and crosses when safe. An omniscient agent would know the future and never be hit. We cannot build omniscient agents. We can build rational ones.
Building on the agent framework, we now ask: how does a goal-based agent actually decide what to do? The answer is problem-solving via search. The agent explores a space of possible states to find a sequence of actions — a plan — that leads from the initial state to a goal state.
This section introduces the formal machinery: how to define a problem, what makes a problem hard, and how production systems encode the rules of state transitions. These concepts underpin every search algorithm you will study — BFS, DFS, A*, and beyond.
A problem is formally defined by five components:
In(Arad)ACTIONS(s)a in state s. RESULT(s, a)GOAL-TEST(s)The state space is the set of all states reachable from the initial state by any sequence of actions. It forms a graph (or tree) that the agent searches.
The 8-puzzle has a 3×3 grid with 8 numbered tiles and one blank. The agent slides tiles to reach a goal configuration. This is the canonical search problem in AI courses.
| Component | 8-Puzzle Specification |
|---|---|
| Initial State | Any arrangement of 8 tiles + 1 blank, e.g. [1,2,3,4,_,5,6,7,8] |
| Actions | Slide blank Left, Right, Up, Down (depending on blank position) |
| Transition Model | RESULT(s, Slide-Right) = new arrangement after moving blank right |
| Goal Test | [1,2,3,4,5,6,7,8,_] — tiles in order, blank at bottom-right |
| Path Cost | Each move costs 1; total cost = number of moves to reach goal |
| State Space Size | 9! / 2 = 181,440 reachable states (half of 9! are unreachable) |
| Solution | Sequence of Slide moves; optimal solution uses A* with Manhattan distance heuristic |
A production system is one of the earliest and most important AI architectures for implementing state space search. Introduced by Allen Newell and Herbert Simon, it provides a formal way to represent knowledge as condition–action rules and a control mechanism to apply them.
A production system consists of three components:
IF <condition> THEN <action>. Each rule is a production.Match: Compare all production rules against the current working memory. Identify all rules whose LHS (left-hand side / condition) is satisfied. The result is the conflict set.
Conflict Resolution: If the conflict set is empty, halt (goal reached or no solution). Otherwise, select one rule to fire using a strategy: e.g., most recently added, most specific, highest priority.
Act (Fire): Execute the RHS (right-hand side / action) of the selected rule. This modifies working memory — adding facts, removing facts, or triggering external actions.
Check Goal: Test whether the current working memory satisfies the goal condition. If yes, halt and return solution path. Otherwise, goto Step 1.
Current board = [[X,O,_],[_,X,_],[O,_,_]] — X's turn to move.
-- Rule R1: Win immediately if possible --
IF board has two X's in a row/col/diag AND third cell is empty
THEN place X in the empty cell → "WIN"
-- Rule R2: Block opponent's win --
IF board has two O's in a row/col/diag AND third cell is empty
THEN place X in the empty cell → "BLOCK"
-- Rule R3: Take centre if empty --
IF centre cell is empty
THEN place X in centre → "STRATEGIC"
-- Rule R4: Take a corner if empty --
IF any corner is empty
THEN place X in that corner → "STRATEGIC"
-- Rule R5: Take any empty cell --
IF any cell is empty
THEN place X in that cell → "DEFAULT"
| Cycle | Working Memory | Rules Fired | Action |
|---|---|---|---|
| 1 | [[X,O,_],[_,X,_],[O,_,_]] | R1 matches! Two X's diagonal (0,0)+(1,1) | Place X at (2,2) — WIN ✓ |
Rule R1 fires immediately — winning takes priority over blocking or strategy. The goal test succeeds: X wins. The production system halts after one cycle.
Not all AI problems are equally hard. The difficulty depends on several characteristics — understanding these helps us choose the right search strategy. This taxonomy is a staple of exam questions.
| Characteristic | Options | Impact on Search | Example |
|---|---|---|---|
| Decomposability | Decomposable / Non-decomposable | Can we break the problem into independent sub-problems? | Sorting sub-arrays = Decomposable TSP = Non-decomposable |
| Solution Steps | Ignorable / Recoverable / Irrecoverable | Can we backtrack from wrong moves? | Chess = Recoverable; Surgery = Irrecoverable |
| State Space | Predictable / Unpredictable | Does the environment respond as expected? | 8-puzzle = Predictable; Robot nav = Unpredictable |
| Good Solution | Absolute / Relative | Is optimal solution required, or is "good enough" acceptable? | Optimal path = Absolute; Route planning = Relative |
| Solution Required | Any path / Best path | Does cost matter? Do we need optimal or just valid? | Maze (any exit) vs. Shortest route |
| Knowledge | Much / Little available | Amount of domain knowledge affects algorithm choice (heuristic vs. blind) | Medical diagnosis (much) vs. Unknown game (little) |
Even with a well-defined problem, designing an effective search program requires navigating several fundamental tensions. These are the engineering challenges of search.
A search algorithm is complete if it is guaranteed to find a solution when one exists. BFS is complete for finite graphs; DFS is not (may get trapped in infinite branches). This is a commonly tested property.
A search algorithm is optimal if it always finds the least-cost solution. BFS is optimal when all step costs are equal; Greedy Best-First Search is generally not optimal; A* is optimal given an admissible heuristic.
The central challenge of AI search is combinatorial explosion. At branching factor b = 10 and depth d = 10, the search tree has 1010 = 10 billion leaf nodes. Without heuristics, even fast computers cannot search deep trees. This is why AI techniques (heuristics, pruning, abstraction) are essential — brute-force search fails on realistic problems.
Initialise: Create a frontier (open list) with the initial state. Create an explored set (closed list), initially empty.
Check: If frontier is empty, return failure (no solution exists).
Select: Choose a node from the frontier according to the selection strategy. BFS = FIFO queue; DFS = LIFO stack; A* = priority queue ordered by f(n) = g(n) + h(n).
Goal Test: If the selected node is a goal state, return the solution path. Otherwise, add the node to the explored set.
Expand: Generate all successors of the node using ACTIONS and RESULT. For each successor not already in explored or frontier, add it to the frontier.
Repeat: Go to Step 2.
The design of a search program requires choosing: (1) a state representation, (2) a frontier management strategy (queue type), (3) whether to use heuristics, and (4) how to handle repeated states. These choices determine completeness, optimality, time complexity, and space complexity — the four evaluation criteria for search algorithms.
The general search template from Section 3 becomes a concrete algorithm the moment we decide which node to expand next. When that decision uses no information about the goal — no hints, no distance estimates — we call it uninformed (or blind) search. These strategies are guaranteed to find solutions (under certain conditions) but may be expensive because they explore systematically rather than intelligently.
Two foundational uninformed strategies are Breadth-First Search (BFS) and Depth-First Search (DFS). Understanding them deeply, including their strengths, weaknesses, and complexity, is essential — they form the baseline against which all smarter algorithms are judged.
Uninformed search algorithms are not just theoretical curiosities. BFS is used in shortest-path finding on unweighted graphs (network routing, social network distances). DFS underpins backtracking solvers (Sudoku, constraint satisfaction). Iterative Deepening DFS combines the best of both and is the standard uninformed strategy in production AI systems.
BFS expands the shallowest unexpanded node first. It uses a FIFO queue as the frontier. All nodes at depth d are explored before any node at depth d+1.
Consider a simplified map of Romanian cities (the classic Russell & Norvig example). We want to travel from Arad to Bucharest. Below is the graph and the BFS expansion order.
| Step | Node Expanded | Frontier (Queue — FIFO) | Explored |
|---|---|---|---|
| 0 | — | [Arad] | {} |
| 1 | Arad ① | [Zerind, Sibiu, Timisoara] | {Arad} |
| 2 | Zerind ② | [Sibiu, Timisoara, Oradea] | {Arad, Zerind} |
| 3 | Sibiu ③ | [Timisoara, Oradea, RimnicuVilcea, Fagaras] | {Arad, Zerind, Sibiu} |
| 4 | Timisoara ④ | [Oradea, RimnicuVilcea, Fagaras, Lugoj] | + Timisoara |
| 5–8 | Oradea ⑤, RimnicuVilcea ⑥, Fagaras ⑦, Lugoj ⑧ | [Pitesti, Craiova, Bucharest, ...] | + depth-2 cities |
| 9 | Pitesti ⑨ → generates Bucharest | [Craiova, Bucharest, ...] | + Pitesti |
| 10 | Bucharest — GOAL TEST PASSES ✓ | — | Solution found! |
BFS finds Bucharest via Arad → Sibiu → Fagaras → Bucharest (3 edges = shallowest path). Note: this is the fewest-edges path, not necessarily the shortest distance path. For that, we need weighted search (Uniform Cost Search or A*).
DFS expands the deepest unexpanded node first. It uses a LIFO stack (or recursion) as the frontier. It dives as deep as possible before backtracking.
DFS's critical advantage over BFS is space efficiency. BFS must hold the entire frontier in memory — at depth 10 with branching factor 10, that is 1010 nodes = ~450 GB. DFS only holds the current path and its siblings: at most b × m = 10 × 10 = 100 nodes. This makes DFS practical for deep state spaces where BFS would run out of memory.
Consider a binary tree (branching factor b = 2). Goal is node G. DFS dives left first.
| Step | Node Popped | Stack (LIFO — top first) | Action |
|---|---|---|---|
| Init | — | [A] | Push start |
| 1 | A ① | [C, B] | Push children (B pushed last = top) |
| 2 | B ② | [C, E, D] | Expand B; D is top (left child) |
| 3 | D ③ | [C, E, I, H] | Expand D; H is top |
| 4 | H ④ | [C, E, I] | H is leaf — no children → backtrack |
| 5 | I ⑤ | [C, E] | I is leaf — no children → backtrack |
| 6 | E ⑥ | [C] | E is leaf — no children → backtrack |
| 7 | C ⑦ | [G, F] | Expand C; F and G pushed |
| 8 | G ⑧ — GOAL ✓ | [] | Goal test passes — return path A→C→G |
| Property | BFS | DFS | Iterative Deepening (IDDFS) |
|---|---|---|---|
| Data Structure | FIFO Queue | LIFO Stack / Recursion | DFS repeated with depth limit |
| Completeness | ✅ Yes (finite b) | ❌ No (loops/infinite) | ✅ Yes |
| Optimality | ✅ Yes (uniform cost) | ❌ No | ✅ Yes (uniform cost) |
| Time Complexity | O(bd+1) | O(bm) | O(bd) |
| Space Complexity | O(bd+1) — HIGH | O(b·m) — LOW | O(b·d) — LOW |
| Best Use Case | Shallow goal, uniform cost | Deep goal, tight memory | Unknown depth, best practical choice |
Iterative Deepening DFS is the recommended uninformed strategy in practice. It runs DFS with depth limit 0, then 1, then 2, and so on until a solution is found. It combines BFS's completeness and optimality with DFS's O(b·d) space complexity. The cost of re-expanding nodes at each iteration is only a constant factor overhead (about b/(b−1) times DFS).
Uninformed strategies are blind — they have no idea which direction brings them closer to the goal. Given that real problems have enormous state spaces, blindness is expensive. Informed search strategies use a heuristic function h(n) — a problem-specific estimate of the cost to reach the goal from node n — to guide the search more efficiently.
The heuristic is the AI technique at work: domain knowledge encoded in a formula, steering the search away from fruitless paths. The most important informed algorithm — the one you must know for the exam — is A* (A-star), which combines actual cost incurred with an optimistic estimate of remaining cost.
A heuristic function h(n) estimates the cost of the cheapest path from node n to a goal state. It encodes domain knowledge cheaply: computing h(n) should be much faster than solving the problem from scratch.
Admissibility: h(n) ≤ h*(n) for all n, where h*(n) is the true optimal cost. An admissible heuristic never overestimates. This is required for A* optimality.
Consistency (Monotonicity): For every node n and successor n' via action a: h(n) ≤ c(n, a, n') + h(n'). Consistency implies admissibility.
| Heuristic | h₁: Misplaced Tiles | h₂: Manhattan Distance |
|---|---|---|
| Definition | Count of tiles not in their goal position | Sum of |row + col distances| each tile is from its goal |
| Formula | h₁ = Σ [tile_i ≠ goal_i] | h₂ = Σ (|r_i − r̂_i| + |c_i − ĉ_i|) |
| Admissible? | ✅ Yes — each misplaced tile requires ≥ 1 move | ✅ Yes — each tile needs at least that many moves (slides only) |
| Which is better? | Weaker (lower estimate) | Stronger (higher, tighter estimate) |
| Dominance | h₂ dominates h₁: h₂(n) ≥ h₁(n) for all n. A stronger (higher) admissible heuristic expands fewer nodes. | |
For the state [[7,2,4],[5,_,6],[8,3,1]] with goal [[1,2,3],[4,5,6],[7,8,_]]:
| Tile | Current Position | Goal Position | Misplaced? | Manhattan Distance |
|---|---|---|---|---|
| 1 | (2,2) | (0,0) | ✗ Yes | |2−0|+|2−0| = 4 |
| 2 | (0,1) | (0,1) | ✓ No | 0 |
| 3 | (2,1) | (0,2) | ✗ Yes | |2−0|+|1−2| = 3 |
| 4 | (0,2) | (1,0) | ✗ Yes | |0−1|+|2−0| = 3 |
| 5 | (1,0) | (1,1) | ✗ Yes | 1 |
| 6 | (1,2) | (1,2) | ✓ No | 0 |
| 7 | (0,0) | (2,0) | ✗ Yes | 2 |
| 8 | (2,0) | (2,1) | ✗ Yes | 1 |
| Total | — | h₁ = 6 | h₂ = 14 | |
h₂ = 14 gives a much tighter lower bound than h₁ = 6, so A* using h₂ will explore far fewer nodes before finding the optimal solution.
Greedy Best-First Search expands the node that appears closest to the goal by choosing the node with the smallest h(n). It uses a priority queue ordered by h(n) only — ignoring how much it has already cost to reach the node.
Greedy search is fast in practice but unreliable. It can be misled by a heuristic into a poor path. Example: using straight-line distance heuristic, going to Fagaras first looks good for reaching Bucharest — but A* discovers a shorter total path via RimnicuVilcea.
A* combines the actual cost from the start to a node g(n) with the estimated cost to the goal h(n). It expands the node minimising the evaluation function:
Find the shortest path from Arad to Bucharest. We use the straight-line distance to Bucharest as the admissible heuristic h(n). Road distances give g(n).
| City | h(n) = SLD to Bucharest (km) |
|---|---|
| Arad | 366 |
| Zerind | 374 |
| Sibiu | 253 |
| Timisoara | 329 |
| Rimnicu Vilcea | 193 |
| Fagaras | 178 |
| Pitesti | 98 |
| Bucharest (Goal) | 0 |
| Step | Node Expanded | g(n) | h(n) | f(n)=g+h | Best Frontier f-values |
|---|---|---|---|---|---|
| 1 | Arad | 0 | 366 | 366 | Zerind:449, Sibiu:393, Timisoara:447 |
| 2 | Sibiu (f=393) | 140 | 253 | 393 | RimnicuVilcea:413, Fagaras:415, ... |
| 3 | RimnicuVilcea (f=413) | 220 | 193 | 413 | Pitesti:417, Fagaras:415, ... |
| 4 | Fagaras (f=415) | 239 | 178 | 415 (wait!) | Pitesti:417, Bucharest:450 via Fagaras, ... |
| 5 | Pitesti (f=417) | 317 | 98 | 417 | Bucharest:418 via Pitesti!, ... |
| 6 | Bucharest (f=418) ✓ | 418 | 0 | 418 | GOAL — optimal cost = 418 km |
The optimal path is Arad (0) → Sibiu (140) → RimnicuVilcea (220) → Pitesti (317) → Bucharest (418 km). Crucially, A* did NOT go through Fagaras (which looks closer to Bucharest on the heuristic) because Fagaras→Bucharest costs 211 km for a total of 450 km — worse than the Pitesti route (418 km).
The reason A* beats Greedy search here: Greedy would choose Fagaras first (h=178 looks best) and find Bucharest at total cost 450 km. A* factors in g(n) — the actual road distance already travelled — so it correctly identifies the Pitesti path as 418 km, which is cheaper. The f(n) = g(n) + h(n) balance is what makes A* optimal.
Everything we have studied so far assumes the agent is alone in its environment — the world does not actively oppose it. But in games like chess, checkers, or Tic-Tac-Toe, there is an opponent who will deliberately try to defeat us. The environment is now adversarial. Single-agent search is replaced by game-tree search.
The key insight is that in a two-player, zero-sum game, maximising our score is equivalent to minimising the opponent's score. This leads directly to the Minimax algorithm — the foundational algorithm for adversarial AI, and the technique that powers everything from classical chess engines to modern game-playing neural networks (which use a learned version of the same principle).
A two-player zero-sum game is defined by:
MAX wants to maximise UTILITY; MIN wants to minimise it. The players alternate turns.
Base Case: If the current state s is a terminal state, return UTILITY(s).
MAX's turn: If PLAYER(s) = MAX, return the maximum over all successors: max_a MINIMAX(RESULT(s, a)). MAX chooses the move with the highest minimax value.
MIN's turn: If PLAYER(s) = MIN, return the minimum over all successors: min_a MINIMAX(RESULT(s, a)). MIN chooses the move with the lowest minimax value.
Optimal move: The move MAX should make from the root is argmax_a MINIMAX(RESULT(s₀, a)).
Consider a near-terminal Tic-Tac-Toe position: X's turn to move. We trace minimax for 3 levels (3 plies = MAX, MIN, MAX).
After X plays at position (0,1), O has a winning move (two O's in a row — play to complete). O will always take a win. So MIN correctly returns −1 for that branch. X must not play at (0,1) since it lets O win.
Minimax is correct but slow: it evaluates every node of the game tree. For chess (branching factor ~35, depth ~80), this is astronomically expensive. Alpha-Beta Pruning cuts branches that cannot possibly affect the final minimax value — achieving the same result as minimax but exploring far fewer nodes.
α (alpha) = the best value MAX has found so far (starts at −∞).
β (beta) = the best value MIN has found so far (starts at +∞).
A branch is pruned when: at a MIN node, the value found is ≤ α (MAX already has something better); or at a MAX node, the value found is ≥ β (MIN already has something better). The result is identical to minimax — no quality is lost.
| Feature | Minimax | Alpha-Beta Pruning |
|---|---|---|
| Correctness | ✅ Finds optimal move | ✅ Identical result to Minimax |
| Time (worst) | O(bd) | O(bd) — no improvement |
| Time (best) | O(bd) | O(bd/2) — squares root of tree! |
| Space | O(bd) | O(bd) — same |
| Move ordering | Not needed | Critical — better ordering = more pruning |
| Practical impact | Chess: b=35, d=8 → 35⁸ ≈ 2.25×10¹² | Alpha-beta: 35⁴ ≈ 1.5 million — 1.5 million vs 2.25 trillion! |
Alpha-beta's best-case O(bd/2) assumes the best moves are examined first. In practice, AI chess and Go engines spend enormous effort on move ordering heuristics — trying killer moves, captures, and history heuristics first — so that alpha-beta can prune as much as possible. AlphaZero uses a neural network to order moves, achieving near-optimal pruning on Go's b=250 branching factor.
This section consolidates every definition, formula, diagram, and comparison from Unit I into a compact revision reference. Work through each sub-section carefully. If you can answer the challenge quiz at the end without hesitation, you are ready for the exam.
| Concept | Definition / Formula | Key Detail |
|---|---|---|
| AI (Rational Agent def.) | System that acts to maximise expected performance | Most widely adopted definition (Russell & Norvig) |
| AI Technique | Knowledge-based method to navigate solution space | Must be generalisable, modifiable, usable with incomplete info |
| Agent | Entity with sensors (percepts) + actuators (actions) | Agent function: f: P* → A |
| PEAS | Performance, Environment, Actuators, Sensors | Used to specify any task environment |
| Rationality ≠ Omniscience | Rational = best decision with current knowledge | Omniscient = knows actual outcomes (impossible) |
| Utility Function | EU(a|e) = Σ P(RESULT(s,a)|e) × U(RESULT(s,a)) | Used by utility-based agents to choose actions |
| Problem Formulation | Initial state, Actions, Transition model, Goal test, Path cost | 5 components — memorise all five |
| Production System | IF–THEN rules + Working Memory + Control System | Match → Conflict resolution → Act → Goal check |
| Minimax | Max player picks max; Min player picks min at each level | Terminal: +1 win, 0 draw, −1 loss; Tic-Tac-Toe: always draw with perfect play |
| Admissible Heuristic | h(n) ≤ h*(n) always | Never overestimates; guarantees A* optimality |
| Agent Type | Memory | Goal | Utility | Learning | Example |
|---|---|---|---|---|---|
| Simple Reflex | ❌ None | ❌ None | ❌ None | ❌ None | Thermostat |
| Model-based Reflex | ✅ State model | ❌ None | ❌ None | ❌ None | Robot with map |
| Goal-based | ✅ State model | ✅ Goal state | ❌ None | ❌ None | GPS navigator |
| Utility-based | ✅ State model | ✅ Goal state | ✅ Utility fn. | ❌ None | Self-driving car |
| Learning Agent | ✅ State model | ✅ Goal state | ✅ Utility fn. | ✅ Yes | AlphaGo, GPT |
| Environment Dimension | Easier End | Harder End | Why it Matters |
|---|---|---|---|
| Observability | Fully observable | Partially / Non-observable | Partial obs. → agent must maintain internal state estimate |
| Agents | Single agent | Multi-agent (adversarial) | Multi-agent → need game theory, adversarial search |
| Determinism | Deterministic | Stochastic | Stochastic → need probability, expected utility |
| Episodicity | Episodic | Sequential | Sequential → current action affects future choices |
| Dynamics | Static | Dynamic | Dynamic → agent must act under time pressure |
| Continuity | Discrete | Continuous | Continuous → infinite state space; needs calculus-based methods |
Mistake 1: Confusing "rational" with "omniscient" — rational means best decision given current knowledge, NOT knowing the true future outcome.
Mistake 2: Saying Tic-Tac-Toe can be won by optimal AI — with perfect play from both sides, Tic-Tac-Toe is always a draw (provable by minimax).
Mistake 3: Confusing the Critic and the Learning Element in a learning agent — the Critic evaluates, the Learning Element modifies the performance element.
Mistake 4: Listing only 4 PEAS components without explaining each one for the specific agent asked — examiners expect the full table for the named agent.
Mistake 5: Calling DFS "complete" — it is NOT complete in infinite or cyclic state spaces. Only BFS (or iterative deepening DFS) is complete.
| Question Pattern | Required Approach | Key Terms to Include |
|---|---|---|
| "Define Artificial Intelligence" | Give all 4 definitions (2×2 grid); state which Russell & Norvig prefer | Rational agent, Turing Test, laws of thought, cognitive modelling |
| "Give PEAS for [Agent X]" | Draw 5-column table: agent, performance, environment, actuators, sensors | Specific performance metrics (not vague like "do well") |
| "Describe environment properties" | List all 6–7 dimensions; classify a given problem for each | Fully/partially observable, deterministic/stochastic, etc. |
| "Explain production system" | Give 3 components + 4-step execution cycle | Working memory, conflict set, conflict resolution, firing |
| "Define state space, formulate problem" | Give all 5 problem components; draw state space graph | Initial state, actions, transition model, goal test, path cost |
| "What are issues in search program design?" | Completeness, optimality, time/space complexity, heuristics, branching factor | Combinatorial explosion, admissible heuristic |