Unit3:Informed and Uninformed search

2,527 views 181 slides Nov 22, 2020
Slide 1
Slide 1 of 181
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49
Slide 50
50
Slide 51
51
Slide 52
52
Slide 53
53
Slide 54
54
Slide 55
55
Slide 56
56
Slide 57
57
Slide 58
58
Slide 59
59
Slide 60
60
Slide 61
61
Slide 62
62
Slide 63
63
Slide 64
64
Slide 65
65
Slide 66
66
Slide 67
67
Slide 68
68
Slide 69
69
Slide 70
70
Slide 71
71
Slide 72
72
Slide 73
73
Slide 74
74
Slide 75
75
Slide 76
76
Slide 77
77
Slide 78
78
Slide 79
79
Slide 80
80
Slide 81
81
Slide 82
82
Slide 83
83
Slide 84
84
Slide 85
85
Slide 86
86
Slide 87
87
Slide 88
88
Slide 89
89
Slide 90
90
Slide 91
91
Slide 92
92
Slide 93
93
Slide 94
94
Slide 95
95
Slide 96
96
Slide 97
97
Slide 98
98
Slide 99
99
Slide 100
100
Slide 101
101
Slide 102
102
Slide 103
103
Slide 104
104
Slide 105
105
Slide 106
106
Slide 107
107
Slide 108
108
Slide 109
109
Slide 110
110
Slide 111
111
Slide 112
112
Slide 113
113
Slide 114
114
Slide 115
115
Slide 116
116
Slide 117
117
Slide 118
118
Slide 119
119
Slide 120
120
Slide 121
121
Slide 122
122
Slide 123
123
Slide 124
124
Slide 125
125
Slide 126
126
Slide 127
127
Slide 128
128
Slide 129
129
Slide 130
130
Slide 131
131
Slide 132
132
Slide 133
133
Slide 134
134
Slide 135
135
Slide 136
136
Slide 137
137
Slide 138
138
Slide 139
139
Slide 140
140
Slide 141
141
Slide 142
142
Slide 143
143
Slide 144
144
Slide 145
145
Slide 146
146
Slide 147
147
Slide 148
148
Slide 149
149
Slide 150
150
Slide 151
151
Slide 152
152
Slide 153
153
Slide 154
154
Slide 155
155
Slide 156
156
Slide 157
157
Slide 158
158
Slide 159
159
Slide 160
160
Slide 161
161
Slide 162
162
Slide 163
163
Slide 164
164
Slide 165
165
Slide 166
166
Slide 167
167
Slide 168
168
Slide 169
169
Slide 170
170
Slide 171
171
Slide 172
172
Slide 173
173
Slide 174
174
Slide 175
175
Slide 176
176
Slide 177
177
Slide 178
178
Slide 179
179
Slide 180
180
Slide 181
181

About This Presentation

Problem solving by Intelligent agent by searching


Slide Content

Unit 3: Informed and Uninformed Search LH 8
Presented By : Tekendra Nath Yogi
[email protected]
College Of Applied Business And Technology

Contd…
•Unit3:InformedandUninformedSearch LH8
–3.1WhysearchinAI?
–3.2Blindsearch(Un-informedsearch)
•3.2.1Breadthfirstsearch(BFS)
–Variations:Uniformcostsearch
•3.2.2Depthfirstsearch(DFS)
–Variations:Depthlimitedsearch,IterativedeepeningDFS
–3.3Heuristicsearch(Informedsearch)
•3.3.1Hillclimbing
–TheFoothillsProblem
–ThePlateauProblem
–TheRidgeProblem
•3.3.2Greedy(Best-first)search
•3.3.3A*algorithmsearch
•3.3.4Means-EndsAnalysis:HouseholdROBOT,MonkeyBananaProblem
212/25/2018 By: Tekendra Nath Yogi

Contd…
•Unit3:InformedandUninformedSearchcontd…
–3.4GeneralProblemSolving(GPS):Problemsolvingagents
•3.4.1Constraintsatisfactionproblem
–ConstraintSatisfactionSearch
–AND/ORtrees
–Thebidirectionalsearch
–Crypto-arithmatics
–3.5GameplayingandAI
•3.2.1GameTreesandMini-maxEvaluation
•3.2.2HeuristicEvaluation
•3.2.3Min-maxalgorithm(search)
•3.2.4Min-maxwithalpha-beta
•3.2.5Gamesofchance
•3.2.6Gametheory
312/25/2018 By: Tekendra Nath Yogi

Four General steps in problem solving
•Problemsolvingisasystematicsearchthrougharangeofpossibleactionsin
ordertoreachsomepredefinedgoalorsolution.
•Forproblemsolvingakindofgoalbasedagentcalledproblemsolvingagents
areused.
•Thisagentfirstformulatesagoalandaproblem,searchesforasequenceof
actionsthatwouldsolvetheproblem,andthenexecutestheactionsoneata
time.Whenthisiscomplete,itformulatesanothergoalandstartsover.
•Thisoverallprocessisdescribedinthefollowingfoursteps:
–Goalformulation
–Problemformulation
–Search
–Execute
412/25/2018 By: Tekendra Nath Yogi

Contd…
•Goalformulation:
–Intelligentagentmaximizetheirperformancemeasurebyadaptingagoal
andaimatsatisfyingit.
–Goalhelporganizebehaviorbylimitingtheobjectivesthattheagentis
tryingtoachieveandhencetheactionsitneedstoconsider.
–Goalarethesetofworldstatesinwhichthegoalissatisfied.
–Therefore,duringgoalformulationstep,specifywhatarethesuccessful
worldstates.
512/25/2018 By: Tekendra Nath Yogi

Contd…
•ProblemFormulation:
–Problemformulationistheprocessofdecidingwhatactionsandstatesto
consider,givenagoal.
–Therefore,theagent‟staskistofindouthowtoact,nowandinthefuture,
sothatitreachesagoalstate.
–Beforeitcandothis,itneedstodecide(orweneedtodecideonits
behalf)whatsortsofactionsandstatesitshouldconsider.
612/25/2018 By: Tekendra Nath Yogi

Contd…
•Searchasolution:
–Theprocessoflookingforasequenceofactionsthatreachesthegoalis
calledasearching.
–searchalgorithmtakesaproblemasainputandreturnsasolutioninthe
formofanactionsequence.
712/25/2018 By: Tekendra Nath Yogi

Contd…
•Execution:
–onceasolutionisfound,theactionsitrecommendscanbecarriedout.
Thisiscalledtheexecutionphase.
–onceasolutionhasbeenexecuted,theagentwillformulateanewgoal.
812/25/2018 By: Tekendra Nath Yogi

Problem Formulation
•A problem can be defined formally by five components:
–Initial state
–Actions
–Transition model
–Goal Test
–Path Cost
912/25/2018 By: Tekendra Nath Yogi

Contd…
•Initialstate:Thestatefromwhichagentstart.
•Actions:Adescriptionofthepossibleactionsavailabletotheagent.During
problemformulationweshouldspecifytheallpossibleactionsavailablefor
eachstate„s‟.
•Transitionmodel:Adescriptionofwhateachactiondoesiscalledthe
transitionmodel.Forformulatingtransitionmodelinproblemformulationwe
takestate„s‟andaction„a‟forthatstateandthenspecifytheresultingstate
„s‟
•GoalTest:Determinewhetherthegivenstateisgoalstateornot.
•PathCost:Sumofcostofeachpathfrominitialstatetothegivenstate
1012/25/2018 By: Tekendra Nath Yogi

