Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 82

ARTIFICIAL

INTELLIGENCE
Unit –I
INTRODUCTION

AI -VI BCA D 03/20/2024


2 Introduction

 Artificial Intelligence is an approach to make a computer, a robot, or a product to think


how smart human think.
 AI is a study of how human brain think, learn, decide and work, when it tries to solve
problems.
 The aim of AI is to improve computer functions which are related to human knowledge
 example, reasoning, learning, and problem-solving.

AI -VI BCA D 03/20/2024


3 Objective of AI Research
 1. Knowledge - to represent knowledge about the world
 Understand the entities and properties
 Relationship to one another
 2. Reasoning – to solve problems through logical reasoning
 Logic - related ideas and conclusions from information
 Deductive - derive specific conclusions from general premises believed to be true
 Inductive -infer general conclusions from specific premises (or)
 Abductive - seek the simplest and most likely explanation for an observation
 3. Planning – to set and achieve goals
 sequence of actions enabling progress towards it.
 Communication - to understand written and spoken language
 to communicate with people, software must have the ability to identify, understand and synthesize written or spoken
human language.
 Perception - to make deductions about the world based on input
AI -VI BCA D 03/20/2024
 software must be able to organize, identify and interpret visual images, sounds and other sensory inputs.
4 Artificial Intelligence

 AI composed in two words


 Artificial – man-made
 Intelligence – thinking power
 AI – Machines /systems thinks like human being
 AI – booming technology, fascinating and universal fields of Computer science
 creates computers or machines as intelligent as human beings

AI -VI BCA D 03/20/2024


5 Definition
 Definition:
 According to the father of Artificial Intelligence, John McCarthy, it is “The science and
engineering of making intelligent machines, especially intelligent computer programs”.

 Definition from Rich & Knight : a program that


 – Acts like human (Turing test)
 – Thinks like human (human-like patterns of thinking steps)
 – Acts or thinks rationally (logically, correctly)

AI -VI BCA D 03/20/2024


6

AI -VI BCA D 03/20/2024


7

AI -VI BCA D 03/20/2024


8

AI -VI BCA D 03/20/2024


9 Why AI?

 With the help of AI,


 you can create such software or devices which can solve real-world problems very easily and with
accuracy such as health issues, marketing, traffic issues, etc.
 you can create your personal virtual Assistant, such as Cortana ( MS own bing search engine),
Google Assistant (google), Siri (will prompt you to call or make a reservation),alexa, etc.
 you can build such Robots which can work in an environment where survival of humans can be at
risk.
 AI opens a path for other new technologies, new devices, and new Opportunities.

AI -VI BCA D 03/20/2024


10 Categories of Artificial Intelligence

 Weak AI - pre-planned moves


 make the humans feel that the machines are acting intelligently (but they are not).
 Strong AI - machine is almost capable of solving a complex problem like an intelligent
man
 think and function very similar to humans
 making the humans feel that the machines are intelligent.

AI -VI BCA D 03/20/2024


Thinks like Human – human like patterns of
11
thinking steps
 Sophia is a social humanoid robot developed by Hong
Kong based company Hanson Robotics. Sophia was
activated on February 14, 2016, and made her first
public appearance at South by Southwest
Festival (SXSW) in mid-March 2016 in Austin, Texas,
United States.
 She is able to display more than 50 facial expressions.
 Robot Sophia was given Saudia citizenship in 2017
'Sophia' the robot tells UN_ 'I am here to help humanity c
reate the future' - YouTube (720p).mp4
AI -VI BCA D 03/20/2024
12

AI -VI BCA D 03/20/2024


13 GOALS
 develop intelligent machines that could learn on their own. No more human intervention
for feeding data to machines.
 To Create Expert Systems −systems which exhibit intelligent behavior, learn, demonstrate,
explain, and advice its users.
 To Implement Human Intelligence in Machines - Creating systems that understand, think,
learn, and behave like humans.
 to develop reasoning and problem – solving skills
 Knowledge representation is representing information that machine or computer can
understand.
 Natural learning processing -With artificial intelligence one can develop machines that can
read and understand human languages

AI -VI BCA D
03/20/2024
14 AI discipline

AI -VI BCA D 03/20/2024


