Artificial Intelligence: Introduction, Typical Applications. State Space Search: Depth Bounded
DFS, Depth First Iterative Deepening. Heuristic Search: Heuristic Functions, Best First Search,
Hill Climbing, Variable Neighborhood Descent, Beam Search, Tabu Search. Optimal Search: A
*
algorithm, Itera...
Artificial Intelligence: Introduction, Typical Applications. State Space Search: Depth Bounded
DFS, Depth First Iterative Deepening. Heuristic Search: Heuristic Functions, Best First Search,
Hill Climbing, Variable Neighborhood Descent, Beam Search, Tabu Search. Optimal Search: A
*
algorithm, Iterative Deepening A*
, Recursive Best First Search, Pruning the CLOSED and OPEN
Lists
Size: 664.14 KB
Language: en
Added: May 06, 2021
Slides: 23 pages
Slide Content
Topic To Be Covered:
I. Mini-Max Algorithm in AI
Jagdamba Education Society's
SND College of Engineering & Research Centre
Department of Computer Engineering
SUBJECT: Artificial Intelligence & Robotics
Lecture No-15
Prof.Dhakane Vikas N
Mini-Max Algorithm in AI
Mini-maxalgorithmisarecursiveor
backtrackingalgorithmwhichisusedin
decision-makingandgametheory.
Itprovidesanoptimalmovefortheplayer
assumingthatopponentisalsoplaying
optimally.
Mini-Maxalgorithmusesrecursiontosearch
throughthegame-tree.
Min-Maxalgorithmismostlyusedforgame
playinginAI.SuchasChess,Checkers,tic-tac-
toe,go,andvarioustow-playersgame.This
Algorithmcomputestheminimaxdecisionfor
thecurrentstate.
Mini-Max Algorithm in AI
Inthisalgorithmtwoplayersplaythegame,one
iscalledMAXandotheriscalledMIN.
Boththeplayersfightitastheopponentplayer
BothPlayersofthegameareopponentofeach
other,whereMAXwillselectthemaximizedvalue
andMINwillselecttheminimizedvalue.
Theminimaxalgorithmperformsadepth-first
searchalgorithmfortheexplorationofthe
completegametree.
Theminimaxalgorithmproceedsalltheway
downtotheterminalnodeofthetree,then
backtrackthetreeastherecursion.
Working of Min-Max Algorithm:
Theworkingoftheminimaxalgorithmcanbeeasily
describedusinganexample.Belowwehavetakenan
exampleofgame-treewhichisrepresentingthetwo-
playergame.
Inthisexample,therearetwoplayersoneiscalled
MaximizerandotheriscalledMinimizer.
MaximizerwilltrytogettheMaximumpossible
score,andMinimizerwilltrytogettheminimum
possiblescore.
Working of Min-Max Algorithm:
ThisalgorithmappliesDFS,sointhisgame-tree,we
havetogoallthewaythroughtheleavestoreach
theterminalnodes.
Attheterminalnode,theterminalvaluesaregiven
sowewillcomparethosevalueandbacktrackthe
treeuntiltheinitialstateoccurs.
Followingarethemainstepsinvolvedinsolvingthe
two-playergametree:
Working of Min-Max Algorithm:
Step2:Now,firstwefindtheutilitiesvaluefor
theMaximizer,itsinitialvalueis-∞,sowewill
compareeachvalueinterminalstatewithinitial
valueofMaximizeranddeterminesthehigher
nodesvalues.
Itwillfindthemaximumamongtheall.
FornodeD max(-1,--∞)=>max(-1,4)=4
ForNodeE max(2,-∞)=>max(2,6)=6
ForNodeF max(-3,-∞)=>max(-3,-5)=-3
FornodeG max(0,-∞)=max(0,7)=7
Working of Min-Max Algorithm:
Step3:Inthenextstep,it'saturn
forminimizer,soitwillcompare
allnodesvaluewith+∞,andwill
findthe3rdlayernodevalues.
FornodeB=min(4,6)=4
FornodeC=min(-3,7)=-3
Working of Min-Max Algorithm:
Step4:
Nowit'saturnforMaximizer,andit
willagainchoosethemaximumofall
nodesvalueandfindthemaximum
valuefortherootnode.
Inthisgametree,thereareonly4
layers,hencewereachimmediately
totherootnode,butinrealgames,
therewillbemorethan4layers.
FornodeAmax(4,-3)=4
Limitation of the minimax Algorithm
Themaindrawbackoftheminimaxalgorithmisthatitgetsreallyslow
forcomplexgamessuchasChess,go,etc.Thistypeofgameshasahuge
branchingfactor,andtheplayerhaslotsofchoicestodecide.
Thislimitationoftheminimaxalgorithmcanbeimprovedfromalpha-
betapruningwhichwehavediscussedinthenexttopic.
Alpha-Beta Pruning in ai
Alpha-betapruningisamodifiedversionoftheminimaxalgorithm.Itis
anoptimizationtechniquefortheminimaxalgorithm.
Aswehaveseenintheminimaxsearchalgorithmthatthenumberof
gamestatesithastoexamineareexponentialindepthofthetree.Since
wecannoteliminatetheexponent,butwecancutittohalf.
Hencethereisatechniquebywhichwithoutcheckingeachnodeofthe
gametreewecancomputethecorrectminimaxdecision,andthis
techniqueiscalledpruning.
ThisinvolvestwothresholdparameterAlphaandbetaforfuture
expansion,soitiscalledalpha-betapruning.ItisalsocalledasAlpha-Beta
Algorithm.
Alpha-betapruningcanbeappliedatanydepthofatree,andsometimesit
notonlyprunethetreeleavesbutalsoentiresub-tree.
Alpha-Beta Pruning in ai
Thetwo-parametercanbedefinedas:
Alpha:Thebest(highest-value)choicewehavefoundsofaratanypoint
alongthepathofMaximizer.Theinitialvalueofalphais-∞.
Beta:Thebest(lowest-value)choicewehavefoundsofaratanypoint
alongthepathofMinimizer.Theinitialvalueofbetais+∞.
TheAlpha-betapruningtoastandardminimaxalgorithmreturnsthe
samemoveasthestandardalgorithmdoes,butitremovesallthenodes
whicharenotreallyaffectingthefinaldecisionbutmakingalgorithm
slow.
Hencebypruningthesenodes,itmakesthealgorithmfast.
Alpha-Beta Pruning in ai
ConditionforAlpha-betapruning:
Themainconditionwhichrequiredforalpha-betapruningis:
α>=β
Keypointsaboutalpha-betapruning:
TheMaxplayerwillonlyupdatethevalueofalpha.
TheMinplayerwillonlyupdatethevalueofbeta.
Whilebacktrackingthetree,thenodevalueswillbepassedtouppernodes
insteadofvaluesofalphaandbeta.
Wewillonlypassthealpha,betavaluestothechildnodes.
Working of Alpha -Beta Pruning:
Working ofAlpha-Beta
Pruning:
Let'stakeanexampleoftwo-player
searchtreetounderstandthe
workingofAlpha-betapruning
Step1:
Atthefirststepthe,Maxplayer
willstartfirstmovefromnodeA
whereα=-∞andβ=+∞,these
valueofalphaandbetapassed
downtonodeBwhereagainα=-∞
andβ=+∞,andNodeBpassesthe
samevaluetoitschildD.