One way to formally define a problem: State space Representation
•Thesetofallstatesreachablefromtheinitialstatebyanysequenceofactionsis
calledstatespace.
•Thestatespaceformsadirectedgraphinwhichnodesarestatesandthelinks
betweennodesareactions.
•AStatespacerepresentationallowsfortheformaldefinitionofaproblemwhich
makesthemovementfrominitialstatetogoalstatequiteeasy.
•Disadvantage:itisnotpossibletovisualizeallstatesforagivenproblem.Also,
theresourcesofthecomputersystemarelimitedtohandlehugestatespace
representation.
1112/25/2018 By: Tekendra Nath Yogi

Contd…
•StateSpacerepresentationofVacuumWorldProblem:Vacuumworld
canbeformulatedasaproblemasfollows:
–States:Thestateisdeterminedbyboththeagentlocationandthedirtlocations.The
agentisinoneoftwolocations,eachofwhichmightormightnotcontaindirt.
–Initialstate:Anystatecanbedesignatedastheinitialstate.
–Actions:Inthissimpleenvironment,eachstatehasjustthreeactions:Left,Right,
andSuck.LargerenvironmentmaymightalsoincludeUpandDown.
–TransitionModel:Theactionshavetheirexpectedeffects,exceptthatmoving
Leftinleftmostsquare,movingRightintherightmostsquare,andsuckingina
cleansquarehavingnoeffect.Thecompletestatespaceisshowninfigurebelow.
–GoalTest:Thischeckswhetherallthesquaresareclean.
–Pathcost:Eachstepcosts1,sothepathcostisthenumberofstepsinthepath.
1212/25/2018 By: Tekendra Nath Yogi

Contd…
1312/25/2018 By: Tekendra Nath Yogi
Fig: State space representation for the vacuum world
Here, links denote actions: L: left, R= Right, S= Suck

Searching For Solution
•Havingformulatedsomeproblems,wenowneedtosolvethem.
•Tosolveaproblemweshouldperformasystematicsearchthrougharangeof
possibleactionsinordertoreachsomepredefinedgoalorsolution.
•Asolutionisanactionsequence,sosearchalgorithmsworksbyconsidering
variouspossibleactionsequences.
•Thepossibleactionsequencesstartingattheinitialstateformasearchtree
withtheinitialstateattheroot;thebranchesareactionsandthenodes
correspondtostatesinthestatespaceoftheproblem.
1412/25/2018 By: Tekendra Nath Yogi

Contd…
•Generalsearch:
–Thesearchingprocessstartsfromtheinitialstate(rootnode)and
proceedsbyperformingthefollowingsteps:
•Checkwhetherthecurrentstateisthegoalstateornot?
•Expand the current state to generate the new sets of states.
•Choose one of the new states generated for search depending upon search
strategy.
•Repeat step 1 to 3 until the goal state is reached or there are no more state to
be expanded.
1512/25/2018 By: Tekendra Nath Yogi

Contd…
•TheImportanceofSearchinAI:
–ManyofthetasksunderlyingAIcanbephrasedintermsofasearchfor
thesolutiontotheproblemathand.
–Manygoalbasedagentsareessentiallyproblemsolvingagentswhich
mustdecidewhattodobysearchingforasequenceofactionsthatleadto
theirsolutions.
–Fortheproductionsystems,needtosearchforasequenceofrule
applicationsthatleadtotherequiredfactoraction.
–Forneuralnetworksystems,needtosearchforthesetofconnection
weightsthatwillresultintherequiredinputtooutputmapping.
1612/25/2018 By: Tekendra Nath Yogi

Contd…
•MeasuringproblemSolvingPerformance:
–Theperformanceofthesearchalgorithmscanbeevaluatedinfourways:
–Completeness:Analgorithmissaidtobecompleteifitdefinitelyfinds
solutiontotheproblem,ifexist.
–Timecomplexity:Howlongdoesittaketofindasolution?Usually
measuredintermsofthenumberofnodesexpandedduringthesearch.
–SpaceComplexity:Howmuchspaceisusedbythealgorithm?Usually
measuredintermsofthemaximumnumberofnodesinmemoryatatime
–Optimality/Admissibility:Ifasolutionisfound,isitguaranteedtobean
optimalone?Forexample,isittheonewithminimumcost?
1712/25/2018 By: Tekendra Nath Yogi

Classes of Search methods
•Therearetwobroadclassesofsearchmethods:
•Uninformed(orblind)searchmethods:
–Strategieshavenoadditionalinformationaboutstatesbeyondthatprovidedin
theproblemdefinition.Alltheycandoisgeneratesuccessorsanddistinguisha
goalstatefromanon-goalstate.
–Allsearchstrategiesaredistinguishedbytheorderinwhichnodesareexpanded.
•Heuristicallyinformedsearchmethods.
–Strategiesthatknowwhetheronenon-goalstateis“morepromising”thananother
arecalledinformedorheuristicsearchstrategies.
–I.e.,Inthecaseoftheheuristicallyinformedsearchmethods,oneusesdomain-
dependent(heuristic)informationinordertosearchthespacemoreefficiently.
1812/25/2018 By: Tekendra Nath Yogi

Uninformed (Or Blind) Search Methods:
•Blindsearchdonothaveadditionalinformationaboutstatebeyondthe
problemdefinitiontosearchasolutioninthesearchspace.
•Itproceedssystematicallybyexploringnodeseitherrandomlyorin
somepredeterminedorder.
•Basedontheorderinwhichnodesareexpanded,itisofthefollowing
types:
–BreadthFirstsearch(BFS)
•Variation:Uniformcostsearch
–DepthFirstsearch(DFS)
•Variations:Depthlimitsearch,IterativedeepeningDFS.
–Bidirectionalsearch
19Presented By: Tekendra Nath YogiIT 228 -Intro to AI

Breadth First Search
•BreadthFirstsearchisasimplestrategyinwhichtherootnodeisexpanded
first,thenallthesuccessorsoftherootnodeareexpandednext,thentheir
successors,andsoon.
•Ingeneral,Allnodesareexpendedatagivendepthinthesearchtreebefore
anynodesatthenextlevelareexpandeduntilthegoalreached.
–I.e.,Expandshallowestunexpendednode.
•The search tree generated by the BFS is shown in figure below:
Fig: search Tree For BFS
Note: We are using the convention that the alternatives are tried in the left to right
order.
20Presented By: Tekendra Nath YogiIT 228 -Intro to AI

Breadth-first search
21Presented By: Tekendra Nath YogiIT 228 -Intro to AI

Breadth-first search
22Presented By: Tekendra Nath YogiIT 228 -Intro to AI

Breadth-first search
23Presented By: Tekendra Nath YogiIT 228 -Intro to AI

Uniform Cost Search
•Thesearchbeginsatrootnode.Thesearchcontinuesbyvisitingthenextnode
whichhastheleasttotalcostfromtherootnode.Nodesarevisitedinthis
manneruntilagoalisreached.
•Nowgoalnodehasbeengenerated,butuniformcostsearchkeepsgoing,
choosinganode(withlesstotalcostfromtherootnodetothatnodethanthe
previouslyobtainedgoalpathcost)forexpansionandaddingasecondpath.
•Nowthealgorithmcheckstoseeifthisnewpathisbetterthantheoldone;ifit
issotheoldoneisdiscardedandnewoneisselectedforexpansionandthe
solutionisreturned.
24Presented By: Tekendra Nath YogiIT 228 -Intro to AI

Uniform cost search example1 (Find path from A to E)
•Expand A to B,C,D
•The path to B is the cheapest one with path cost 2.
•Expand B to E
–Total path cost = 2+9 =11
•This might not be the optimal solution since the path
AC as path cost 4 ( less than 11)
•Expand C to E
–Total path cost = 4+5 =9
•Path cost from A to D is 10 ( greater than path cost, 9)
Hence optimal path is ACE
25Presented By: Tekendra Nath YogiIT 228 -Intro to AI

