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

Used in Vacuum-cleaner agentTask environments

An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment through actuators.

The vacuum world

PartWrittenSlide
SquaresA, B Lecture reference: Rational Agents · slide 3
Percept[location, status], e.g. [A, Dirty] Lecture reference: Rational Agents · slide 3
ActionsLeft, Right, Suck, NoOp Lecture reference: Rational Agents · slide 3
Search actionsLeft, 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
The reflex agent program Lecture reference: Rational Agents · slide 3
PerceptAction
[A, Clean]Right
[A, Dirty]Suck
[B, Clean]Left
[B, Dirty]Suck
What the program returns

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
Open the vacuum agent in A DD

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:

MeasurePoints
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

PartWhat it is
PPerformance measureA function the agent is maximizing (or minimizing)
EEnvironmentA formal representation for world states
AActuatorsActions that change the state according to a transition model
SSensorsObservations 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.

DimensionValuesSlide
ObservableFully / Partially Lecture reference: Rational Agents · slide 10
DeterministicDeterministic / Stochastic / Strategic Lecture reference: Rational Agents · slide 11
EpisodicEpisodic / Sequential Lecture reference: Rational Agents · slide 12
StaticStatic / Dynamic / Semidynamic Lecture reference: Rational Agents · slide 13
DiscreteDiscrete / Continuous Lecture reference: Rational Agents · slide 14
Single agentSingle / Multi Lecture reference: Rational Agents · slide 15
KnownKnown / 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

Used in State spacesTree and graph search

A search problem has five components:

ComponentMeaningRomania (slide 6)
Initial stateThe state the agent starts inArad
ActionsWhat the agent can doGo from one city to another
Transition modelThe state that results from performing a given action in a given state, called its successorIf you go from city A to city B, you end up in city B
Goal stateThe state to reachBucharest
Path costAssumed to be a sum of nonnegative step costsSum of edge costs (total distance traveled)
TermMeaningSlide
State spaceThe 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 functionGiven 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
FrontierThe 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
ExpandGenerate the children of a node by applying the successor function to its state. Lecture reference: Solving Problems by Searching · slide 13
Search treeA “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. stateA 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 searchThe algorithm outline below, with no repeated-state handling: the same state can be expanded again. Lecture reference: Solving Problems by Searching · slide 28
Explored setThe 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 searchTree 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 costEach 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 solutionThe sequence of actions that reaches the goal with the lowest path cost. Lecture reference: Solving Problems by Searching · slide 5
Search strategyDefined 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
Tree Search Algorithm Outline Lecture reference: Solving Problems by Searching · slide 28
  • 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
Graph search adds, to handle repeated states Lecture reference: Solving Problems by Searching · slide 36

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

Used in Comparing search strategiesHeuristics

SymbolMeaningSlide
bMaximum branching factor of the search tree Lecture reference: Uninformed Search · slide 30
dDepth of the optimal solution Lecture reference: Uninformed Search · slide 30
mMaximum 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
nA 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

PropertyConditionMeaningSlide
Admissibleh(n) ≤ h*(n) for every node nNever overestimates the cost to reach the goal. With it, A* tree search is optimal. Lecture reference: Informed Search · slide 25
Consistenth(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
Dominanceh2(n) ≥ h1(n) for all nWith both admissible, h2 dominates h1, and A* with h1 expands more nodes. Lecture reference: Informed Search · slide 35
Combiningh(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:

WrittenWhere it appearsSlides
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

Used in Comparing search strategiesTree and graph search

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:

StrategyFrontierExpands
Breadth-first search BFSFIFO queueExpand shallowest unexpanded node Lecture reference: Uninformed Search · slide 3
Depth-first search DFSLIFO queueExpand deepest unexpanded node Lecture reference: Uninformed Search · slide 5
Depth-limited search DLSLIFO queueDFS that does not expand nodes at the depth limit Lecture reference: Uninformed Search · slide 33
Iterative deepening search IDSLIFO queueDLS with depth limits 0, 1, 2, … until a solution is found Lecture reference: Uninformed Search · slide 33
Uniform-cost search UCSPriority queue ordered by g(n)Expand the frontier node with the lowest path cost Lecture reference: Uninformed Search · slide 40
Greedy best-first search GreedyPriority 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

AlgorithmComplete?Optimal?TimeSpace
BFSYesIf all step costs are equalO(bᵈ)O(bᵈ)
DFSNoNoO(bᵐ)O(bm)
IDSYesIf all step costs are equalO(bᵈ)O(bd)
UCSYesYesNumber of nodes with g(n) ≤ C*Number of nodes with g(n) ≤ C*
GreedyNoNoWorst case: O(bᵐ); best case: O(bd)Worst case: O(bᵐ); best case: O(bd)
A*YesYes (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

Used in Tree and graph searchState spaces

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:

StrategyWrittenReads
Uniform-cost search140g(n)
Greedy best-first search253h(n)
A* search393=140+253f(n)=g(n)+h(n)
Weighted A* search646=140+2·253f(n)=g(n)+α·h(n)
BFS, DFS, DLS, IDSnothing

In a tool

Open in the search 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).

Arad366=0+366Sibiu393=140+253Timisoara447=118+329Zerind449=75+374Arad646=280+366Fagaras415=239+176Oradea671=291+380Rimnicu Vilcea413=220+193Craiova526=366+160Pitesti417=317+100Sibiu553=300+253Bucharest450=450+0Sibiu591=338+253Bucharest418=418+0Craiova615=455+160Rimnicu Vilcea607=414+193
  • On the frontier
  • Expanded
  • Goal state
  • Solution path
  • On the frontier
  • Expanded (explored)
  • Goal state
  • Solution path
  • h(n) estimate

Frontier

10 nodes Priority queue ordered by f(n) = g(n) + h(n)
  1. Timisoara 447=118+329
  2. Zerind 449=75+374
  3. Bucharest 450=450+0
  4. Craiova 526=366+160
  5. Sibiu 553=300+253
  6. Sibiu 591=338+253
  7. Rimnicu Vilcea 607=414+193
  8. Craiova 615=455+160
  9. Arad 646=280+366
  10. 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 happensSentenceSearch
Start
The frontier starts with the rootInitialize the frontier with Arad.A* tree search on Romania, step 1
An IDS iteration startsStart 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 priorityTake 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 successorsTake 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 offTake 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 limitThe 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 limitThe 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 frontierTake 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 outThe 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

Used in Tree and graph searchComparing search strategies

Where the slides leave a choice open, every tool makes the same one. With these choices the tools reproduce the traces on the slides:

TraceProducedOn the slide
BFS expansion order BFS tree search on the tiny search problemS,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) Lecture reference: Uninformed Search · slide 4 Matches
DFS expansion order DFS tree search on the tiny search problemS,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) Lecture reference: Uninformed Search · slide 6 Matches The slide leaves out the root S.
UCS expansion order UCS tree search on the tiny search problemS,p,d,b,e,a,r,f,e,G(S,p,d,b,e,a,r,f,e,G) Lecture reference: Uninformed Search · slide 41 Matches
IDS, one iteration per limit IDS on the binary treeA | ABC | ABDECFG | ABDHIEJKCFLMA | ABC | ABDECFG | ABDHIEJKCFLM Lecture reference: Uninformed Search · slides 34–37 Matches
Children of Arad A* tree search on RomaniaSibiu, Timisoara, ZerindSibiu, Timisoara, Zerind Lecture reference: Solving Problems by Searching · slide 30 Matches
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.

