Unit 1
Unit 1
1
Introduction
• What is AI?
• The foundations of AI
• A brief history of AI
• The state of the art
• Introductory problems
2
What is AI?
3
What is AI?
5
Acting Humanly: The Turing Test
• The Turing Test is a method of inquiry in artificial intelligence (AI) for determining
whether or not a computer is capable of thinking like a human being. The test is
named after Alan Turing, the founder of the Turing Test
• Turing proposed that a computer can be said to possess artificial intelligence if it can
mimic human responses under specific conditions.
• The original Turing Test requires three terminals, each of which is physically
separated from the other two. One terminal is operated by a computer, while the
other two are operated by humans.
• During the test, one of the humans functions as the questioner, while the second
human and the computer function as respondents. The questioner interrogates the
respondents within a specific subject area, using a specified format and context. After
a preset length of time or number of questions, the questioner is then asked to decide
which respondent was human and which was a computer.
• The test is repeated many times. If the questioner makes the correct determination in
half of the test runs or less, the computer is considered to have artificial intelligence
because the questioner regards it as "just as human" as the human respondent.
Huma
n
AI
Imitation Game
System 6
Human
Acting Humanly: The Turing Test
7
Thinking Humanly: Cognitive Modelling
8
Thinking Rationally: Laws of Thought
• Obstacles:
Informal knowledge representation.
Computational complexity and resources.
9
Acting Rationally
• Advantages:
More general than the “laws of thought”
approach.
More amenable to scientific development than human-
based approaches.
10
The Foundations of AI
11
The Foundations of AI
12
A Brief History of AI
• The gestation of AI (1943 1956):
1943: McCulloch & Pitts: Boolean circuit model of
brain.
1950: Turing’s “Computing Machinery and Intelligence”.
1956: McCarthy’s name “Artificial Intelligence” adopted.
13
A Brief History of AI
14
A Brief History of AI
16
Physical Symbol System
CC$7899ABVV
Symbol
S1 S2 S3 S4 S5 S6 Structures -
“Expressions”
S1 S2 S3 S4 S5 S6
Key Concepts
26
The State of the Art
28
Introductory Problem: Tic-Tac-Toe
X X
o
29
Introductory Problem: Tic-Tac-Toe
Program 1:
Data Structures:
• Board: 9 element vector representing the board, with 1-9 for
each square. An element contains the value 0 if it is blank, 1 if
it is filled by X, or 2 if it is filled with a O
• Movetable: A large vector of 19,683 elements ( 3^9), each
element is 9-element vector.
Algorithm:
1. View the vector as a ternary number. Convert it to a
decimal number.
2. Use the computed number as an index into
Move-Table and access the vector stored there.
3. Set the new board to that vector.
30
Introductory Problem: Tic-Tac-Toe
Comments:
This program is very efficient in time.
3. Difficult to extend.
31
Introductory Problem: Tic-Tac-Toe
1 2 3
4 5 6
7 8 9
32
Introductory Problem: Tic-Tac-Toe
Program 2:
Data Structure: A nine element vector representing the board.
But instead of using 0,1 and 2 in each element, we store 2 for
blank, 3 for X and 5 for O
Functions:
Make2: returns 5 if the center sqaure is blank. Else any other
balnk sq
Posswin(p): Returns 0 if the player p cannot win on his next
move; otherwise it returns the number of the square that
constitutes a winning move. If the product is 18 (3x3x2),
then X can win. If the product is 50 ( 5x5x2) then O can win.
Go(n): Makes a move in the square n
Strategy:
Turn = 1 Go(1)
Turn = 2 If Board[5] is blank, Go(5), else Go(1)
Turn = 3 If Board[9] is blank, Go(9), else Go(3)
Turn = 4 If Posswin(X) 0, then Go(Posswin(X))
.......
33
Introductory Problem: Tic-Tac-Toe
Comments:
3. Hard to generalize.
34
Introductory Problem: Tic-Tac-Toe
8 3 4
1 5 9
6 7 2
15 (8 +
5) 35
Introductory Problem: Tic-Tac-Toe
Comments:
36
Introductory Problem: Tic-Tac-Toe
Program 3:
Comments:
38
Introductory Problem: Question
Answering
“Mary went shopping for a new coat. She found a red
one she really liked. When she got it home, she
discovered that it went perfectly with her favourite
dress”.
39
Introductory Problem: Question
Answering
Program 1:
Z = a new coat
40
Introductory Problem: Question
Answering
Program 2:
Structured representation of sentences:
Event2: Thing1:
instance: Finding instance: Coat
tense: Past colour: Red
agent: Mary
object: Thing 1
41
Introductory Problem: Question
Answering
Program 3:
Background world knowledge:
C finds M
C leaves L C buys M
C leaves L
C takes M
42
To build a system for solving the
problem
• Define the problem precisely
• Analyse the problem
• Isolate and represent the task knowledge
• Choose best problem solving technique
43
State Space Search
• Move from initial state to final state using rules
– Initial state => Start board position
– Rules => Legal moves
– Goal => win state
– Eg. In chess “While pawn_at sqr(a,b) -> move_pawn_from(a,b)
to (c,d)
• State space representation form the basic for AI
technique.
44
A Water Jug Problem
Puzzle-Solving as Search
• You have a 4-gallon and a 3-gallon water jug
• You have a faucet with an unlimited amount of water
• You need to get exactly 2 gallons in 4-gallon jug
3 (x,y) (x – d,y) if x > 0 Pour some water out of the 4-gallon jug
4 (x,y) (x,y – d) if x > 0 Pour some water out of the 3-gallon jug
50
Production system
51
Control Strategy
• It should avoid loops
• It should be systematic
52
Breadth First Search
• Maintain queue of nodes to visit
• Evaluation
– Complete?
Yes a
© Daniel S. Weld 54
Heuristic search
• Technique that improves efficiency of search process
by sacrificing claims of completeness
• Used to solve hard problems
• General domain heuristics: Nearest neighbour
heuristics
• Domain specific heuristic : Select locally superior
alternate at each step.
55
Heuristic Function
56
Problem Characteristics
57
58
Can solution steps be ignored?
• Mathematical theorem proving:
- Start with proving a lemma
- If not useful we ignore it and start with another one
• 8-puzzle :
- We make a wrong move and realize it
- Backtrack and find next alternative move
• Chess:
- We make a move
- Not possible to recover back
• 8-puzzle problem:
– When we make a move we know what will happen
– Possible to plan entire sequence on moves and be
confident on what will be the resulting state
– We can backtrack to earlier moves
• Bridge game:
– We need to plan before first play, but cannot play with
certainty
– Outcome is uncertain
60
61
Is the solution a state or a path?
River Financial
bank institution
62
Role of knowledge
• Chess:
– Knowledge to represent rules for legal moves
– Requires control mechanism for search procedure
• Election survey
– Knowledge is the survey report collected from
various locations(voluminous)
63
Production system
characteristics
• Monotonic: execution of a rule never prevents
the execution of other applicable rules
• Non-monotonic: without this property
• Partially commutative: if application of a
particular sequence of rules transforms state x
into state y, then any permutation of those
rules that are allowable, transforms x into y
• Commutative: monotonic + partially
commutative
64
Problems and production system
monotonic Non-
monotonic
commutative synthesis
65
Problems and production system
monotonic Non-
monotonic
Partially
Ignorable Recoverable
commutative
Non-partially Irrecoverable
Irrecoverable
commutative Unpredictable
66
Sample problems - 8-puzzle
67
Sample problems - 8-puzzle
68
Sample problems - 8 queens
69
Sample problems - 8 queens
70
Sample problems - 8 queens
71
Sample problems -
Cryptarithmetic
72
Sample problems -
Cryptarithmetic
73
Heuristic Search
• Heuristic - a “rule of thumb” used to help guide search
– often, something learned experientially and recalled when
needed
• Heuristic Function - function applied to a state in a search space to
indicate a likelihood of success if that state is selected
– heuristic search methods are known as “weak methods”
because of their generality and because they do not apply a
great deal of knowledge
– the methods themselves are not domain or problem specific,
only the heuristic function is problem specific
• Heuristic Search –
– given a search space, a current state and a goal state
– generate all successor states and evaluate each with our
heuristic function
– select the move that yields the best heuristic value
• Here and in the accompanying notes, we examine various heuristic
search algorithms
– heuristic functions can be generated for a number of problems
like games, but what about a planning or diagnostic situation?
Example Heuristic Function
• Simple heuristic for 8-puzzle:
– add 1 point for each tile in the right location
– subtract 1 point for each tile in the wrong location
• Better heuristic for 8-puzzle
– add 1 point for each tile in the right location
– subtract 1 point for each move to get a tile to the right location
• The first heuristic only takes into account the local tile
position
– it doesn’t consider such factors as groups of tiles in proper
position
– we might differentiate between the two types of heuristics as
local vs global
2 (1) 3(1)
4(-1) 5(-1) 1(-1)
6 (-1) 7(-1) 8(-1)
Example Heuristics: 8 Puzzle
From the start state, which operator do we select (which state do we move
into)? The first two heuristics would recommend the middle choice (in this case,
we want the lowest heuristic value) while the third heuristic tells us nothing
useful (at this point because too much of the puzzle is not yet solved)
Heuristic Search Algorithms
78
Generate and Test
79
Hill Climbing
• Given an initial state perform the following
until you reach a goal state or a dead end
– generate all successor states
– evaluate each state with the heuristic function
– move to the state that is highest
• This algorithm only tries to improve during
each selection, but not find the best solution
• 3 types
– Simple HC
– Steepest Ascent HC
– Simulated Annealing
• In simple hill climbing, generate and evaluate states until you find one with a best value, then immediately move on to it
• (7)
(4) (2)
A
B C D
E F G H
STEEPEST ASCENT HILL CLIMBING
• In steepest ascent hill climbing, generate
all successor states, evaluate them, and
then move to the best value available (as
long as it is better than the current value)
– in both of these, you can get stuck in a local
maxima but not reach a global maxima
A
(7)
B C D
(3) (5) (2)
82
Simulated Annealing
• Another idea is simulated annealing
– the idea is that early in the search, we haven’t invested much yet, so we can
make some downhill moves
• in the 8 puzzle, we have to be willing to “mess up” part of the solution to
move other tiles into better positions
– We use objective function rather than heuristic function
– Valley descending rather than hill climbing
– It is based on process of annealing where physical substances such as metals are
melted and then gradually cooled until solid state is reached.
– Goal: To produce minimal energy final state
– Physical substances move from higher energy configuration to lower ones->
valley descending
– Probability for transition
• P= eE/kT
E - +ve change in energy level
T- Temperature
k- Boltzman constant
-
Annealing schedule: Rate at which the system is cooled
83
Algorithm – Simulated Annealing
1. Evaluate the initial state
if it goal return else continue initial state-> current state
2. Intialize BestSoFar to current state
3. Intialise T according to annealing schedule
4. Loop until solution is found or until there are no new operators left to be applied to
current state
a. Select an operator tat has not yet been applied to current state and apply it to produce new
state
b. Evaluate new state
E = val(current state)-val(new state)
c. If new state -> goal return
d. If not goal but better than current state then add it to BestSoFar
e. If not better than current state eval P= eE/kT
If P > rand(0-1) then down hill move is acceptable
f. Revise T according to annealing Schedule
5. Return BestSoFar
84
Simulated Annealing
(7)
A
B C D
(3) (4) (5)
F G
E
85
• 3 states can be reached from Hill climbing
– Local Maxima:
• A state that is better than all its neighbours but not better than some
other state farther away
A
(5) (4) (2)
B C D
E F
(4)
G
86
• Plateau :
– Flat area in search space in which all neighbouring
states have the same values.
– Not possible to determine the direction to move
B C D
(3) (3) (3)
87
• Ridge
– Special kind of local maxima
– Area in search space that is higher than the surrounding areas and itself, has a
slope
– Orientation of high region compared to set of available moves and directions in
which they move make it impossible to traverse a ridge by a single move
(3) (8)
A
(4)
B - C
-
F
D E
H
G
P(goal) 88
Blocks World Problem
Initial state Goal state
H
A
H Assign 1 if block in G
F Pleatue E
D
E
C
D
- A B
C 1 H A
B 1 G
1 G 1 G
1 F
1 F 1 F
1 E
1 1 E 1 E
D
1 1 D 1 D
C
1 - H 1 C 1 C
B 1
-1 A -1 B 1 A -1 H -1 B
1
89
h(a) =4 h(b)=4 h(c)=4
Blocks World Problem
Initial state Goal state
• Assign –ve value based on H
A no.of wrong blocks above
H G
which it is resides
• Best node with high heuristic F
G
value is chosen E
F
D
E
C
D
- A B
C 7 H A
B -6 G
-5 G -5 G
-5 F
-4 F -4 F
-4 E
-3 -3 E -3 E
D
-2 -2 D -2 D
C
-1 - H -1 C -1 C
B 1
0 A B A H B
90
h(a) =-28 h(b)=-16 h(c)=-15
Best First Search
• A* Algorithm-
91
Working Principle:
A* Algorithm works as-
•It maintains a tree of paths originating at the
start node.
•It extends those paths one edge at a time.
•It continues until its termination criterion is
satisfied.
• A* Algorithm extends the path that minimizes
the following function-
Here, f(n) = g(n) + h(n)
•‘n’ is the last node on the path
•g(n) is the cost of the path from start node to node ‘n’
•h(n) is a heuristic function that estimates cost of the
cheapest path from node ‘n’ to the goal node
92
Algorithm-
Step-01:
a
•Define a list OPEN. OPEN={a} h(a)=0+8
•Initially, OPEN consists solely of a single node, the start node S.
Step-02:
If the list is empty, return failure and exit.
Step-03:
Remove node n with the smallest value of f(n) from OPEN and move it to
list CLOSED.
•If node n is a goal state, return success and exit. OPEN={} CLOSED=a93
Step-04:
Expand node n.
a
Step-05:
b c
•If any successor to n is the goal node, return success and the solution by
tracing the path from goal node to S.
•Otherwise, go to Step-06.
Step-06: OPEN={b,c}
CLOSED ={a}
•For each successor node, (1+5) (1+4)
a
•Apply the evaluation function f to the node.
•If the node has not been in either list, add it to OPEN. b c
Step-07:
•Go back to Step-02.
94
a OPEN={b,c}
CLOSED={a}
a
(6)
(1+5) (1+4) OPEN={b,d,e}
CLOSED={a,c} b c
b (2+5) (2+7) c
e
d
(2+1) a OPEN={d,e}
CLOSED={a,b,c}
goal
b c
f d e
95
a OPEN={b,c}
CLOSED={a}
a
(6)
(1+5) (1+4) OPEN={b,d}
CLOSED={a,c,e} b c
b c (2+5)
e
{3+1) d
parent of b is e rather than a
(1+4)
b
(2+1) a OPEN={d,e}
CLOSED={a,b,c}
goal parent of c is b rather than a
96
Given an initial state of a 8-puzzle problem and final state to be
reached-
97
Solution-
•A* Algorithm maintains a tree of paths originating at the initial state.
•It extends those paths one edge at a time.
•It continues until final state is reached.
98
Problem
Reduction
Problem Reduction
• So far search strategies discussed were
for OR graphs.
– Here several arcs indicate a different ways
of solving problem.
• Another kind of structure is AND-OR
graph (tree).
• Useful for representing the solution of
problem by decomposing it into smaller
sub-problems.
Problem Reduction – Contd..
• Each sub-problem is solved and final
solution is obtained by combining
solutions of each sub-problem.
• Decomposition generates arcs that we will
call AND arc.
• One AND arc may point to any number of
successors, all of which must be solved.
• Such structure is called AND–OR graph
rather than simply AND graph.
Example of AND-OR Tree
Acquire TV
Solved Solved
Solved Solved
AO* Algorithm
• Let graph G consists initially the start node. Call it
INIT.
• Compute h(INIT).
• Until INIT is SOLVED or h(INIT) > Threshold or Un_Sol
{1
– Traverse the graph starting from INIT and follow the
current best path.
– Accumulate the set of nodes that are on the path which
have not yet been expanded or labeled as SOLVED.
– Select one of these unexpanded nodes. Call it NODE
and expand it.
– Generate the successors of NODE. If there are none,
then assign Threshold as the value of this NODE else
for each SUCC that is also not ancestor of NODE do the
following
{2
• Add SUCC to the graph G and compute h for each.
• If h(SUCC) = 0 then it is a solution node and label it as
SOLVED.
Contd..
• Propagate the newly discovered information
up the graph as follows:
– Initialize S with NODE.
– Until S is empty
{3
Select from S, a node such that the selected node has no ancestor
in G occurring in S /* to avoid cycle */.
Call it CURRENT and remove it from S.
Compute the cost of each arcs emerging from CURRENT.
Cost of AND arc = (h of each of the nodes at the end of the arc)
+ (cost of arc itself)
Assign the minimum of the costs as new h
value of CURRENT.
Mark the best path out of CURRENT
(with minimum cost).
Mark CURRENT node as SOLVED if all of the
nodes connected to it through the new marked
arc have been labeled SOLVED.
If CURRENT has been marked SOLVED or if the
cost of CURRENT was just changed, then new
status must be propagated back up the graph.
So add to S all of the ancestors of CURRENT.
3
}
2
}
1
}
Longer Path May be Better
• Consider another example
1
2 3 4 Unsolvable
5 6
7 8
9 10
Explanation
D (3)
E (2) C (5)
124
Constraint Satisfaction Problems
• What is a CSP?
– Finite set of variables X1, X2, …, Xn
• Constraints:
• Qi != Qj (j != i)
• |Qi – Qj| != |i – j|
Sudoku as a Constraint Satisfaction Problem
(CSP)
1 2 3 4 5 6 7 8
9
A
B
• Variables: 81 variables C
– A1, A2, A3, …, I7, I8, I9 D
E
– Letters index rows, top to bottom F
G
– Digits index columns, left to right H
• Domains: The nine positive digits I
– A1 {1, 2, 3, 4, 5, 6, 7, 8, 9}
– Etc.
• Constraints: 27 Alldiff constraints
– Alldiff(A1, A2, A3, A4, A5, A6, A7, A8, A9)
– Etc.
• [Why constraint satisfaction?]
CSP example: map coloring
{WA=red,NT=green,Q=red,NSW=green,V=red,SA=blue,T=
green}
Varieties of constraints
• Unary constraints involve a single variable.
– e.g. SA green
7 3 4
7 3 4
----------
14 6 8
----------
O=4
R=8
W=3
U=6
T=7
F=1
CSP Example: Cryptharithmetic
puzzle
Means-Ends Analysis
• We have studied the strategies which can reason either in forward or
backward, but a mixture of the two directions is appropriate for solving a
complex and large problem.
• Such a mixed strategy, make it possible that first to solve the major part of
a problem and then go back and solve the small problems arise during
combining the big parts of the problem. Such a technique is called Means-
Ends Analysis.
• Means-Ends Analysis is problem-solving techniques used in Artificial
intelligence for limiting search in AI programs.
• It is a mixture of Backward and forward search technique.
• The MEA technique was first introduced in 1961 by Allen Newell, and
Herbert A. Simon in their problem-solving computer program, which was
named as General Problem Solver (GPS).
• The MEA analysis process centered on the evaluation of the difference
between the current state and goal state.
133
How means-ends analysis
Works:
• means-ends analysis process can be applied
recursively for a problem. It is a strategy to control
search in problem-solving. Following are the main
Steps which describes the working of MEA technique
for solving a problem.
• First, evaluate the difference between Initial State
and final State.
• Select the various operators which can be applied
for each difference.
• Apply the operator at each difference, which
reduces the difference between the current state
and goal state.
134
Operator Subgoaling
• In the MEA process, we detect the differences
between the current state and goal state.
• Once these differences occur, then we can apply an
operator to reduce the differences
• But sometimes it is possible that an operator cannot
be applied to the current state.
• So we create the subproblem of the current state, in
which operator can be applied, such type of
backward chaining in which operators are selected,
and then sub goals are set up to establish the
preconditions of the operator is called Operator
Subgoaling.
135
Algorithm for Means-Ends
• Let's we take Current state asAnalysis
CURRENT and Goal State as GOAL, then
following are the steps for the MEA algorithm.
• Step 1: Compare CURRENT to GOAL, if there are no differences between
both then return Success and Exit.
• Step 2: Else, select the most significant difference and reduce it by doing
the following steps until the success or failure occurs.
– Select a new operator O which is applicable for the current difference,
and if there is no such operator, then signal failure.
– Attempt to apply operator O to CURRENT. Make a description of two
states.
i) O-Start, a state in which O?s preconditions are satisfied.
ii) O-Result, the state that would result if O were applied In O-start.
– If(First-Part <------ MEA (CURRENT, O-START)
And
(LAST-Part <----- MEA (O-Result, GOAL), are successful, then signal
Success and return the result of combining FIRST-PART, O, and LAST-
PART.
136
Example- Robo navigation
o1
o1 o2
o2
loc1 loc2
Operator Pre-cond Result
PUSH(obj,loc) At(Robo,loc) and Large(obj) At(obj,loc) and
and at(robo,loc
Clear(obj) and armempty
CARRY(obj,loc At(Robo,loc) and small(obj) and At(obj,loc) and
) Clear(obj) and armempty at(robo,loc
loc1 loc2
Operator Pre-cond Result
PUSH(obj,loc) At(Robo,loc) and Large(obj) At(obj,loc) and
and at(robo,loc
Clear(obj) and armempty
CARRY(obj,loc At(Robo,loc) and small(obj) and At(obj,loc) and
) Clear(obj) and armempty at(robo,loc
Episodic No sequential No
Agent keeps track of the world state as well as set of goals it’s trying to achieve: chooses
actions that will (eventually) lead to the goal(s).
More flexible than reflex agents may involve search and planning
Goal-based agents
167
Architecture of a
knowledge-based agent
• Knowledge Level.
– The most abstract level: describe agent by saying what it
knows.
– Example: A taxi agent might know that the Golden Gate Bridge
connects San Francisco with the Marin County.
• Logical Level.
– The level at which the knowledge is encoded into sentences.
– Example: Links(GoldenGateBridge, SanFrancisco,
MarinCounty).
• Implementation Level.
– The physical representation of the sentences in the logical
level.
– Example: ‘(links goldengatebridge sanfrancisco
marincounty)
168
Function KB-agent(percept) returns Action
static KB, a knowlegebase, t counter(time)
TELL(KB, MAKE-PERCEPT-SENTENCE(percept, t)
action<- ASK(KB,MakeAction_query(t))
TELL(KB, MAKE-ACT-SENTENCE(action, t)
t=t+1
Return action
169
Game
Playing
How to play a game
• A way to play such a game is to:
– Consider all the legal moves you can make
– Compute the new position resulting from each move
– Evaluate each resulting position and determine which
is best
– Make that move
– Wait for your opponent to move and repeat
• Key problems are:
– Representing the “board”
– Generating all legal next boards
– Evaluating a position
Evaluation function
• Evaluation function or static evaluator is used
to evaluate the “goodness” of a game position.
– Contrast with heuristic search where the evaluation
function was a non-negative estimate of the cost from the
start node to a goal and passing through the given node
• The zero-sum assumption allows us to use a single
evaluation function to describe the goodness of a
board with respect to both players.
– f(n) >> 0: position n good for me and bad for you
– f(n) << 0: position n bad for me and good for you
– f(n) near 0: position n is a neutral position
– f(n) = +infinity: win for me
– f(n) = -infinity: win for you
Evaluation function examples
• Example of an evaluation function for Tic-Tac-Toe:
f(n) = [# of 3-lengths open for me] - [# of 3-lengths open for
you]
where a 3-length is a complete row, column, or diagonal
• Alan Turing’s function for chess
– f(n) = w(n)/b(n) where w(n) = sum of the point value of
white’s pieces and b(n) = sum of black’s
• Most evaluation functions are specified as a weighted
sum of position features:
f(n) = w1*feat1(n) + w2*feat2(n) + ... + wn*featk(n)
• Example features for chess are piece count, piece
placement, squares controlled, etc.
Game trees
2 1 2 1
2 7 1 8 2 7 1 8 2 7 1 8
MIN node
value computed
f value by minimax
Alpha-beta pruning
181
• Step 3: Now algorithm backtrack to node B, where the value of β
will change as this is a turn of Min, Now β= +∞, will compare with
the available subsequent nodes value, i.e. min (∞, 3) = 3, hence at
node B now α= -∞, and β= 3.
182
• Step 4: At node E, Max will take its turn, and the value of alpha will
change. The current value of alpha will be compared with 5, so max (-∞,
5) = 5, hence at node E α= 5 and β= 3, where α>=β, so the right
successor of E will be pruned, and algorithm will not traverse it, and the
value at node E will be 5.
183
• Step 5: At next step, algorithm again backtrack the tree, from node B to
node A. At node A, the value of alpha will be changed the maximum
available value is 3 as max (-∞, 3)= 3, and β= +∞, these two values now
passes to right successor of A which is Node C.
• At node C, α=3 and β= +∞, and the same values will be passed on to node
F.
• Step 6: At node F, again the value of α will be compared with left child
which is 0, and max(3,0)= 3, and then compared with right child which is 1,
and max(3,1)= 3 still α remains 3, but the node value of F will become 1.
184
• Step 7: Node F returns the node value 1 to node C, at C α= 3
and β= +∞, here the value of beta will be changed, it will
compare with 1 so min (∞, 1) = 1. Now at C, α=3 and β= 1, and
again it satisfies the condition α>=β, so the next child of C
which is G will be pruned, and the algorithm will not compute
the entire sub-tree G.
185
• Step 8: C now returns the value of 1 to A here the best value for A is
max (3, 1) = 3. Following is the final game tree which is the showing
the nodes which are computed and nodes which has never computed.
Hence the optimal value for the maximizer is 3 for this example.
186
Alpha-beta algorithm
function MAX-VALUE (state, α, β)
;; α = best MAX so far; β = best MIN
if TERMINAL-TEST (state) then return UTILITY(state)
v := -∞
for each s in SUCCESSORS (state) do
v := MAX (v, MIN-VALUE (s, α, β))
if v >= β then return v
α := MAX (α, v)
end
return v