•Thegraphbelowshowsthestep-costs
fordifferentpathsgoingfromthe
start(S)tothegoal(G).
•Useuniformcostsearchtofindthe
optimalpathtothegoal.
Presented By: Tekendra Nath Yogi 26
Home work: Uniform cost search
IT 228 -Intro to AI

Depth First Search
•DFSalsobeginsbyexpandingtheinitialnode.
•Looksforthegoalnodeamongallthechildrenofthecurrentnodebeforeusing
thesiblingofthisnode
•i.e.expanddeepestunexpandednode(expandmostrecentlygenerateddeepest
nodefirst.).
•The search tree generated by the DFS is shown in figure below:
27Presented By: Tekendra Nath YogiIT 228 -Intro to AI

Depth-first search example
•Expand deepest unexpanded node
•Here initial state is A and goal state is M
28Presented By: Tekendra Nath YogiIT 228 -Intro to AI

Depth-first search example
•Expand deepest unexpanded node
29Presented By: Tekendra Nath YogiIT 228 -Intro to AI

Depth-first search example
•Expand deepest unexpanded node
30Presented By: Tekendra Nath YogiIT 228 -Intro to AI

Depth-first search example
•Expand deepest unexpanded node
31Presented By: Tekendra Nath YogiIT 228 -Intro to AI

Depth-first search example
•Expand deepest unexpanded node
32Presented By: Tekendra Nath YogiIT 228 -Intro to AI

Depth-first search example
•Expand deepest unexpanded node
33Presented By: Tekendra Nath YogiIT 228 -Intro to AI

Depth-first search example
•Expand deepest unexpanded node
34Presented By: Tekendra Nath YogiIT 228 -Intro to AI

Depth-first search example
•Expand deepest unexpanded node
35Presented By: Tekendra Nath YogiIT 228 -Intro to AI

Depth-first search example
•Expand deepest unexpanded node
36Presented By: Tekendra Nath YogiIT 228 -Intro to AI

Depth-first search example
•Expand deepest unexpanded node
37Presented By: Tekendra Nath YogiIT 228 -Intro to AI

Depth-first search example
•Expand deepest unexpanded node
38Presented By: Tekendra Nath YogiIT 228 -Intro to AI

Depth-first search example
•Expanddeepestunexpandednode
•Butthistypeofsearchcangoonandon,deeperanddeeperintotree
searchspaceandthus,wecangetlost.Thisisreferredtoasblindalley.
39Presented By: Tekendra Nath YogiIT 228 -Intro to AI

Presented By: TekendraNath Yogi 40
Depth-limited search(Same as DFS if L= ∞)
•Depthlimitsearchisdepth-firstsearchwithdepthlimitL.
–i.e.,nodesatdepthLaretreatedastheyhavenosuccessors.
•ThedepthlimitsolvestheinfinitepathproblemofDFSbyplacinglimitonthe
depth.
•Yetitintroducesanothersourceofproblemifweareunabletofindgoodguess
ofL.Letdisthedepthofshallowestsolution.
–IfL<dthenincompletenessresultsbecausenosolutionwithinthedepthlimit.
–IfL>dthennotoptimal.
IT 228 -Intro to AI

Presented By: Tekendra Nath Yogi 41
Depth-limited search Example 1
•Depth limited search= DFS+ limit for the depth
–Let goal node= 11 and limit= 2
–Trace the path to the goal node using Depth limited search .
IT 228 -Intro to AI

Presented By: Tekendra Nath Yogi 42
Depth-limited search Example 1
•Depth limited search= DFS+ limit for the depth
•No path is found from root node to goal node because L< d.
IT 228 -Intro to AI

Iterative deepening search
•ItisageneralstrategytofindbestdepthlimitL.
•ItbeginbyperformingDFStoadepthofzero,thendepthofone,depthof
two,andsoonuntilasolutionisfoundorsomemaximumdepthisreached.
•ItissimilartoBFSinthatitexploresacompletelayerofnewnodesateach
iterationbeforegoingtonextlayer.
•ItissimilartoDFSforasingleiteration.
•Itispreferredwhenthereisalargesearchspaceandthedepthofasolutionis
notknown.
•Butitperformsthewastedcomputationbeforereachingthegoaldepth.
4312/25/2018 By: Tekendra Nath Yogi

Iterative Deepening search example
•Here initial state is A and goal state is M.
•Let we don‟t know the depth of M then the Iterative deepening search proceeds
as follows:
44Presented By: TekendraNath YogiIT 228 -Intro to AI

Presented By: Tekendra Nath Yogi 45
Iterative deepening search l =0
IT 228 -Intro to AI

Presented By: Tekendra Nath Yogi 46
Iterative deepening search l =1
IT 228 -Intro to AI

Presented By: TekendraNath Yogi 47
Iterative deepening search l =2
IT 228 -Intro to AI

Presented By: TekendraNath Yogi 48
Iterative deepening search l =3
IT 228 -Intro to AI

Bidirectional search
•Thissearchisusedwhenaproblemhasasinglegoalstatethatisgiven
explicitlyandallthenodegenerationoperatorshaveinverses.
•Soitisusedtofindshortestpathfromaninitialnodetogoalnode
insteadofgoalitselfalongwithpath.
•Itworksbysearchingforwardfromtheinitialnodeandbackwardfrom
thegoalnodesimultaneously,byhopingthattwosearchesmeetinthe
middle.
•Checkateachstageifthenodesofonehavebeengeneratedbythe
other,.i.e.,theymeetinthemiddle.
•Ifso,thepathconcatenationisthesolution.
Presented By: Tekendra Nath Yogi 49IT 228 -Intro to AI

Bidirectional search contd..
•Advantages:
–OnlyslightmodificationofDFSand
BFScanbedonetoperformthis
search.
–Theoreticallyeffectivethan
unidirectionalsearch.
•Disadvantage:
–Problemiftherearemanygoalstates.
–Practicallyinefficientduetoadditional
overheadtoperformintersection
operationateachpointofsearch
Presented By: Tekendra Nath Yogi 50IT 228 -Intro to AI

Drawbacks of uninformed search :
•Criteriontochoosenextnodetoexpanddependsonlyonaglobalcriterion:
level.
•Doesnotexploitthestructureoftheproblem.
51Presented By: Tekendra Nath YogiIT 228 -Intro to AI

Heuristic Search:
•HeuristicSearchUsesdomain-dependent(heuristic)informationbeyondthe
definitionoftheproblemitselfinordertosearchthespacemoreefficiently.
•Waysofusingheuristicinformation:
–Decidingwhichnodetoexpandnext,insteadofdoingtheexpansioninastrictly
breadth-firstordepth-firstorder;
–Inthecourseofexpandinganode,decidingwhichsuccessororsuccessorsto
generate,insteadofblindlygeneratingallpossiblesuccessorsatonetime;
–Decidingthatcertainnodesshouldbediscarded,orpruned,fromthesearch
space.
5212/25/2018 By: Tekendra Nath Yogi

Contd…
•InformedSearchDefineaheuristicfunction,h(n),thatestimatesthe
"goodness"ofanoden.
•Theheuristicfunctionisanestimate,basedondomain-specificinformation
thatiscomputablefromthecurrentstatedescription,ofhowclosewearetoa
goal.
•Specifically,h(n)=estimatedcost(ordistance)ofminimalcostpathfrom
state„n‟toagoalstate.
5312/25/2018 By: Tekendra Nath Yogi

Contd…
•A) Best-First Search:
–Best first searchuses an evaluation function f(n) that gives an indication
of which node to expand next for each node.
–Akeycomponentoff(n)isaheuristicfunction,h(n),whichisaadditional
knowledgeoftheproblem.
–Basedontheevaluationfunctionbestfirstsearchcanbecategorizedinto
thefollowingcategories:
•Greedybest-firstsearch
•A*search
5412/25/2018 By: Tekendra Nath Yogi