15 Advantages of Artificial Intelligence

 1) Reduction in Human Error


 decisions are taken from the previously gathered information applying certain set of algorithms.
 2) Takes risks instead of Humans
 overcome many risky limitations of human by developing an AI Robot
 3) Available 24×7
 machines work 24×7 without any breaks
 4) Helping in Repetitive Jobs
 repetitive works like sending a thanking mail, verifying certain documents for errors
 5) Digital Assistance
 used in many websites to provide things that user want.
 6) Faster Decisions
 machines take decisions faster than a human
 7) Daily Applications
 Apple’s Siri, Window’s Cortana, Google’s OK Google
 8) New Inventions
 many inventions - solve the majority of complex problems

AI -VI BCA D 03/20/2024


16 Disadvantages of Artificial Intelligence

 1) High Costs of Creation


 hardware and software need to get updated
 repairing and maintenance
 2) Making Humans Lazy
 applications automating the majority of the work.
 3) Unemployment
 replacing the majority of the repetitive tasks and other works with robots
 4) No Emotions
 cannot develop a bond with humans
 5) Lacking Out of Box Thinking
 perform only those tasks which they are designed or programmed to do

0
AI -VI BCA D 03/20/2024
17 Few Branches of AI
 Logical AI  Common sense knowledge and
 specific situation – how to take Reasoning
decision  non-monotonic reasoning and
 theories of action
Search

 Learning from experience
examine large numbers of
possibilities – ex. Moves in chess  abilities to represent information.
 Pattern Recognition  Planning
 program makes observations of  sequence of actions.
some kind,
 Epistemology
 Representation
 study of the kinds of knowledge
 Usually languages of that are required for solving
mathematical logic are used to problems
represent the facts
 Ontology
 Inference
 study of the kinds of things that

AI -VI BCA D conclusion can be withdrawn if exist 03/20/2024

there is evidence to the divergent


18 Applications of AI

AI -VI BCA D 03/20/2024


19

AI -VI BCA D 03/20/2024


Best 10 examples of AI in day to day life
1. Open Your Phone With Face ID- uses neural engine and face recognition
20
2. Email -Google gave us a smarter inbox, categorizing all the emails on its own, into folders such
as Primary, Social, Promotions, Updates and more.
3. Entertainment and Social Apps-identifying friends from photos, newsfeed personalization. ,Netflix
- recommendations

4. Google Navigation- Maps uses Machine Learning


5. Banking & Finance- AI & ML provides security features (Fraud preventions E-payments, Mobile
Banking)
6. Google predictive search algorithms-Google Auto complete forms- RankBrain is the algorithm
name
7. E-commerce – pattern matching , product recommendations
8. Mobile use- Speech recognition with Natural Language Processing (voice to text, chatbot)
9. Video games-AI controlled Non-playable characters (NPC), ML for BGM
10. Smart Personal Assistant- Google Assistant , Alexa, SIRI (Online shopping, Controlling lights
and other internet-enabled equipment ,Setting reminders and alarms , Booking cabs, flights and
trains, Playing music and videos )
AI -VI BCA D 03/20/2024
21 Internal Representation
 In order to act intelligently, a computer must have the
knowledge about the domain of interest.
 Knowledge is the body of facts and principles gathered or the
act, fact, or state of knowing.
 This knowledge needs to be presented in a form, which is
understood by the machine.
 This unique format is called internal representation.
 Thus plain English sentences could be translated into an
internal representation and they could be used to answer based
on the given sentences.

AI -VI BCA D 03/20/2024


22 Properties of Internal Representation
 avoid Ambiguity in words
 remove all referential ambiguity
 explicitly mention functional structure to express an idea

 Internal representation should avoid word sense ambiguity


 Word sense ambiguity arise because of multiple meaning of words.
Example
‘Raj caught a pen .
Raj caught a train.
Raj caught fever’
 Internal representation must remove all referential ambiguity.
 Referential ambiguity is the ambiguity about what the sentence refers to
Example: Raj said that Ram was not well. He must by lying”
AI -VI BCA D 03/20/2024

Who does he refers to..?


23
 Internal representation must explicitly mention functional
structure
 Functional structure is the word order used in the language
to express an idea.
Example: Ram killed Ravan. Ravan was killed by Ram.
 Thus internal representation may not use the order of the
original sentence
 Internal representation should be handle complex sentence
without losing meaning attached with it.

AI -VI BCA D 03/20/2024