Tools that take a typed graph read this format: one directive or edge per line. Directives are case-insensitive.

LineMeaning
undirectedThe graph is undirected. Without a direction line it is undirected unless some edge uses ->.
directedThe graph is directed.
start: AradThe start state (exactly one).
goal: BucharestGoal states; several as goal: G1, G2 (goals: works too).
Arad - Sibiu 140An edge both ways with its step cost (default 1); -- works too. In a directed graph it adds both directions.
S -> d 3A directed edge (→ works too). The graph becomes directed; an error if it is declared undirected.
Arad Sibiu 140No arrow: an edge in the graph’s direction.
Arad - Sibiu: 140The cost may follow a colon.
h: Arad=366, Sibiu=253Heuristic values; several h: lines are allowed. States without a value have h = 0.
at: Arad 26 233A drawing position (optional; y grows downward).
node: LonelyStates with no edges (a list; nodes: works too). Also fixes the order of the states.
# commentEverything after # on a line is ignored.
# h: Straight-line distanceOn 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
The tiny search problem Lecture reference: Uninformed Search · slide 3 Open in the search tool
The same text, drawn. Without 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
A graph with a heuristic: A* gone wrong Lecture reference: Informed Search · slide 27

Messages

Problems in the text are reported with the line they are on. For example:

LineMessage
strat: Aerror Unknown directive "strat:". Expected start:, goal:, h:, at:, node:, directed, or undirected.
A - B -3error Negative cost -3. Step costs must be ≥ 0.
Rimnicu Vilcea - B 5error Unexpected "-" after the edge. Names with spaces need quotes, like "Rimnicu Vilcea".
A -> B 5error "->" makes a directed edge, but the graph is declared undirected. Use "-" or remove "undirected".
h: A=-1error h(A) = -1 is negative. Heuristic values must be ≥ 0.
h: C=2warning h is given for C, which is not a state of the graph; ignored.
A - B 7warning Edge A - B is already listed on line 3; this line replaces it.
B - B 1info Self-loop on B: this edge leads back to the same state.
start: Aerror No goal state. Add a line like "goal: G".

8-puzzle

  • Lecture reference: Solving Problems by Searching · slide 10
  • Lecture reference: Informed Search · slides 32–37

Used in 8-puzzle

Start state
Goal state
WhereWritten
Text, row by row7 2 4 / 5 _ 6 / 8 3 1 (_ is the blank)
Links724506831: nine digits, 0 for the blank
Typing a boardTiles 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
h1(start) = 8
h2(start) = 3+1+2+2+2+3+3+2 = 18

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:

4-connected: step cost 1
8-connected: diagonals cost √2 ≈ 1.41
No cutting corners: a wall blocks both diagonals past it

Heuristics for a cell dx columns and dy rows from the goal, with values for dx = 3, dy = 2:

HeuristicFormulaExampleAdmissible
Manhattan|dx| + |dy|54-connected only
Euclidean√(dx² + dy²)3.61Yes
Octilemax(|dx|, |dy|) + (√2 − 1)·min(|dx|, |dy|)3.83Yes
Chebyshevmax(|dx|, |dy|)3Yes
Zero00Yes

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.

DeckIdCoversSlides
Introduction to AIintroChapter 127
Rational AgentsagentsChapter 221
Solving Problems by SearchingsearchChapter 344
Uninformed SearchuninformedSection 3.446
Informed SearchinformedSections 3.5–3.644

The lectures page lists each deck with the tools that cite it.