Contd…
•Greedy Best First Search :
–Greedybestfirstsearchexpandsthenodethatseemstobeclosesttothe
goalnode.
–EvaluationfunctionbasedonHeuristicfunctionisusedtoestimate
whichnodeisclosesttothegoalnode.
–Therefore,Evaluationfunctionf(n)=heuristicfunctionh(n)=estimated
costofthepathfromnodentothegoalnode.
–E.g.,h
SLD(n)=straight-linedistancefromntogoal
–Note:g(root)=0andh(goal)=0
5512/25/2018 By: Tekendra Nath Yogi

Contd…
•Example1ToillustrateGreedyBest-FirstSearch:
–For example consider the following graph
–Straight Line distances to node G (goal node) from other nodes is given below:
–Let H(n)= Straight Line distance
–Now Greedy Search operation is done as below:
5612/25/2018 By: Tekendra Nath Yogi

Contd…
•Start at node „s‟, the start state
•Children of s= {B(4), D(5)}
•Therefore, best = B
5712/25/2018 By: Tekendra Nath Yogi

Contd…
•Children of B= {E(7), C(3)}
•Considered= {D(5), E(7), C(3)}
•Therefore, Best= C
5812/25/2018 By: Tekendra Nath Yogi

Contd…
•Children of C= {D(5), G(0)}
•Considered= {D(5), E(7), G(0)}
•Therefore, Best= G, is the goal node.
5912/25/2018 By: Tekendra Nath Yogi

Contd…
•A * Search :
–A*isabestfirst,informedsearchalgorithm.Thesearchbeginsatrootnode.
Thesearchcontinuesbyvisitingthenextnodewhichhastheleast
evaluation.
–Itevaluatesnodesbyusingthefollowingevaluationfunction
•f(n)=h(n)+g(n)=estimatedcostofthecheapestsolutionthroughn.
•Where,g(n):theactualshortestdistancetraveledfrominitialnodetocurrent
node,Ithelpstoavoidexpandingpathsthatarealreadyexpensive
•h(n):theestimated(or"heuristic")distancefromcurrentnodetogoal,itestimate
whichnodeisclosesttothegoalnode.
–Nodesarevisitedinthismanneruntilagoalisreached.
6012/25/2018 By: Tekendra Nath Yogi

Contd…
•ExampletoillustrateA*Search:
–For example consider the following graph
–Straight Line distances to node G (goal node) from other nodes is given
below:
–Labels in the graph shows actual distance.
–Let H(n)= Straight Line distance
–Now A* Search operation is done as below
6112/25/2018 By: Tekendra Nath Yogi

Contd…
•A* algorithm starts at s, the start state.
•Children of S={B, D}
•Now, evaluation function for each child of S is:
–f(B) =g(B) + h(B) =9+4=13
–f(D)=g(D)+h(D)= 8+6=14
•Here, candidate node for expansion are{B, D}, among these candidate nodes
the node B is least evaluated, so it is selected for expansion.
6212/25/2018 By: Tekendra Nath Yogi

Contd…
•Child of B ={E, C}
•Now, evaluation for each child of B are
–F(E)= (9+8)+7=24
–F(c)=(9+7)+3=19
•Here, candidate nodes for expansion are{E,C, and D}
•Among these candidate the node D is least evaluated, so it is selected for expansion
63Presented By: Tekendra Nath Yogi
f(n)= 14H(n)= 4
IT 228 -Intro to AI

Contd….
•Child of D={G, C}
Evaluation for the child of D are
•Here, the candidate nodes for expansion are{ E, C,G and C}.
•Among these candidate the node C child of D is least
evaluated, so It is selected for expansion.
64Presented By: Tekendra Nath Yogi
H(n)= 6
IT 228 -Intro to AI

Contd…
•Child of C= {G,B}
Evaluation for the child of C are
•Here the candidate for expansion are{E,C,G,G, and B}.
•Among these candidate the node G, which is child of D is least evaluated, so
it is selected for expansion, but it is the goal node, hence we are done
65Presented By: Tekendra Nath Yogi
H(n)= 6
H(n)= 3
IT 228 -Intro to AI

Contd…
66Presented By: Tekendra Nath Yogi
H(n)= 6
H(n)= 3
IT 228 -Intro to AI

Contd…
•B)Localsearchalgorithms:
–Localsearchalgorithmsoperateusingasinglecurrentnodeandmove
onlytoneighborsofthisnoderatherthansystematicallyexploringpaths
fromaninitialstate.E.g.Hillclimbing.
–Thesealgorithmsaresuitableforproblemsinwhichallthatmatteristhe
solutionstate,notthepathcosttoreachit.Typically,thepathsfollowed
bythesearcharenotretained.
–Althoughlocalsearchalgorithmsarenotsystematic,theyhavetwokey
advantages:
•Theyuseverylittlememory.
•Theycanoftenfindreasonablesolutionsinlargeorinfinitestatespacesfor
whichsystematicalgorithmsareunsuitable.
6712/25/2018 By: Tekendra Nath Yogi

Contd…
•HillClimbingSearch:
–Hillclimbingcanbeusedtosolveproblemsthathavemanysolutions,
someofwhicharebetterthanothers.
–Itstartswitharandom(potentiallypoor)solution,anditerativelymakes
smallchangestothesolution,eachtimeimprovingitalittle.Whenthe
algorithmcannotseeanyimprovementanymore,itterminates.
–Ideally,atthatpointthecurrentsolutionisclosetooptimal,butitisnot
guaranteedthathillclimbingwillevercomeclosetotheoptimalsolution.
–Note:Thealgorithmdoesnotmaintainasearchtreeanddoesnotlook
aheadbeyondtheimmediateneighborsofthecurrentstate.
6812/25/2018 By: Tekendra Nath Yogi

Contd…
6912/25/2018 By: Tekendra Nath Yogi

Contd…
•Hillclimbingsuffersfromthefollowingproblems:
–TheFoot-hillsproblem(localmaximum)
–ThePlateauproblem
–TheRidgeproblem
7012/25/2018 By: Tekendra Nath Yogi

Contd…
•Foot-Hillproblem:
–Localmaximumisastatewhichisbetterthanallofitsneighborsbutis
notbetterthansomeotherstateswhicharefartheraway.
–Atlocalmaxima,allmovesappeartomakethethingsworse.
–Thisproblemiscalledthefoothillproblem.
–Solution:Backtracktosomeearliernodeandtrygoingtodifferent
direction.
7112/25/2018 By: Tekendra Nath Yogi

Contd…
•ThePlateauproblem:
–Plateauisaflatareaofthesearchspaceinwhichawholesetof
neighboringstateshavethesamevalue.
–Onplateau,itisnotpossibletodeterminethebestdirectioninwhichto
movebymakinglocalcomparison.
–Suchaproblemiscalledplateauproblem.
–Solution:Makeabigjumpinsomedirectiontotrytogetanewsection
ofthesearchspace.
7212/25/2018 By: Tekendra Nath Yogi

Contd…
•TheRidgeproblem:
–Ridgeisanareaofthesearchspacewhichishigherthanthesurroundingareas
andthatitselfhasaslope.
–Duetothesteepslopesthesearchdirectionisnottowardsthetopbuttowardsthe
side(oscillatesfromsidetoside).
–SuchaproblemiscalledRidgeproblem.
•Solution:Applytwoormorerulessuchasbi-directionsearchbeforedoing
thetest.
7312/25/2018 By: Tekendra Nath Yogi