24 Problem representation in AI
 Define the problem precisely -initial solution & final solution.

 Analyze the problem - important features

 Isolated and represent - features into knowledge representation

 Choose (problem solving techniques) – choose best technique

State space representation: set of all possible states for a given

problem.

AI -VI BCA D 03/20/2024


25 Example of problem space

to make a cup of coffee.


• Analyze the problem

• Check necessary ingrediants are available or not

• If they are available, apply procedure for making coffee.

AI -VI BCA D 03/20/2024


26

• Ingrediants (initial state)

• Sequence of steps(states)

• Cup of coffee (goal)

• Coffee powder, milk powder, sugar

(operators)

AI -VI BCA D 03/20/2024


27

AI -VI BCA D 03/20/2024


28  We started with Ingredients i.e the Initial state.
 Followed by sequence of Steps.
 We added only needed amount of coffee
powder, milk & sugar. These are Operators/
Actions.
 At last had a cup of coffee –Goal state.

AI -VI BCA D 03/20/2024


SEARCH TECHNIQUES
29  Search algorithms are one of the most important areas of Artificial
Intelligence.
Problem-solving agents:
 In Artificial Intelligence, Search techniques are universal
problem-solving methods.
 Rational agents or Problem-solving agents in AI mostly used
these search strategies or algorithms to solve a specific problem
and provide the best result.
 Problem-solving agents are the goal-based agents and use atomic
representation.
 Searching algorithms can be of various types. When any type of
searching is performed, there may be some information provided
about the searching or may not be. Also, it is possible that the
searching procedure may depend upon some constraints or rules.
AI -VI BCA D 03/20/2024
Search Algorithm Terminologies:
• Search: Searching is a step by step procedure to solve a search-problem in a
30 given search space. A search problem can have three main factors:
 Search Space: Search space represents a set of possible solutions, which a
system may have.
 Start State: It is a state from where agent begins the search.
 Goal test: It is a function which observe the current state and returns whether
the goal state is achieved or not.
• Search tree: A tree representation of search problem is called Search tree. The
root of the search tree is the root node which is corresponding to the initial state.
• Actions: It gives the description of all the available actions to the agent.
• Transition model: A description of what each action do, can be represented as a
transition model.
• Path Cost: It is a function which assigns a numeric cost to each path.
• Solution: It is an action sequence which leads from the start node to the goal
node.
AI -VI BCA D 03/20/2024

• Optimal Solution: If a solution has the lowest cost among all solutions.
Properties of Search Algorithms:
31
 Following are the four essential properties of search algorithms to compare the efficiency of these
algorithms:

 Completeness: A search algorithm is said to be complete if it guarantees to return a solution if at least


any solution exists for any random input.

 Optimality: If a solution found for an algorithm is guaranteed to be the best solution (lowest path cost)
among all other solutions, then such a solution for is said to be an optimal solution.

 Time Complexity: Time complexity is a measure of time for an algorithm to complete its task.

 Space Complexity: It is the maximum storage space required at any point during the search, as the
complexity of the problem.

AI -VI BCA D 03/20/2024


Two categories
32 Direct heuristic Search techniques / Uninformed (Blind Search)
Week Heuristic Search techniques /informed (Heuristic Search)

AI -VI BCA D 03/20/2024


 An uninformed search is a searching technique
33
that has no additional information about the distance
from the current state to the goal.
 Informed Search is another technique that has
additional information about the estimate distance
from the current state to the goal.

AI -VI BCA D 03/20/2024


34

Best first, A+,mean Depth first, breath first

AI -VI BCA D 03/20/2024


Informed (Heuristic) Search Strategies
 Heuristic - a “rule of thumb” used to help guide search
35
 The purpose of heuristic function is to guide the search process in the most profitable
path among all that are available.
 To solve large problems with large number of possible states, problem-specific
knowledge needs to be added to increase the efficiency of search algorithms.
 Heuristic Function - function applied to a state in a search space to indicate a
likelihood of success if that state is selected
 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
 At each branching step, it evaluates the available information and makes a decision on
which branch to follow.
Heuristic Evaluation Functions
 It calculate the cost of optimal path between two states. A heuristic function for
sliding-tiles games is computed by counting number of moves that each tile makes
AI -VI BCA D 03/20/2024
from its goal state and adding these number of moves for all tiles.

36 Pure Heuristic Search
 It expands nodes in the order of their heuristic
