Notation
The terms, symbols, and drawing conventions of the tools, and the choices they make where the slides leave one open. Each section cites the slides it follows.
On this page
Rational agents
- Lecture reference: Rational Agents · slides 2–6
- Lecture reference: Rational Agents · slides 9–17
An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment through actuators.
The vacuum world
| Part | Written | Slide |
|---|---|---|
| Squares | A, B | Lecture reference: Rational Agents · slide 3 |
| Percept | [location, status], e.g. [A, Dirty] | Lecture reference: Rational Agents · slide 3 |
| Actions | Left, Right, Suck, NoOp | Lecture reference: Rational Agents · slide 3 |
| Search actions | Left, Right, Suck; the tools give each a step cost of 1 | Lecture reference: Solving Problems by Searching · slide 8 |
function Vacuum-Agent([location, status]) returns an action
if status = Dirty then return Suck
else if location = A then return Right
else if location = B then return Left | Percept | Action |
|---|---|
| [A, Clean] | Right |
| [A, Dirty] | Suck |
| [B, Clean] | Left |
| [B, Dirty] | Suck |
State names
A state is named by the agent’s square, a space, and C (clean) or D (dirty) for each square from left to right: A DD has the agent in A and both squares dirty, as pictured on slide 3. The state-space graph of slide 9, in its order:
- A DD
- B DD
- A CD
- B CD
- A DC
- B DC
- A CC
- B CC
How many possible states? What if there are n possible locations? Lecture reference: Solving Problems by Searching · slide 8
Show answer
Performance measures
A performance measure (utility function) is an objective criterion for success of an agent’s behavior. Whether the reflex agent is rational depends on the performance measure and the environment. The vacuum tool scores the world after each time step with one of these:
| Measure | Points |
|---|---|
| Clean squares | +1 per clean square after each time step |
| Clean squares, −1 per move | +1 per clean square after each time step, −1 for each Left or Right |
A rational agent selects, for each possible percept sequence, an action that is expected to maximize its performance measure, given the evidence provided by the percept sequence and its built-in knowledge. The expected utility of an action:
EU(action) = Σoutcomes P(outcome | action) U(outcome)
PEAS
| Part | What it is |
|---|---|
| PPerformance measure | A function the agent is maximizing (or minimizing) |
| EEnvironment | A formal representation for world states |
| AActuators | Actions that change the state according to a transition model |
| SSensors | Observations that allow the agent to infer the world state |
Environment types
Seven dimensions, in the order of the slides. The table of slide 17, and the environments tool, write the short values.
| Dimension | Values | Slide |
|---|---|---|
| Observable | Fully / Partially | Lecture reference: Rational Agents · slide 10 |
| Deterministic | Deterministic / Stochastic / Strategic | Lecture reference: Rational Agents · slide 11 |
| Episodic | Episodic / Sequential | Lecture reference: Rational Agents · slide 12 |
| Static | Static / Dynamic / Semidynamic | Lecture reference: Rational Agents · slide 13 |
| Discrete | Discrete / Continuous | Lecture reference: Rational Agents · slide 14 |
| Single agent | Single / Multi | Lecture reference: Rational Agents · slide 15 |
| Known | Known / Unknown | Lecture reference: Rational Agents · slide 16 |
Strategic and Semidynamic are the values the review slide adds in parentheses Lecture reference: Rational Agents · slide 20
Search problems
- Lecture reference: Solving Problems by Searching · slides 5–14
- Lecture reference: Solving Problems by Searching · slides 27–43
A search problem has five components:
| Component | Meaning | Romania (slide 6) |
|---|---|---|
| Initial state | The state the agent starts in | Arad |
| Actions | What the agent can do | Go from one city to another |
| Transition model | The state that results from performing a given action in a given state, called its successor | If you go from city A to city B, you end up in city B |
| Goal state | The state to reach | Bucharest |
| Path cost | Assumed to be a sum of nonnegative step costs | Sum of edge costs (total distance traveled) |
| Term | Meaning | Slide |
|---|---|---|
| State space | The set of all states reachable from the initial state by any sequence of actions: a directed graph whose nodes are states and whose links are actions. | Lecture reference: Solving Problems by Searching · slide 7 |
| Successor function | Given a state, applies all applicable actions and lists the resulting (successor) states. It captures the transition model without a full representation of the state space. | Lecture reference: Solving Problems by Searching · slide 14 |
| Frontier | The list of unexpanded nodes; the strategy picks the next one to take off. Always called the frontier here. | Lecture reference: Solving Problems by Searching · slide 13 |
| Expand | Generate the children of a node by applying the successor function to its state. | Lecture reference: Solving Problems by Searching · slide 13 |
| Search tree | A “what if” tree of action sequences. The root node corresponds to the starting state, a node’s children come from the successor function, and a path is a sequence of actions. A solution is a path ending in the goal state. | Lecture reference: Solving Problems by Searching · slide 27 |
| Node vs. state | A state is a representation of the world; a node is a data structure in the search tree that keeps a pointer to its parent and its path cost. One state can appear in many nodes. | Lecture reference: Solving Problems by Searching · slide 27 |
| Tree search | The algorithm outline below, with no repeated-state handling: the same state can be expanded again. | Lecture reference: Solving Problems by Searching · slide 28 |
| Explored set | The states already expanded. Graph search adds a node’s state when it expands the node and does not put explored states on the frontier again. | Lecture reference: Solving Problems by Searching · slide 36 |
| Graph search | Tree search plus the explored set and the frontier check of “Handling repeated states”. The slides show it as “Search without repeated states”. | Lecture reference: Solving Problems by Searching · slides 36–43 |
| Step cost, path cost | Each action has a nonnegative step cost; the path cost g(n) of a node is the sum of the step costs from the initial state. | Lecture reference: Solving Problems by Searching · slide 5 |
| Optimal solution | The sequence of actions that reaches the goal with the lowest path cost. | Lecture reference: Solving Problems by Searching · slide 5 |
| Search strategy | Defined by the order of node expansion. Uninformed strategies use only the problem definition; informed strategies also use a heuristic function h(n). | Lecture reference: Uninformed Search · slide 2 |
- Initialize the frontier using the starting state
- While the frontier is not empty
- Choose a frontier node according to search strategy and take it off the frontier
- If the node contains the goal state, return solution
- Else expand the node by applying the successor function and add its children to the frontier
- Every time you expand a node, add that state to the explored set; do not put explored states on the frontier again
- Every time you add a node to the frontier, check whether it already exists in the frontier with a higher path cost, and if yes, replace that node with the new one
What is the state space for the Romania problem? Lecture reference: Solving Problems by Searching · slide 7
Show answer
Symbols
- Lecture reference: Uninformed Search · slide 30
- Lecture reference: Uninformed Search · slide 45
- Lecture reference: Informed Search · slide 5
- Lecture reference: Informed Search · slide 16
- Lecture reference: Informed Search · slide 25
| Symbol | Meaning | Slide |
|---|---|---|
| b | Maximum branching factor of the search tree | Lecture reference: Uninformed Search · slide 30 |
| d | Depth of the optimal solution | Lecture reference: Uninformed Search · slide 30 |
| m | Maximum length of any path in the state space (may be infinite) | Lecture reference: Uninformed Search · slide 30 |
| C* | Cost of the optimal solution | Lecture reference: Uninformed Search · slide 45 |
| ε | A positive constant that every step cost is greater than (UCS is complete then) | Lecture reference: Uninformed Search · slide 44 |
| n | A node of the search tree | Lecture reference: Informed Search · slide 5 |
| g(n) | Cost of the path from the start state to node n: the path cost, or cost so far | Lecture reference: Informed Search · slide 16 |
| h(n) | Heuristic function: estimated cost of reaching the goal from node n | Lecture reference: Informed Search · slide 5 |
| h*(n) | True cost to reach the goal state from n | Lecture reference: Informed Search · slide 25 |
| f(n) = g(n) + h(n) | A* evaluation function: estimated total cost of the path through n to the goal | Lecture reference: Informed Search · slide 16 |
| α | Weighted A* inflation factor, α > 1: the frontier is ordered by g(n) + α·h(n); with an admissible h, the solution costs at most α·C* (default α = 2) | Lecture reference: Informed Search · slide 38 |
| h1(n), h2(n) | 8-puzzle heuristics: number of misplaced tiles, total Manhattan distance | Lecture reference: Informed Search · slide 32 |
| c(n, n′) | Step cost of the action from n to its successor n′ (the slides write cost(A to C)) | Lecture reference: Informed Search · slide 28 |
Heuristics
| Property | Condition | Meaning | Slide |
|---|---|---|---|
| Admissible | h(n) ≤ h*(n) for every node n | Never overestimates the cost to reach the goal. With it, A* tree search is optimal. | Lecture reference: Informed Search · slide 25 |
| Consistent | h(n) ≤ c(n, n′) + h(n′) for every action from n to n′ | Slide form: cost(A to C) + h(C) ≥ h(A). Implies admissibility; with it, A* graph search is optimal. | Lecture reference: Informed Search · slide 28 |
| Dominance | h2(n) ≥ h1(n) for all n | With both admissible, h2 dominates h1, and A* with h1 expands more nodes. | Lecture reference: Informed Search · slide 35 |
| Combining | h(n) = max{h1(n), h2(n), …, hm(n)} | The maximum of admissible heuristics is admissible. | Lecture reference: Informed Search · slide 37 |
Complexity
Time is the number of nodes generated, space the largest number of nodes in memory, both in terms of b, d, m, and C*. Exponents are superscripts:
| Written | Where it appears | Slides |
|---|---|---|
| O(bd) | Nodes in a b-ary tree of depth d: time and space of BFS, time of IDS | Lecture reference: Uninformed Search · slide 31 Lecture reference: Uninformed Search · slide 38 |
| O(bm) | Time of DFS; worst-case time and space of greedy best-first search | Lecture reference: Uninformed Search · slide 32 Lecture reference: Informed Search · slide 14 |
| O(bd) | b times d, linear: space of IDS; best-case time and space of greedy | Lecture reference: Uninformed Search · slide 38 Lecture reference: Informed Search · slide 42 |
| O(bm) | b times m, linear: space of DFS | Lecture reference: Uninformed Search · slide 32 |
| O(bC*/ε) | Time and space of UCS: nodes with path cost ≤ C*. Can exceed O(bᵈ) when there are many small steps. | Lecture reference: Uninformed Search · slide 44 |
In plain text, such as the properties table below, the UCS bound is written O(b^(C*/ε)).
Search strategies
- Lecture reference: Uninformed Search · slide 45
- Lecture reference: Informed Search · slide 42
A strategy is defined by the order of node expansion, which is the order its frontier gives nodes back. Names and short forms as the tools write them:
| Strategy | Frontier | Expands |
|---|---|---|
| Breadth-first search BFS | FIFO queue | Expand shallowest unexpanded node Lecture reference: Uninformed Search · slide 3 |
| Depth-first search DFS | LIFO queue | Expand deepest unexpanded node Lecture reference: Uninformed Search · slide 5 |
| Depth-limited search DLS | LIFO queue | DFS that does not expand nodes at the depth limit Lecture reference: Uninformed Search · slide 33 |
| Iterative deepening search IDS | LIFO queue | DLS with depth limits 0, 1, 2, … until a solution is found Lecture reference: Uninformed Search · slide 33 |
| Uniform-cost search UCS | Priority queue ordered by g(n) | Expand the frontier node with the lowest path cost Lecture reference: Uninformed Search · slide 40 |
| Greedy best-first search Greedy | Priority queue ordered by h(n) | Expand the node that has the lowest value of the heuristic function h(n) Lecture reference: Informed Search · slide 7 |
| A* search A* | Priority queue ordered by f(n) = g(n) + h(n) | Expand the node with the lowest f(n) = g(n) + h(n) Lecture reference: Informed Search · slide 16 |
| Weighted A* search Weighted A* | Priority queue ordered by g(n) + α·h(n) | A* with an admissible heuristic inflated by α > 1 Lecture reference: Informed Search · slide 38 |
DLS is the depth-limited DFS that IDS runs once per limit. Weighted A* orders the frontier by g(n) + α·h(n) with α = 2 unless set otherwise.
Properties
| Algorithm | Complete? | Optimal? | Time | Space |
|---|---|---|---|---|
| BFS | Yes | If all step costs are equal | O(bᵈ) | O(bᵈ) |
| DFS | No | No | O(bᵐ) | O(bm) |
| IDS | Yes | If all step costs are equal | O(bᵈ) | O(bd) |
| UCS | Yes | Yes | Number of nodes with g(n) ≤ C* | Number of nodes with g(n) ≤ C* |
| Greedy | No | No | Worst case: O(bᵐ); best case: O(bd) | Worst case: O(bᵐ); best case: O(bd) |
| A* | Yes | Yes (if heuristic is admissible) | Number of nodes with g(n) + h(n) ≤ C* | Number of nodes with g(n) + h(n) ≤ C* |
The time and space of UCS are also written O(bC*/ε) Lecture reference: Uninformed Search · slide 44
Diagram legend
- Lecture reference: Solving Problems by Searching · slide 27
- Lecture reference: Solving Problems by Searching · slide 41
- Lecture reference: Informed Search · slide 22
The state-space graph draws each state once. The search tree draws a node for every path the search generates, so one state can appear many times. Both use the same status colors.
State-space graph
-
State
A circle with the state’s name.
-
State on the Romania map
A small square with the name beside it, as on the slide map.
-
Start state
An arrow in from nowhere, labelled start.
-
Goal state
A double outline.
-
Action, both ways
A line with the step cost (undirected graphs).
-
Action, one way
An arrow to the successor state, with the step cost.
-
h(n) estimate
The heuristic value of a state, written h=366.
-
Being expanded
The state of the node just taken off the frontier.
-
On the frontier
The state of a node waiting on the frontier: a colored outline.
-
Expanded (explored)
Expanded earlier; in graph search, the explored set.
-
Not added (repeated state)
A child generated at this step whose node was not added: a dashed ring.
-
Solution path
At the goal step: the states and actions of the solution.
Statuses are drawn on circles and on the map squares of Romania, where the small markers are filled solid.
Search tree
-
Node
Its state’s name. Children are drawn left to right in successor order.
-
Priority
Under the node: what the strategy orders the frontier by (see below).
-
Being expanded
The node just taken off the frontier, marked with a triangle.
-
On the frontier
Generated and not yet taken off: a colored outline.
-
Expanded
Taken off the frontier and expanded.
-
Goal state
The node that passed the goal test: a double outline.
-
Solution path
The nodes and edges from the root to the goal node.
-
Not added (repeated state)
A child that did not go on the frontier: dashed and crossed out, as the slides cross out repeated states.
-
Cut off at the depth limit
Goal-tested at the depth limit and not expanded.
-
Replaced on the frontier
A frontier node that a cheaper path to the same state replaced.
Under each node
The value the frontier is ordered by, as the slides write it. For Sibiu, reached from Arad at path cost g = 140 with straight-line distance h = 253:
| Strategy | Written | Reads |
|---|---|---|
| Uniform-cost search | 140 | g(n) |
| Greedy best-first search | 253 | h(n) |
| A* search | 393=140+253 | f(n)=g(n)+h(n) |
| Weighted A* search | 646=140+2·253 | f(n)=g(n)+α·h(n) |
| BFS, DFS, DLS, IDS | nothing | |
In a tool
A* tree search on Romania, step 7 of 7: Take Bucharest off the frontier. It contains the goal state: return the solution Arad → Sibiu → Rimnicu Vilcea → Pitesti → Bucharest (cost 418).
Frontier
10 nodes Priority queue ordered by f(n) = g(n) + h(n)- Timisoara 447=118+329
- Zerind 449=75+374
- Bucharest 450=450+0
- Craiova 526=366+160
- Sibiu 553=300+253
- Sibiu 591=338+253
- Rimnicu Vilcea 607=414+193
- Craiova 615=455+160
- Arad 646=280+366
- Oradea 671=291+380
Step descriptions
- Lecture reference: Solving Problems by Searching · slide 28
- Lecture reference: Solving Problems by Searching · slide 36
Used in Tree and graph search
The tools announce every step of a search in one sentence, in the words of the tree search outline. These sentences are produced by the same code, on the lecture graphs:
| What happens | Sentence | Search |
|---|---|---|
| Start | ||
| The frontier starts with the root | Initialize the frontier with Arad. | A* tree search on Romania, step 1 |
| An IDS iteration starts | Start iteration with depth limit 1: initialize the frontier with A. | IDS on the binary tree, step 4 |
| Expansions | ||
| A node is expanded (no priority) | Take S off the frontier. Not a goal; expand it: d, e, p. | BFS tree search on the tiny search problem, step 2 |
| A node is expanded, with its priority | Take Sibiu off the frontier (f = 393). Not a goal; expand it: Arad, Fagaras, Oradea, Rimnicu Vilcea. | A* tree search on Romania, step 3 |
| A node has no successors | Take a off the frontier. Not a goal, and it has no successors. | DFS tree search on the tiny search problem, step 5 |
| Children not added | ||
| Its state is in the explored set (graph search) | Take Zerind off the frontier (g = 75). Not a goal; expand it: Arad, Oradea. Arad is in the explored set; not added. | UCS graph search on Romania, step 3 |
| Its state is on the frontier at a lower path cost (graph search) | Take Sibiu off the frontier (g = 140). Not a goal; expand it: Arad, Fagaras, Oradea, Rimnicu Vilcea. Arad is in the explored set; not added. Oradea is already on the frontier with a lower path cost (146); not added. | UCS graph search on Romania, step 5 |
| A cheaper path replaces the frontier node (graph search) | Take Pitesti off the frontier (g = 317). Not a goal; expand it: Bucharest, Craiova, Rimnicu Vilcea. Bucharest (path cost 418) replaces Bucharest (path cost 450) on the frontier. Craiova is already on the frontier with a lower path cost (366); not added. Rimnicu Vilcea is in the explored set; not added. | UCS graph search on Romania, step 11 |
| Its state is already on the path (path check) | Take Sibiu off the frontier. Not a goal; expand it: Arad, Fagaras, Oradea, Rimnicu Vilcea. Arad is already on this path; not added. | DFS with the path check on Romania, step 3 |
| Depth limits | ||
| A node at the depth limit is cut off | Take B off the frontier. Not a goal. B is at the depth limit 1; not expanded. | IDS on the binary tree, step 6 |
| IDS moves on to the next limit | The frontier is empty and nodes were cut off at the depth limit 1: start again with depth limit 2. | IDS on the binary tree, step 8 |
| DLS finds no solution within its limit | The frontier is empty and nodes were cut off at the depth limit 1: no solution within the limit. | DLS (limit 1) on the binary tree, step 5 |
| End | ||
| The goal node is taken off the frontier | Take Bucharest off the frontier. It contains the goal state: return the solution Arad → Sibiu → Rimnicu Vilcea → Pitesti → Bucharest (cost 418). | A* tree search on Romania, step 7 |
| The goal test passes at generation (option) | G contains the goal state (tested when generated): return the solution S → e → r → f → G (cost 14). | BFS graph search (goal test at generation) on the tiny search problem, step 13 |
| The frontier runs out | The frontier is empty: return failure (no solution). | BFS graph search on the tiny search problem, starting from h, step 5 |
When the search ends, a summary gives the solution and the node counts:
Solution: Arad → Sibiu → Rimnicu Vilcea → Pitesti → Bucharest (cost 418). 6 nodes taken off the frontier, 5 expanded, 16 generated.
Conventions beyond the slides
Where the slides leave a choice open, every tool makes the same one. With these choices the tools reproduce the traces on the slides:
| Trace | Produced | On the slide |
|---|---|---|
| BFS expansion order BFS tree search on the tiny search problem | S,d,e,p,b,c,e,h,r,q,a,a,h,r,p,q,f,p,q,f,q,c,G | (S,d,e,p,b,c,e,h,r,q,a,a, h,r,p,q,f,p,q,f,q,c,G) |
| DFS expansion order DFS tree search on the tiny search problem | S,d,b,a,c,a,e,h,p,q,q,r,f,c,a,G | (d,b,a,c,a,e,h,p,q,q, r,f,c,a,G) The slide leaves out the root S. |
| UCS expansion order UCS tree search on the tiny search problem | S,p,d,b,e,a,r,f,e,G | (S,p,d,b,e,a,r,f,e,G) |
| IDS, one iteration per limit IDS on the binary tree | A | ABC | ABDECFG | ABDHIEJKCFLM | A | ABC | ABDECFG | ABDHIEJKCFLM |
| Children of Arad A* tree search on Romania | Sibiu, Timisoara, Zerind | Sibiu, Timisoara, Zerind |
- Successor order
- Alphabetical by state name (“name order”): case-insensitive, with digit runs compared by value, so q2 comes before q10. Typed-in graphs can switch to “listed”, the order the edges are written in.
- DFS order
- Children are pushed so that the first successor is expanded first.
- Goal test
- When a node is taken off the frontier, as in the tree search outline. An option tests children when they are generated instead; the root is then tested when the frontier is initialized.
- Expansion order
- Lists every node taken off the frontier, including the goal node.
- Ties
- In a priority queue, the node added first comes off first.
- Graph search
- A node’s state enters the explored set when the node is expanded; a child whose state is explored is not added. A child whose state is already on the frontier replaces that frontier node only for UCS, greedy, A*, and weighted A*, and only when its path cost is lower; otherwise it is not added. The replacing node is a new frontier entry, so it takes its place among ties as a new node.
- Path check
- “Avoid repeated states along path”: a child whose state is already on the path from the root to it is not added. Available for every strategy; it makes DFS and IDS complete in finite state spaces. Lecture reference: Uninformed Search · slide 32
- Depth limit
- A node at depth = limit is goal-tested but not expanded: it is cut off, even when it has no children. DLS uses limit 3 unless set otherwise. IDS runs DLS with limits 0, 1, 2, … and stops at the first limit with a solution, when an iteration cuts nothing off (no solution), or at its largest limit (50 unless set otherwise).
- Counts
- Generated counts every node created, including the root and children that were not added. Expanded counts nodes whose successors were generated. The slides’ time is nodes generated; their space is the largest frontier, plus the explored set in graph search.
- Missing h values
- Greedy, A*, and weighted A* use h = 0 for states without a heuristic value.
- Weighted A*
- α = 2 unless set otherwise.
- Run limits
- A run stops at a limit on the nodes taken off the frontier (tools may set it; 10,000 unless set otherwise) or at 200,000 generated nodes; its last step says which limit stopped it.
Graph text format
Used in Tree and graph searchHeuristicsComparing search strategies
Tools that take a typed graph read this format: one directive or edge per line. Directives are case-insensitive.
| Line | Meaning |
|---|---|
| undirected | The graph is undirected. Without a direction line it is undirected unless some edge uses ->. |
| directed | The graph is directed. |
| start: Arad | The start state (exactly one). |
| goal: Bucharest | Goal states; several as goal: G1, G2 (goals: works too). |
| Arad - Sibiu 140 | An edge both ways with its step cost (default 1); -- works too. In a directed graph it adds both directions. |
| S -> d 3 | A directed edge (→ works too). The graph becomes directed; an error if it is declared undirected. |
| Arad Sibiu 140 | No arrow: an edge in the graph’s direction. |
| Arad - Sibiu: 140 | The cost may follow a colon. |
| h: Arad=366, Sibiu=253 | Heuristic values; several h: lines are allowed. States without a value have h = 0. |
| at: Arad 26 233 | A drawing position (optional; y grows downward). |
| node: Lonely | States with no edges (a list; nodes: works too). Also fixes the order of the states. |
| # comment | Everything after # on a line is ignored. |
| # h: Straight-line distance | On the first line: the name of the heuristic. |
| "Rimnicu Vilcea" | Names are words of letters, digits, _, ', and .; any other name, such as one with a space, needs double quotes (escapes \" and \\). |
Costs are numbers ≥ 0, like 5 or 2.5; so are h values. A later line for the same edge replaces the earlier one. A graph has at most 300 states and 3,000 edges.
Examples
directed node: S, a, b, c, d, e node: f, G, h, p, q, r start: S goal: G S -> d 3 S -> e 9 S -> p 1 b -> a 2 c -> a 2 d -> b 1 d -> c 8 d -> e 2 e -> h 8 e -> r 2 f -> c 3 f -> G 2 h -> p 4 h -> q 4 p -> q 15 r -> f 1
at: lines the states are placed
automatically; node: lines keep their order.directed node: S, A, B, C, G start: S goal: G S -> A 1 S -> B 1 A -> C 1 B -> C 2 C -> G 3 h: S=2, A=4, B=1, C=1, G=0
Messages
Problems in the text are reported with the line they are on. For example:
8-puzzle
- Lecture reference: Solving Problems by Searching · slide 10
- Lecture reference: Informed Search · slides 32–37
Used in 8-puzzle
| Where | Written |
|---|---|
| Text, row by row | 7 2 4 / 5 _ 6 / 8 3 1 (_ is the blank) |
| Links | 724506831: nine digits, 0 for the blank |
| Typing a board | Tiles 1–8, the blank as _ or 0; spaces, commas, slashes, line breaks, and brackets between them are ignored. |
- Actions
- Move the blank Left, Right, Up, Down (in successor order); each move costs 1.
- States
- 181,440 states (9!/2) are reachable from any board. A board can be reached from the goal exactly when the parities of their inversions match.
- h1(n)
- The number of misplaced tiles; the blank does not count.
- h2(n)
- The total Manhattan distance: for each tile, the number of squares from its desired location, rows plus columns.
- max(h1(n), h2(n))
- The two combined by taking the larger value Lecture reference: Informed Search · slide 37
The terms of h2 are tiles 1 to 8 in order, as on the slide. Open the slide boards in the 8-puzzle tool
Are h1 and h2 admissible? Lecture reference: Informed Search · slide 32
Show answer
Grid path finding
- Lecture reference: Informed Search · slides 23–24
- Lecture reference: Informed Search · slides 38–40
Used in Path finding on a grid
A cell is written (column, row), counted from (0, 0) at the top left. Walls block; every other cell is a state. The successor function lists neighbors clockwise from Up:
Heuristics for a cell dx columns and dy rows from the goal, with values for dx = 3, dy = 2:
| Heuristic | Formula | Example | Admissible |
|---|---|---|---|
| Manhattan | |dx| + |dy| | 5 | 4-connected only |
| Euclidean | √(dx² + dy²) | 3.61 | Yes |
| Octile | max(|dx|, |dy|) + (√2 − 1)·min(|dx|, |dy|) | 3.83 | Yes |
| Chebyshev | max(|dx|, |dy|) | 3 | Yes |
| Zero | 0 | 0 | Yes |
The default is the exact distance on a grid without walls: Manhattan for 4-connected moves, octile for 8-connected. Weighted A* multiplies h by α; the slides’ example uses 5 × the Euclidean distance.
Slide citations
Presets and sections cite a deck by its title and a slide number: Lecture reference: Uninformed Search · slide 4, or a range: Lecture reference: Rational Agents · slides 6–8.
| Deck | Id | Covers | Slides |
|---|---|---|---|
| Introduction to AI | intro | Chapter 1 | 27 |
| Rational Agents | agents | Chapter 2 | 21 |
| Solving Problems by Searching | search | Chapter 3 | 44 |
| Uninformed Search | uninformed | Section 3.4 | 46 |
| Informed Search | informed | Sections 3.5–3.6 | 44 |
The lectures page lists each deck with the tools that cite it.