Mean-End Analysis
•Meanendanalysisisaproblemsolvingtechnique.Allowsustosolvethemajor
partsofaproblemfirstandthengobackandsolvethesmallerproblemsthat
arisewhileassemblingthefinalsolution.
•Technique:
–TheMeanEndanalysisprocessfirstdetectsthedifferencesbetweencurrent
stateandthegoalstate.
–Oncesuchadifferenceisisolated,anoperatorthatcanreducethedifference
hastobefound.
–Butsometimesitisnotpossibletoapplythisoperatortothecurrentstate.
So,wetrytogetasub-problemoutofitandtrytoapplyouroperatortothis
newstate.
–Ifthisalsodoesnotproducethedesiredgoalstatethenwetrytogetsecond
sub-problemandapplythisoperatoragain.Thisprocessmaybecontinued.
7412/25/2018 By: Tekendra Nath Yogi

Contd…
•Problem:
•Solution:
7512/25/2018 By: Tekendra Nath Yogi

Contd…
•Whyitiscalledmeanendanalysis?
–Givenadescriptionofthedesiredstateoftheworld(theend).
–Itworksbyselectingandusingoperatorsthatwillachieveit(themeans).
–Hencethename,meanendanalysis(MEA).
7612/25/2018 By: Tekendra Nath Yogi

Contd…
•MeanEndAnalysis(HouseholdRobot):
–Considerasimplehouseholdrobotdomain.ProblemGiventotherobot
is:Moveadeskwithtwothingsonitfromoneroomtoanother.The
objectsontopmustalsobemoved.
7712/25/2018 By: Tekendra Nath Yogi

Contd…
•Theavailableoperatorsareshownbelowalongwiththeirpre-conditionsandresults.
•Tablebelowshowswheneachoftheoperatorsisappropriate:
7812/25/2018 By: Tekendra Nath Yogi

Contd…
Therobotsolvesthisproblemasfollows:
•Themaindifferencebetweentheinitialstateandthegoalstatewouldbethe
locationofthedesk.
•Toreducethisdifference,eitherPUSHorCARRYcouldbechosen.
•IfCARRYischosenfirst,itspreconditionsmustbemet.Thisresultsintwo
moredifferencesthatmustbereduced:
–Thelocationoftherobotandthesizeofthedesk.
–ThelocationoftherobotishandledbyapplyingWALK,butthereareno
operatorsthatcanchangethesizeofanobject,Sothispathleadstoadead-end.
7912/25/2018 By: Tekendra Nath Yogi

Contd…
•Followingtheotherbranch,weattempttoapplyPUSH.Figurebelowshows
therobot‟sprogressatthispoint.
Fig:Theprogressofmeanendanalysismethod.
•NowthedifferencesbetweenAandBandBetweenCandDmustbereduced.
8012/25/2018 By: Tekendra Nath Yogi

Contd…
•PUSHhaspreconditions:
–therobotmustbeatthedesk,and
–thedeskmustbeclear.
•TherobotcanbebroughttothecorrectlocationbyusingWALK.
•AndthesurfaceofthedeskcanbeclearedbytwousesofthePICKUP,.
•ButafteronePICKUP,Anattempttodothesecondresultsinanother
difference(thearmmustbeempty).
•PUTDOWNcanbeusedtoreducethedifference.
8112/25/2018 By: Tekendra Nath Yogi

Contd…
•OncePUSHisperformed,theproblemstateisclosedtothegoalstate,butnot
quite.Theobjectmustbeplacedbackonthedesk.PLACEwillputthem
there.Theprogressoftherobotatthispointisasshowninfigurebelow:
Fig:Moreprogressonthemeanendanalysismethod.
•ThefinaldifferencebetweenCandEcanbereducedbyusingWALKtoget
therobotbacktotheobjectfollowedbyPICKUPandCARRY.
8212/25/2018 By: Tekendra Nath Yogi

Contd…
•Mean-EndAnalysis:(MonkeyBananaProblem):
–ThemonkeyisinaclosedroominwhichthereisasmallBox.
–Thereisabunchofbananashangingfromtheceilingbutthemonkeycannotreach
them.
–AssumingthatthemonkeycanmovetheBoxandifthemonkeystandsontheBox
themonkeycanreachthebananas.
–Establishamethodtoinstructthemonkeyonhowtocapturethebananas.
8312/25/2018 By: Tekendra Nath Yogi

Contd…
•RepresentingtheWorld:
–IntheMonkeyBananaproblemwehave:
•objects:amonkey,abox,thebananas,andafloor.
•locations:we‟llcallthema,b,andc.
•relationsofobjectstolocations.Forexample:
–themonkeyisatlocationa;
–themonkeyisonthefloor;
–thebananasarehanging;
–theboxisinthesamelocationasthebananas.
–FormallyRepresentingtherelationsofobjectstolocationsas:
–at(monkey,a).
–on(monkey,floor).
–status(bananas,hanging).
–at(box,X),at(bananas,X).
8412/25/2018 By: Tekendra Nath Yogi

Contd…
•InitialState:
at(monkey,a),
on(monkey,floor),
at(box,b),
on(box,floor),
at(bananas,c),
status(bananas,hanging).
•GoalState:
on(monkey,box),
on(box,floor),
at(monkey,c),
at(box,c),
at(bananas,c),
status(bananas,grabbed).
8512/25/2018 By: Tekendra Nath Yogi

Contd…
•AllOperators:
8612/25/2018 By: Tekendra Nath Yogi
OperatorPreconditions Results
go(X,Y) at(monkey,X) at(monkey, Y)
on(monkey, floor)
push(B,X,Y)at(monkey,X) at(monkey, Y)
at(B,X) at(B,Y)
on(monkey, floor)
on(B,floor)
climb_on(B)at(monkey,X) on(monkey, B)
at(B,X)
on(monkey,floor)
on(B,floor)
grab(B) on(monkey,box) status(B, grabbed)
at(box,X)
at(B,X)
status(B, hanging)

Contd…
•InstructionsTotheMonkeytoGrabthebanana:
–FirstofallMonkeyshouldmoveformlocationatolocationb.
•Go(a,b)
–ThenpushtheBoxformlocationbtolocationa.
•Push(B,b,a)
–PushtheBoxagainfromlocationatolocationc.
•Push(B,a,c)
–MonkeyshouldclimbontheBox
•Climb_on(B)
–ThenGrabthebanana.
•Grab(B)
8712/25/2018 By: Tekendra Nath Yogi

Constraint satisfaction problems
•ACSPconsistsofthreecomponents:X,DandC
–XisaFinitesetofvariables{X
1,X
2,…,X
n}
–DisasetofNonemptydomainofpossiblevaluesforeachvariable{D
1,
D
2,…D
n}
–CisaFinitesetofconstraints{C
1,C
2,…,C
m}
–EachconstraintC
ilimitsthevaluesthatvariablescantake,e.g.,X
1≠X
2
8812/25/2018 By: Tekendra Nath Yogi

Contd…
•InCSP:
–State:Astateisdefinedasanassignmentofvaluestosomeorall
variables.
–Consistentassignment:consistentassignmentisanassignmentthatdoes
notviolatetheconstraints.
–Anassignmentiscompletewheneveryvariableisassignedavalue.
–AsolutiontoaCSPisacompleteassignmentthatsatisfiesallconstraints
i.e.,completeandconsistentassignment.
8912/25/2018 By: Tekendra Nath Yogi

Contd…
•Example(Map-Coloringproblem):Given,amapofAustraliashowing
eachofstatesandterritories.Thetaskiscoloreachregioneitherred,green,
orblueinsuchawaythatnoneighboringregionshavethesamecolor.
9012/25/2018 By: Tekendra Nath Yogi
•ThisproblemcanbeformulatedasCSPas
follows:
–Variables:WA,NT,Q,NSW,V,SA,T
–Domains:D
i={red,green,blue}
–Constraints:adjacentregionsmusthavedifferent
colors
•e.g.,WA≠NT