values.
 It creates two lists, a closed list for the already
expanded nodes and an open list for the created
but unexpanded nodes.
 In each iteration, a node with a minimum heuristic
value is expanded, all its child nodes are created
and placed in the closed list.
 Then, the heuristic function is applied to the child
nodes and they are placed in the open list
according to their heuristic value. The shorter
AI -VI BCA D 03/20/2024

paths are saved and the longer ones are disposed.


37  8 Tile Puzzle
 Puzzle which will have square with 9 slots
numbered from 1 t0 8 and empty slot.
 Objective is to get the square in numerical order.
By using empty slot.
 Operators UP – Move up
 Down – move down
 Left – move left
 Right – move right
AI -VI BCA D 03/20/2024
38

AI -VI BCA D 03/20/2024


 TRY YOURSELF
39
 Example Heuristics: 8 Puzzle

AI -VI BCA D 03/20/2024


40

AI -VI BCA D 03/20/2024


41

AI -VI BCA D 03/20/2024


42 Example 2 –Try urself

AI -VI BCA D 03/20/2024


43
Best First Search (Informed Search)
Best-first search is depends on the heuristic
function and the structure of the problem.
In the best first search algorithm, we expand
the node which is closest to the goal node and
the closest cost is estimated by heuristic
function,
Performance of the algorithm depends on how
well the cost or evaluation function is
designed.
AI -VI BCA D 03/20/2024
44 Best First Search Algorithm
Create two list: open[ ] and close[ ] list
Open – node that has been generated and had heuristic applied
but not yet examined
Close-nodes that has already been examined.
 Step 1: Place the starting node into the OPEN list.
 Step 2: If the OPEN list is empty, Stop and return failure.
 Step 3: Remove the node n, from the OPEN list which has
the lowest value of h(n), and places it in the CLOSED list.
 Step 4: Expand the node n, and generate the successors of
node n.
AI -VI BCA D 03/20/2024

 Step 5: Check each successor of node n, and find whether


45  Step 6: For each successor node, algorithm checks for
evaluation function f(n), and then check if the node has
been in either OPEN or CLOSED list. If the node has not
been in both list, then add it to the OPEN list.
 Step 7: Return to Step 2.

AI -VI BCA D 03/20/2024


Best first search We start from source "S" and search for goal “G" using given costs and Best First search.
=[] ,closed=[]
Open

Open=[S], closed=[]
46

SBFG
AI -VI BCA D 03/20/2024
47  In BFS(Breadth first search) and DFS(Depth first search),
when we are at a node, we can consider any of the adjacent as
next node. So both BFS and DFS blindly explore paths
without considering any cost function.
 The idea of Best First Search is to use an evaluation function
to decide which adjacent is most promising and then explore.
Best First Search falls under the category of Heuristic Search
or Informed Search.

AI -VI BCA D 03/20/2024


48
Analysis : The worst case time complexity for Best First Search
is O(n * Log n) where n is the number of nodes. In worst case, we
may have to visit all nodes before we reach the goal.
Advantage.
 It is more efficient than that of BFS and DFS.
 Time complexity of Best first search is much less than Breadth
first search.
 The Best first search allows us to switch between paths by
gaining the benefits of both breadth first and depth first search.
Disadvantage
 Sometimes, it covers more distance than our consideration.

AI -VI BCA D 03/20/2024


49
Means-Ends Analysis - 1961 by Allen Newell, and Herbert A. Simon
 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.
Means-ends analysis Works:
 The means-ends analysis process can be applied recursively for a problem. It is a
strategy to control search in problem-solving.
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.
AI -VI BCA D 03/20/2024
50 Algorithm

 Let's take the Current state as CURRENT and Goal State as GOAL, then the 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
AI -VI BCA D 03/20/2024
(LAST-Part <----- MEA (O-Result, GOAL), are successful, then signal Success and return the
result of combining FIRST-PART, O, and LAST-PART.
51 Operator Subgoaling

 create the sub-problem 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.

AI -VI BCA D 03/20/2024


52

AI -VI BCA D 03/20/2024


53

AI -VI BCA D 03/20/2024


54

AI -VI BCA D 03/20/2024


55

 To reach the goal state using MEA,


 1. Apply move operator to pull out circle from the rectangle
 2. Apply expand operator to reduce the size of the rectangle.

AI -VI BCA D 03/20/2024


56 Example 2 :Toy problem: chicken crossing

AI -VI BCA D 03/20/2024


57

AI -VI BCA D 03/20/2024


58

AI -VI BCA D 03/20/2024


59

AI -VI BCA D 03/20/2024


60

AI -VI BCA D 03/20/2024


61

AI -VI BCA D 03/20/2024


Game Playing Algorithms
62  Mini-max algorithm is a recursive or backtracking algorithm which is used in decision-making and game
theory. It provides an optimal move for the player assuming that opponent is also playing optimally.
 Mini-Max algorithm uses recursion to search through the game-tree.
 Min-Max algorithm is mostly used for game playing in AI. Such as Chess, Checkers, tic-tac-toe, go, and
various tow-players game. This Algorithm computes the min-max decision for the current state.
 In this algorithm two players play the game, one is called MAX and other is called MIN.
 Both the players fight it as the opponent player gets the minimum benefit while they get the maximum benefit.
 Both Players of the game are opponent of each other, where MAX will select the maximized value and MIN will
select the minimized value.
 The minimax algorithm performs a depth-first search algorithm for the exploration of the complete game tree.
 The minimax algorithm proceeds all the way down to the terminal node of the tree, then backtrack the tree as
the recursion.

AI -VI BCA D 03/20/2024


63

AI -VI BCA D 03/20/2024


Working of Min-Max Algorithm

 The working of the minimax algorithm can be easily described using an example. Below we have
64
taken an example of game-tree which is representing the two-player game.
 In this example, there are two players one is called Maximizer and other is called Minimizer.
 Maximizer will try to get the Maximum possible score, and Minimizer will try to get the minimum
possible score.
 This algorithm applies DFS, so in this game-tree, we have to go all the way through the leaves to
reach the terminal nodes.
 At the terminal node, the terminal values are given so we will compare those value and backtrack the
tree until the initial state occurs. Following are the main steps involved in solving the two-player
game tree:

AI -VI BCA D 03/20/2024


 Step-1: In the first step, the algorithm generates the entire game-tree and apply
the utility function to get the utility values for the terminal states. In the below
65 tree diagram, let's take A is the initial state of the tree. Suppose maximizer takes
first turn which has worst-case initial value =- infinity, and minimizer will take
next turn which has worst-case initial value = +infinity.

AI -VI BCA D 03/20/2024


 Step 2: Now, first we find the utilities value for the Maximizer, its initial value is -∞, so we will
compare each value in terminal state with initial value of Maximizer and determines the higher nodes
values. It will find the maximum among the all.
66
 For node D max(-1,- -∞) => max(-1,4)= 4
 For Node E max(2, -∞) => max(2, 6)= 6
 For Node F max(-3, -∞) => max(-3,-5) = -3
 For node G max(0, -∞) = max(0, 7) = 7

AI -VI BCA D 03/20/2024


 Step 3: In the next step, it's a turn for minimizer, so it will compare all nodes value with +∞, and will find
the 3rd layer node values.
67  For node B= min(4,6) = 4
 For node C= min (-3, 7) = -3

AI -VI BCA D 03/20/2024


 Step 4: Now it's a turn for Maximizer, and it will again choose the maximum of all nodes value and
find the maximum value for the root node. In this game tree, there are only 4 layers, hence we reach
immediately to the root node, but in real games, there will be more than 4 layers.
68
 For node A max(4, -3)= 4

AI -VI BCA D 03/20/2024


Properties of Mini-Max algorithm:
 Complete- Min-Max algorithm is Complete. It will definitely find a solution (if exist), in the finite
69 search tree.
 Optimal- Min-Max algorithm is optimal if both opponents are playing optimally.
 Time complexity- As it performs DFS for the game-tree, so the time complexity of Min-Max
algorithm is O(bm), where b is branching factor of the game-tree, and m is the maximum depth of the
tree.
 Space Complexity- Space complexity of Mini-max algorithm is also similar to DFS which
is O(bm).

Limitation of the minimax Algorithm:


 The main drawback of the minimax algorithm is that it gets really slow for complex games such as
Chess, go, etc. This type of games has a huge branching factor, and the player has lots of choices to
decide. This limitation of the minimax algorithm can be improved from alpha-beta pruning

AI -VI BCA D 03/20/2024


Alpha-Beta Pruning
70
 Alpha-beta pruning is a modified version of the minimax algorithm. It is an optimization technique for the
minimax algorithm.
 in the minimax search algorithm that the number of game states it has to examine are exponential in depth of the
tree. Since we cannot eliminate the exponent, but we can cut it to half. Hence there is a technique by which
without checking each node of the game tree we can compute the correct minimax decision, and this technique
is called pruning.
 Pruning involves two threshold parameter Alpha and beta for future expansion, so it is called alpha-beta
pruning. It is also called as Alpha-Beta Algorithm.
 Alpha-beta pruning can be applied at any depth of a tree, and sometimes it not only prune the tree leaves but
also entire sub-tree.
 The two-parameter can be defined as:
 Alpha: The best (highest-value) choice we have found so far at any point along the path of Maximizer. The initial value
of alpha is -∞.
 Beta: The best (lowest-value) choice we have found so far at any point along the path of Minimizer. The initial value of
beta is +∞.
 The Alpha-beta pruning to a standard minimax algorithm returns the same move as the standard algorithm does,
but it removes AIall the nodes which are not really affecting the final decision but making algorithm slow. 03/20/2024
-VI BCA D
Hence
by pruning these nodes, it makes the algorithm fast.
71 Condition for Alpha-beta pruning:

 Condition for Alpha-beta pruning:


 α>=β

 Key points about alpha-beta pruning:


 The Max player will only update the value of alpha.
 The Min player will only update the value of beta.
 While backtracking the tree, the node values will be passed to upper nodes instead of values of
alpha and beta.
 We will only pass the alpha, beta values to the child nodes.

AI -VI BCA D 03/20/2024


72 Working of Alpha-Beta Pruning:

 Step 1: At the first step the, Max player will start first move from node A where α= -∞ and
β= +∞, these value of alpha and beta passed down to node B where again α= -∞ and β=
+∞, and Node B passes the same value to its child D.

AI -VI BCA D 03/20/2024


73

 Step 2: At Node D, the value of α will be calculated as its turn for Max. The value of α is
compared with firstly 2 and then 3, and the max (2, 3) = 3 will be the value of α at node D
and node value will also 3.

AI -VI BCA D 03/20/2024


74

 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.

 In the next step, algorithm traverse the next successor of Node B which is node E, and the values of α= -∞,
and β= 3 will also be passed.
AI -VI BCA D 03/20/2024
 Step 4: At node E, Max will take its turn, and the value of alpha will change. The current
75 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.

AI -VI BCA D 03/20/2024


 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,
76 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.

AI -VI BCA D 03/20/2024


 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 α
77 remains 3, but the node value of F will become 1.

AI -VI BCA D 03/20/2024


 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,
78 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.

AI -VI BCA D 03/20/2024


 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
79 nodes which has never computed. Hence the optimal value for the maximizer is 3 for this
example.

AI -VI BCA D 03/20/2024


80 Move Ordering in Alpha-Beta pruning:
 The effectiveness of alpha-beta pruning is highly dependent on the order in which each node is
examined. Move order is an important aspect of alpha-beta pruning.
It can be of two types:
 Worst ordering: In some cases, alpha-beta pruning algorithm does not prune any of the leaves
of the tree, and works exactly as minimax algorithm. In this case, it also consumes more time
because of alpha-beta factors, such a move of pruning is called worst ordering. In this case, the
best move occurs on the right side of the tree. The time complexity for such an order is O(bm).
 Ideal ordering: The ideal ordering for alpha-beta pruning occurs when lots of pruning happens
in the tree, and best moves occur at the left side of the tree. We apply DFS hence it first search
left of the tree and go deep twice as minimax algorithm in the same amount of time.
Complexity in ideal ordering is O(bm/2).

AI -VI BCA D 03/20/2024


81 Rules to find good ordering:

 Following are some rules to find good ordering in alpha-beta pruning:


 Occur the best move from the shallowest node.
 Order the nodes in the tree such that the best nodes are checked first.
 Use domain knowledge while finding the best move. Ex: for Chess, try order: captures first, then
threats, then forward moves, backward moves.
 We can bookkeep the states, as there is a possibility that states may repeat.

AI -VI BCA D 03/20/2024


82

Thank you..
Dr.Thenmozhi K
THANK YOU..
thenmithu@gmail.com

AI -VI BCA D 03/20/2024

You might also like