Contd…
•Solutionsare completeand consistentassignments,
–e.g., WA = red, NT = green, Q = red, NSW = green, V = red, SA = blue,
T = green
9112/25/2018 By: Tekendra Nath Yogi

Contd…
•CSPasastandardsearchproblem:
–ACSPcaneasilyexpressedasastandardsearchproblem,as
follows:
•InitialState:theemptyassignment{},inwhichallvariablesare
unassigned..
•Successorfunction:Assignvaluetounassignedvariableprovidedthat
thereisnotconflict.
•Goaltest:thecurrentassignmentiscompleteandconsistent.
•Pathcost:aconstantcostforeverystep.
9212/25/2018 By: Tekendra Nath Yogi

Contd…
•Constraintsatisfactionsearch:
–ForsearchingasolutionofCSPsfollowingalgorithmscanbeused:
•Backtrackingsearch:Worksonpartialassignments.
•LocalsearchforCSPs:worksoncompleteassignment.
9312/25/2018 By: Tekendra Nath Yogi

Contd…
•Backtrackingsearch:
–Thetermbacktrackingsearchisusedforadepthfirstsearchthatchooses
valuesforonevariableatatimeandbacktrackswhenavariablehasno
legalvalueslefttoassign.
–Thealgorithmrepeatedlychooseanunassignedvariable,andthentriesall
valuesinthedomainofthatvariableinturn,tryingtofindasolution.
–Ifaninconsistencyisdetected,thenbacktrackreturnsfailure,causingthe
previouscalltotrytoanothervalues.
9412/25/2018 By: Tekendra Nath Yogi

95
Backtracking example
Presented By: Tekendra Nath YogiIT 228 -Intro to AI

96
Backtracking example
Presented By: Tekendra Nath YogiIT 228 -Intro to AI

97
Backtracking example
Presented By: Tekendra Nath YogiIT 228 -Intro to AI

98
Backtracking example
Presented By: Tekendra Nath YogiIT 228 -Intro to AI

Contd…
•LocalsearchforCSPs:
–Theyuseacompletestateformulation:
•Theinitialstateassignsavaluetoeveryvariable,andthesearch
changesthevalueofonevariableatatimebecausetheinitialguess
violatesseveralconstraints.
–E.g.:
•Firstrandomlyselectanyconflictedvariable.
•Thenchoosethevalueofthatconflictedvariablethatviolatesthe
fewestconstraints.
9912/25/2018 By: Tekendra Nath Yogi

Crypt-arithmetic Problem
•ManyproblemsinAIcanbeconsideredasproblemsofconstraintsatisfaction,
inwhichthegoalstatesatisfiesagivensetofconstraint.
ExampleofsuchaproblemisCrypt-Arithmeticproblem(amathematical
puzzle),inwhichthegoalstate(solution)satisfiesthefollowingconstraints:
–Valuesaretobeassignedtolettersfrom0to9only.
–Notwolettersshouldhavethesamevalue.
–Ifthesameletteroccursmorethanonce,itmustbeassignedthesamedigiteach
time.
–Thesumofthedigitsmustbearithmeticallycorrectwiththeaddedrestrictionthat
noleadingzeroesareallowed.
10012/25/2018 By: Tekendra Nath Yogi

Contd…
•Example1: Solve the following puzzle by assigning numeral (0-9) in such a
way that each letter is assigned unique digit which satisfy the following
addition.
10112/25/2018 By: Tekendra Nath Yogi

Contd…
•Solution:Here,
•Variables:{F, T, U, W, R, O, c
1,c
2, C3 }
•Domains: {0,1,2,3,4,5,6,7,8,9}
•Constraints: Alldiff(F,T,U,W,R,O)
•where c1, c2, and c3 are auxiliary variables representing the digit (0 or 1) carried over
into the next column.
10212/25/2018 By: Tekendra Nath Yogi
c3 c2 c1

Contd…
•Hereweareaddingtwothreeletterswordsbutgettingafourlettersword.Thisindicates
thatF=c3=1
•Now,c2+T+T=O+10…….Becausec3=1
•C2canbe0or1.Letc2=0thenTshouldbe>5i.eTcanbe{6,7,8,9}
•LetT=9thenC2+T+T=O+10 0+9+9=O+10fromthisO=8
•NowO+O=R+10 8+8=R+10FromthisR=6
•Now,c1+W+W=U herec1=1andUandWcanbe{2,3,4,5,7}
•But,c2=0soletW=2then1+2+2=Ui.e.,U=5
•Nowreplacingeachletterinthepuzzlebyitscorrespondingdigitandtestingtheir
arithmeticcorrectness:
•Thisassignmentsatisfiesalltheconstraintsothisisthefinalsolution
10312/25/2018 By: Tekendra Nath Yogi

Contd…
•Example2:Solvethefollowingpuzzlebyassigningnumeral(0-
9)insuchawaythateachletterisassigneduniquedigitwhich
satisfythefollowingaddition.
•Solution:Here,
•Variables:{F,O,U,R,E,I,G,H,T, c
1,c
2, C3 ,c4}
•Domains: {0,1,2,3,4,5,6,7,8,9}
•Constraints: Alldiff(F,O,U,R,E,I,G,H,T)
•where c1, c2, and c3 are auxiliary variables representing the digit (0 or 1) carried over
into the next column.
10412/25/2018 By: Tekendra Nath Yogi

Contd…
•Hereweareaddingtwothreeletterswordsbutgettingafourlettersword.This
indicatesthatE=c4=1…..BecauseEisleftmostlettersoitshouldnotbe0.
•Nowc3+F+F=I+10,herec3canbe0or1andFshouldbegreaterthan5.i.e
{6,7,8,9}
•Letc3=0andF=9then0+9+9=I+10fromthisI=8
•Now,c2+O+O=G……sincec3=0
•C2canbe0or1andOcanbe{2,3,4}.Letc2=0andO=2ThenG=4.
•R+R=T hereRcanbe{3,5,6,7}
•IfweletR=3thisleadstodeadendsoletR=5thenT=0andc1=1
•C1+U+U=Hherec1=1andc2=0andUcanbe{3}
•FormthisU=3thenH=7
10512/25/2018 By: Tekendra Nath Yogi

Contd…
•Initial problem state:
–S = ? M= ? C1 = ?
–E = ? O = ? C2 = ?
–N = ? R = ? C3 = ?
–D = ? E = ? C4 = ?
•Goalstates:Agoalstateisaproblemstateinwhichalllettershavebeenassigneda
digitinsuchawaythatallconstraintsaresatisfied
10612/25/2018 By: Tekendra Nath Yogi

Contd…
10712/25/2018 By: Tekendra Nath Yogi

Contd…
10812/25/2018 By: Tekendra Nath Yogi

Contd…
10912/25/2018 By: Tekendra Nath Yogi

Contd…
11012/25/2018 By: Tekendra Nath Yogi

Home Work
•Solvethefollowingpuzzlesbyassigningnumeral(0-9)insuchawaythat
eachletterisassigneduniquedigitwhichsatisfythefollowingaddition.
1.
2.
3.
4.
11112/25/2018 By: Tekendra Nath Yogi

Problem Reduction: AND/ OR Tree
•Thebasicintuitionbehindthemethodofproblemreductionis:
–Reduceahardproblemtoanumberofsimpleproblemsand,wheneachof
thesimpleproblemsissolved,thenthehardproblemhasbeensolved.
•To represent problem reduction we can use an AND-OR tree. AnAND–OR
treeis a graphical representationof the reduction of problems to conjunctions
and disjunctions of sub-problems.
•Example:
112Presented By: Tekendra Nath YogiIT 228 -Intro to AI
represents thesearch spacefor solving the
problem P, using the problem-reduction
methods:
P if Q and R
P if S
Q if T
Q if U

Contd…
•Example1
•Example2:
113Presented By: Tekendra Nath YogiIT 228 -Intro to AI

Contd….
•SearchingAND/ORTree:
•TofindasolutioninAND–ORtree,analgorithmsimilartoBestfirstsearch
algorithmisusedbutwiththeabilitytohandleANDarcappropriately.
•Thisalgorithmevaluatesthenodesbasedonthefollowingevaluationfunction.
•IfthenodeisORnodethencostfunctionf(n)=h(n)
•IfthenodeisANDnodethencostfunctionisthesumofcostsinANDnode.
–f(n)=f(n
1)+f(n
2)+….+f(n
k)=h(n
1)+h(n
2)+….+h(n
k)
–Where,n
1,n
2,….N
kareANDnodes.
114Presented By: Tekendra Nath YogiIT 228 -Intro to AI

Contd…
•Here,thenumbershowthevalueoftheheuristicfunctionatthatnode.
•InthefiguretheminimalisBwhichisthevalueof3.ButBformsapartoftheAND
treesoweneedtoconsidertheotherbranchalsoofthisANDtreei.e.,Cwhichhasa
weightof4.So,ourestimatenowis(3+4)=7.
•NowthisestimateismorecostlierthanthatofbranchDi.e.,5.Soweexplorenode
DinsteadofBasithasthelowestvalue.
•Thisprocesscontinuesuntileitherasolutionisfoundorallpathsledtodeadends,
indicatingthatthereisnosolution.
115Presented By: Tekendra Nath YogiIT 228 -Intro to AI

Adversarial Search(Game Playing)
•Competitiveenvironmentsinwhichtheagentsgoalsareinconflict,giverise
toadversarialsearch,oftenknownasgames.
•InAI,gamesmeansdeterministic,fullyobservableenvironmentsinwhich
therearetwoagentswhoseactionsmustalternateandinwhichutilityvalues
attheendofthegamearealwaysequalandopposite.
–E.g.,Iffirstplayerwins,theotherplayernecessarilyloses
•ThisOppositionbetweentheagent‟sutilityfunctionsmakethesituation
adversarial.
11612/25/2018 By: Tekendra Nath Yogi

Contd…
•GamesasAdversarialSearch:
–AGamecanbeformallydefinedasakindofsearchproblemwiththe
followingelements:
•States:boardconfigurations.
•Initialstate:theboardpositionandwhichplayerwillmove.
•Successorfunction:returnslistof(move,state)pairs,eachindicating
alegalmoveandtheresultingstate.
•Terminaltest:determineswhenthegameisover.
•Utilityfunction:givesanumericvalueinterminalstates
–(e.g.,-1,0,+1forloss,tie,win)
11712/25/2018 By: Tekendra Nath Yogi

Contd…
•GameTrees:Problemspacesfortypicalgamesrepresentedastrees,inwhich:
–Rootnode:Representsthestatebeforeanymoveshavebeenmade.
–Nodes:Representspossiblestatesofthegames.Eachlevelofthetreehas
nodesthatareallMAXorallMIN;nodesatleveliareoftheoppositekind
fromthoseatleveli+1.and
–Arcs:Representsthepossiblelegalmovesforaplayer.Movesare
representedonalternatelevelsofthegametreesothatalledgesleading
fromrootnodetothefirstlevelrepresentmovesforthefirst(MAX)player
andedgesfromthefirstleveltosecondrepresentsmovesforthe
second(MIN)playerandsoon.
–Terminalnodesrepresentend-gameconfigurations.
11812/25/2018 By: Tekendra Nath Yogi

Contd…
•Evaluation Function:
–Anevaluationfunctionisusedtoevaluatethe"goodness"ofagame
position.
–i.e.,estimateoftheexpectedutilityofthegameposition
–Theperformanceofagameplayingprogramdependsstronglyonthe
qualityofitsevaluationfunction.
–Aninaccurateevaluationfunctionwillguideanagenttowardpositions
thatturnouttobelost.
11912/25/2018 By: Tekendra Nath Yogi

Contd…
•Agoodevaluationfunctionshould:
•Ordertheterminalstatesinthesamewayasthetrueutilityfunction:
•i.e.,Statesthatarewinsmustevaluatebetterthandraws,whichin
turnmustbebetterthanlosses.Otherwise,anagentusingthe
evaluationfunctionmighterrevenifitcanseeaheadallthewayto
theendofthegame.
•Fornon-terminalstates,theevaluationfunctionshouldbestrongly
correlatedwiththeactualchancesofwinning.
•Thecomputationmustnottaketoolongi.e.,evaluatefaster.
12012/25/2018 By: Tekendra Nath Yogi

Contd…
•Anexample(partial)gametreeforTic-Tac-Toe:
12112/25/2018 By: Tekendra Nath Yogi
•f(n) = +1 if the position is a win for
X.
•f(n) = -1 if the position is a win for
O.
•f(n) = 0 if the position is a draw.

Contd…
•TherearetwoplayersdenotedbyXandO.Theyarealternativelywritingtheirletterin
oneofthe9cellsofa3by3board.Thewinneristheonewhosucceedsinwritingthree
lettersinline.
•Thegamebeginswithanemptyboard.Itendsinawinforoneplayerandalossforthe
other,orpossiblyinadraw.
•Acompletetreeisarepresentationofallthepossibleplaysofthegame.Therootnodeis
theinitialstate,inwhichitisthefirstplayer'sturntomove(theplayerX).
•Thesuccessorsoftheinitialstatearethestatestheplayercanreachinonemove,their
successorsarethestatesresultingfromtheotherplayer'spossiblereplies,andsoon.
•TerminalstatesarethoserepresentingawinforX,lossforX,oradraw.
•Eachpathfromtherootnodetoaterminalnodegivesadifferentcompleteplayofthe
game.FiguregivenaboveshowsthesearchspaceofTic-Tac-Toe.
12212/25/2018 By: Tekendra Nath Yogi

Mini-max search algorithm
•Mini-maxsearchalgorithmisagamesearchalgorithmwiththeapplicationof
DFSprocedure.
•Itassumes:
•Boththeplayerplayoptimallyfromtheretotheendofthegame.
•Asuitablevalueofstaticevaluation(utility)isavailableontheleafnodes.
•Giventhevalueoftheterminalnodes,thevalueofeachnode(MaxandMIN)is
determinedby(backupfrom)thevaluesofitschildrenuntilavalueis
computedfortherootnode.
–ForaMAXnode,thebackedupvalueisthemaximumofthevaluesassociated
withitschildren
–ForaMINnode,thebackedupvalueistheminimumofthevaluesassociatedwith
itschildren
12312/25/2018 By: Tekendra Nath Yogi

Contd…
•Mini-maxsearchExample:
12412/25/2018 By: Tekendra Nath Yogi

Contd…
12512/25/2018 By: Tekendra Nath Yogi

Contd…
12612/25/2018 By: Tekendra Nath Yogi

Contd…
12712/25/2018 By: Tekendra Nath Yogi

Contd…
•LimitationsofMini-maxsearch:
–Mini-max search traverse the entire search tree but it is not always
feasible to traverse entire tree.
–Time limitations
12812/25/2018 By: Tekendra Nath Yogi

Alpha-beta pruning
•Wecanimproveontheperformanceofthemini-maxalgorithmthrough
alpha-betapruning.
•Basicidea:Ifamoveisdeterminedworsethananothermovealready
examined,thenthereisnoneedforfurtherexaminationofthenode.
12912/25/2018 By: Tekendra Nath Yogi
•For Example:Consider node nin thetree.
•If player has a better choice at:
–Parent node of n
–Or any choice point further up
•Then nis never reached in play.
•So,When that much is known about n, it can
be pruned.

Contd…
•Example:
13012/25/2018 By: Tekendra Nath Yogi

Contd…
•Alpha-Betapruningprocedure:
–Traversethesearchtreeindepth-firstorder.DuringtraversingAlphaand
Betavaluesinheritedfromtheparenttochildneverfromthechildren.
Initiallyalpha=-infinityandalwaystrytoincrease,andbeta=+infinityand
alwaystrytodecrease.Alphavalueupdatesonlyatmaxnodeandbetavalue
updateonlyatminnode.
–Maxplayer:
•Val>Alpha?(valisValuebackupformthechildrenofmaxplayer)
–UpdateAlpha
•IsAlpha>=Beta?
–Prune(calledalphacutoff)
•ReturnAlpha
–MINplayer:
•Val<Beta?(valisValuebackupformthechildrenofminplayer)
–UpdateBeta
•IsAlpha>=Beta?
–Prune(calledbetacutoff)
•ReturnBeta
13112/25/2018 By: Tekendra Nath Yogi

Contd…
•Alpha-Betapruningexample:
13212/25/2018 By: Tekendra Nath Yogi

Contd…
13312/25/2018 By: Tekendra Nath Yogi

Contd…
13412/25/2018 By: Tekendra Nath Yogi

Contd…
13512/25/2018 By: Tekendra Nath Yogi

Contd…
13612/25/2018 By: Tekendra Nath Yogi

Contd…
13712/25/2018 By: Tekendra Nath Yogi

Contd…
13812/25/2018 By: Tekendra Nath Yogi

Contd…
13912/25/2018 By: Tekendra Nath Yogi

Contd…
14012/25/2018 By: Tekendra Nath Yogi

Contd…
14112/25/2018 By: Tekendra Nath Yogi

Contd…
14212/25/2018 By: Tekendra Nath Yogi

Contd…
14312/25/2018 By: Tekendra Nath Yogi

Contd…
14412/25/2018 By: Tekendra Nath Yogi

Contd…
14512/25/2018 By: Tekendra Nath Yogi

Contd…
14612/25/2018 By: Tekendra Nath Yogi

Contd…
14712/25/2018 By: Tekendra Nath Yogi

Contd…
14812/25/2018 By: Tekendra Nath Yogi

Contd…
14912/25/2018 By: Tekendra Nath Yogi

Contd…
15012/25/2018 By: Tekendra Nath Yogi

Contd…
15112/25/2018 By: Tekendra Nath Yogi

Contd…
15212/25/2018 By: Tekendra Nath Yogi

Contd…
15312/25/2018 By: Tekendra Nath Yogi

Contd…
15412/25/2018 By: Tekendra Nath Yogi

Contd…
15512/25/2018 By: Tekendra Nath Yogi

Contd…
15612/25/2018 By: Tekendra Nath Yogi

Contd…
15712/25/2018 By: Tekendra Nath Yogi

Contd…
15812/25/2018 By: Tekendra Nath Yogi

Contd…
15912/25/2018 By: Tekendra Nath Yogi

Contd…
16012/25/2018 By: Tekendra Nath Yogi

Contd…
16112/25/2018 By: Tekendra Nath Yogi

Contd…
16212/25/2018 By: Tekendra Nath Yogi

Contd…
16312/25/2018 By: Tekendra Nath Yogi

Contd…
16412/25/2018 By: Tekendra Nath Yogi

Contd…
16512/25/2018 By: Tekendra Nath Yogi

Contd…
16612/25/2018 By: Tekendra Nath Yogi

Contd…
16712/25/2018 By: Tekendra Nath Yogi

Contd…
16812/25/2018 By: Tekendra Nath Yogi

Contd…
16912/25/2018 By: Tekendra Nath Yogi

Contd…
17012/25/2018 By: Tekendra Nath Yogi

Contd…
17112/25/2018 By: Tekendra Nath Yogi

Games of Chance
•InthegamewithuncertaintyPlayersincludearandomelement(rolldice,flip
acoin,etc.)todeterminewhatmovestomake
•i.e.,Dicearerolledatthebeginningofaplayer‟sturntodeterminethe
legalmoves.Suchgamesarecalledgameofchance.
•Chancegamesaregoodforexploringdecisionmakinginadversarial
problemsinvolvingskillandluck.
17212/25/2018 By: Tekendra Nath Yogi

Contd…
•GameTreeswithChanceNodes:
•Thegametreeinthechancegameincludechancenodesinadditionto
MAXandMINnodes.Chancenodes(shownascircles)representthedice
rolls.
•Thebranchesleadingfromeachchancenodedenotethepossibledicerolls;
eachbranchislabeledwiththerollanditsprobability.
17312/25/2018 By: Tekendra Nath Yogi
Max
min
Chance
Terminal node
Chance

Contd…
•Algorithm for chance Games:
•Generalization of minimaxfor games with chance nodes. Also known as
Expectiminimaxgive perfect play
–IfthestateisterminalnodethenReturntheutilityvalue.
–ifstateisaMAXnodethenreturnhighestExpectiminimax–Valueof
Successors
–ifstateisaMINnodethenreturnlowestExpectiminimax–Valueof
Successors
–ifstateisaCHANCEnodethen
•Forchancenodes„C‟overamaxnode,compute:epectimax(C)=
Sum
i(P(d
i)*maxvalue(i))
•Forchancenodes„C‟overaminnodecompute:epectimin(C)=
Sum
i(P(d
i)*minvalue(i))
17412/25/2018 By: Tekendra Nath Yogi

Contd…
•Example:
17512/25/2018 By: Tekendra Nath Yogi

What is Game Theory?
•Gametheoryisastudyofhowtomathematicallydeterminethebeststrategy
forgivenconditionsinordertooptimizetheoutcome
•Findingacceptable,ifnotoptimal,strategiesinconflictsituations.
•Abstractionofrealcomplexsituation
•Gametheoryishighlymathematical
•Gametheoryassumesallhumaninteractionscanbeunderstoodandnavigated
bypresumptions.
17612/25/2018 By: Tekendra Nath Yogi

Contd…
•Why is game theory important?
–Allintelligentbeingsmakedecisionsallthetime.
–AIneedstoperformthesetasksasaresult.
–Helpsustoanalyzesituationsmorerationallyandformulatean
acceptablealternativewithrespecttocircumstance.
–Usefulinmodelingstrategicdecision-making
•Gamesagainstopponents
•Gamesagainstnature
–Providesstructuredinsightintothevalueofinformation
17712/25/2018 By: Tekendra Nath Yogi

Homework
•Explainthedifferencesandsimilaritiesbetweendepth-firstsearchand
breadth-firstsearch.Giveexamplesofthekindsofproblemswhereeach
wouldbeappropriate.
•Explainwhatismeantbythefollowingtermsinrelationtosearchmethods:
–complexity
–completeness
–Optimality
•Provideadefinitionoftheword“heuristic.”Inwhatwayscanheuristicsbe
usefulinsearch?Namethreewaysinwhichyouuseheuristicsinyour
everydaylife.
•Explainthecomponentsofthepathevaluationfunctionf(node)usedby
A*.Doyouthinkitisthebestevaluationfunctionthatcouldbeused?To
whatkindsofproblemsmightitbebestsuited?Andtowhatkindsof
problemswoulditbeworstsuited?
12/25/2018 By:TekendraNathYogi 178

Contd…
•What is alpha-beta pruning procedure? Solve the following problem by using
this procedure
17912/25/2018 By: Tekendra Nath Yogi

Contd…
•What are the different steps involved in simple problem solving?
•What is the main difference between Uninformed Search and
Informed Search strategies?
•What are the advantages and disadvantages of bidirectional
search strategy?
•What are the advantages of local search?
18012/25/2018 By: Tekendra Nath Yogi

Thank You !
181By: Tekendra Nath Yogi12/25/2018