0% found this document useful (0 votes)
20 views15 pages

Searching Techniques AI

Uploaded by

ALWIN YABESH A
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views15 pages

Searching Techniques AI

Uploaded by

ALWIN YABESH A
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

of

Search Algorithms
35.2Properties search A
agornthnsad to be
Completeness: vometr
sNpenienoe
partwular
nput. a
let one luton or
A search aleornthm
ssadto
an optunal bot
2 Optimality: e
ouonfu
(Ost. hrlow
Tme complexty he
complexity:
Tineand space
, TI andspacecompleay
3ue naamun tong
omne aken
b%

pacceared
a noda opte
A goodsearchalgorithm
akesless me o petornchecancb
operation. and spaceto do s work
Then perorm acion

e Uninformed
Search
Algorithms
AGURE 3.12Epsodic/
Non-episodic
Environment
4uninformed
search. alsoknoWn as a blundsearch
algorithm, Do h ddoai
35 Search goalstate
otherthan
to raverse
bowomorirhms.
or
che
visit
one provided
the nodes in
the machine
inheproblemdefnion.
the tree.
Theonly
oTaDon
moon be
he
soedou
blindy
Algorithms
Ong
efficientor ineficient.
tollows
che tecbnique
There can be multple
irrepecave af wteher
plansto reachthe goalsate
fom de ort
or sn
We hrvered chatarufical ischestudyof building
Intelhgence raional Theseagentsmake
agents. differ by the orderand/or length
Althese paths actions.

of
uSe of sorme or the ocher searchalgorthmsin he backgroundto achievetheir
tasks.For examnl hissection, we will read about depthfrstsearch.breadthfirsseanchand ora cos send
soTDE sn-player
gamesikealegames,Sudoku,
crossword,etc.,
use search algorithms
to deduce Each of thesealgorithms has thefollowng
orithms. nformanoo.

a
ponon n he
partculr me. graph,dhe startnodeS tothegoalnode G.
Problerm
A consistsef thefollowing:
searchproblem Strategy, thcpathfollowed
stating by the graph rechG. NT
1.Statespaces thesetof all posible thatcan be attained
states by an agent.
whichisa
Eringe.
state.
data structure
to storeallthepossible (nodechat
states a b
dhe current
2. Startstates the statefrom where thesearchingisdone.
3. Goaltestis functuonchatchecksifthecurrentsateisthegoalstateor no. Tree,thatdepictspathwhile
traversing
to thegoalnode. TR
4. Solationto asearchproblem (alsoknown as plan)thattransformsthe
is sequenceof actions
a
Solution
plan,thatspecifiesthesequenceof nodes from S to G.

Martcateo thegoal state.Th plan isrealized Path/Step


costare integers
that representthe costto mOve fronone odeto nodhernode

l
using
searchalgorithms.

3.5.1
Typesof SearchAlgorithms Depth First
3.6.1 Search(DFS)
Inthisscarchalgorithm, the tree istraversedfrom therootnode The keywlbe searched theeaf
Fhereare iuny but,inthssectuon,we
earchalgorsthns will sixofthemosspopularly
discuss usedone.
For bettet
undertarndrg.
we will them undertwo heading-informed
categorize and unnformed
node of aparticular If
branch. thekey is notfound, then thesearchprocesbackrckst,the posetfiom
s
a
howi n ty 3.13 where the otherbranch was leftunexplored. Thisprocess repeatedfor charoherbranchcherunt
he key isfound or the entire tree iscompletely raversed.

Depin searohreah
first
seafe

PIGURE 1.13Dteresstlypenof SeurchAlgorthuIN


FIGURE 3.14 Dth-first
search
140 CHAPTER

In Fg 3.14, visualze
we can dearly che workingof aDPS algorith.
Here,
easch
nodeA andthenravenes n odes B.D and H.Now, H istheleaf
(node, hepath,
Lo eplore
the root
branch.NodesE and are thus l we
teta Solution: node
toreachnodeB to traverseits unexplored
to follow branch
the unexplored
travered.
Now,
nodeE.As a
,
'deepet
he node of the E bratrh

of
thepath s retraced
node, so again,
node
andthen it s foundthatallnodes inbranches
B have
beentraced

of
visited So,

t
explorng heotheruntraced branch the roott node.Here,
by

of
move further
will node

nodesF. K and G arecxplored.


we can concudethatDES algorithm
From thcseobservatios, occupies
a lot

lot is at the bottom end of


tume to execute when the solution or
and take a
dse
of
tuee.
implementedusngLIFO,thats,stackdata structure. 1%,
can be givenas, O(b).It
iscquivalent
to the
of the algorithm
Time conplexsty
nuber
tnavenedun pace
DFS. Comespondingly, complexity 1ohow
iscqivalent largecan the
fringege.
Obm),where
bisthe maxamum branching factorin tree.
a
solution DFS algorithm
d define thedepth of thelezst-cost
as far as egloes
m specfiesthe maxmum depth of che statespace. Itmaybe possole
dong
each branch belos
Infinsty backtrackáng
Note that path = thedepthof the searchtree= the number of
levelsof thesearchtree number of nodesinlevel The DESs pathcan be give a,S->A->B ->C->G
beksand ts D

the graph given

e
ThoughtheDFS algorsthm iscompleteifthesearchtree isfinite
and a solution it
exsts, Consider
Example:
optimal inreaching
as thenumber of steps thesolution, inreaching
or the costspent itshigh.
Advantages
1.Ituscslesmemorysitstoresonlythe nodeson thepathfromtheroot
nodetothecurrent no
2. It
takeslestimeto rachthegoalnode/statea comparedto theBFSalgorithm.

Disadvantages solution:We startwithode0.Expiorngs brznchtonode1, eoe tonode ?


->1->2->4}
ndodr4 F
1.Sometimes, Insuch 2 scenarío,thereis
marry statekeep recurring no guarantee
of finding e pode 4.we backtack node
to 3.Hence.the DS pb a be s

solution.
2. incertaincases,the algorithm
my getstuckinan infinite (DLS)
SearchAlgorithm
nodesinthe tree.A posible
deoth.1fcheideal
solutionto this
loopwhile
goingdeepscatchíng
ío
problemisto choosean appropriatevalue
s d,and thechosencut-offislesthan d. thenalgorithm
cut-off
ofcuro
DLS
Depth-Limited
3.6.2
s sinilarto the DFS algorithn wh an addonof pedeermode z a
T s
fzis.
Bat,Í
the limitations thenfnite
of pathinthe DFS, k DLS. he
the chosen cutoffs more than d,theeECUtion timeincrezses. veTCOTTe
3. Conplexity
of thealgorithm is
treated2sit a leafnode (or a node wh no uOcesoS DOdes;
depends on the numberof paths
ist ermúnated i n cas
y ofthe thset
4. DPS cannot checkduphcate nodes TheDLS algorithm
Thsiskaoro nnd
does nothaearvsolunon

r
1.Firs, ifthepToblen ass
Example:Explore
the path thatwill
be expilored
usngtheDES algorithm not have ay soluionwta 2 es de
to reach nodeG fromS
2. Second, iftheproblemdoes
failure
cut-off
isfound
when thesolution
3. Third,
DES CreatesthesameSet
For cxample,inthe tree
flve!
Fe3.15.
givenin
pte2 cbr to chr c tmge
nodes as breadthfirst H wiB notbe
d
nodesEEGand
of
method,different Dot go to level3.Therefore.
orde.
142 CAPTER3

Machin
Thus,che DLS Search u the solution
algornthm s complete ispresent
wthinthe
amat. Whaletme compleaty of DLS algonthms ob). spacecomplexitys specifed
O(bxe).
depthbmut and d s thedepehot the tree
wherelat
Level0

Level 1
Level2

the DLS implementanon be referred


and could tofor better ndertandn
imageexplains
This
Level3
Search(BES)
BreadthFirst
FIGURE3.15Depthlimited
search 3.6.3
nodesinthe tree are traversedbreadthwise to reachthe goalnode Searchng beg
Inthisalgorithm, and expands the successornode breadthwsebeforetraversngdepch-ac
node
Advantages fromthe root
.ident from Fig. 3.16, a BFS algorithm startsfrom the rootnode A and chentrersesnode
1. tsamemory efhaentalgorthm
sitconsumeslessspace. C. This means chat children of theroot node arerveTscd beforrcapliorngoher
B followed
by node to the nexsi
2. The algorthmtakes lsstimeto execute. all
n odes level,
ata particular controlthenpasses
mndes on any branch.A ftertraversing
3. Ittermunatsn finnteime to G aretraversed. Ths s followed by traversaof nodesH
afternodeC, alln odes fronm
Therefore,
exploresall neighbour nodes the presentdepch beforemong the
to K.Thus,
the BFS algorthm
level.
Disadvatages nodesat the nextdepth

1.It
san ncompletealgorhm swe may not be able to getthesolution
everytimewe do the
ifthesolution
search(even due to limtconstraint).
exists,
2. Ifmulnple
solunons
ofa problemexist,thenDLS may notbe able
to findtheoptimal
solution.
In ocherWords, thealgorithm s not optmalevenif
(>d.
Exarmple:
Travere
thegrventreeto searchnode H using
DLS withpredefined
limit
as 2.

Lmit=
2 Depth
FIGURE3.16Breadth-frst
search

limited
Search
Solution:We tartwithNode A atlevel0.
Thesearchproceshencontunus to cxplorenodes B,C,D, and E ar level
1
Now, we go to level2 and explorethe childnodes of node B.
backtracksdoneto level1 When H is not found chere, a

Childnodes of node C to find


are searched node H. Finally,
node Hisfound
nodeof Candthe algorthm termnates atlevel 2 as childa

Example:Traversethe grventreeto earch node H usingDLS ploring


wIth
predefined
limt Visiting
as 2.
Solution:Inche ree,node Hs notpresent till
level2.,so the
algorthm
failure. ismarked witha dashed
The path traversedforsearchng J..
termnates
Ba cutoff
returning from arandom node
FIGURE 3.17BFS
Treestartingg
144 CHAPTER 3 Artificialy
ntelligent
Machine

3.17,
In Fig. BFSalgorithm a random initial
selects node(alsoknown
kn assourcenode
orroot
insucha way thatall
and traversesthecgraphlayer-wise thenodes and their
respective node
children
and explored.
are visited Here, nodes

Visiting node means to visit a node.And.


or select

a
Exploringa nodemeans explorngtheadjacent nodes(childnodes)of thesclectednod.

Advantages
1. BES will
finda solutionif exists.
it

G
multiple then BES will
solutions, givethe minimalsolution
2. Ifagven problem has requiring
least

numberof steps.
issimple
ofthe BFS algorithm
3. The architecture and robust.

4. Itconstructs throughthenodes
path of traversing
theshortest of thegraphso thatthe grank
be traversed numberofiterations.
inthe smallest inthe path = the depth solution number of nodesinlvel
theshallowest

of
nodes
Thealgorithmn loop.
doesnotgetstuckinan infinite n BFS algorithm,
a
5. the sourcenode, traversethe graph and trace the
Usingnode

as
A
Considerthe graph.
Example: using a queue.
algorithm
Disadvantages workingof the
Queue
lotof memorysp2ce
1. Sinceeach levelof nodeissaved for creatingthe nextone, itconsumesa a

Spacerequirementtostorenodes isexponential.
the bottom or atthe end.
2. tIt
akes
less
timeif
the solutionisfaraway from the root node-at cb its
'a'& insert
Print nodesintothequeuei
child
nodes. a:
Print
depends on thenumberof
3. Itscomplexity the queue
nodesinto
usinga FIFO queue.Ttis a complete algorithm, thatis,itfinds
Printb:
el
d c Print itschild
'b'& insert
TheBFS algorithm isimplemented or ifall
if t hereisno cost
Thealgorithmnisoptimal,ifstepcost = 1(thati s, either
its nodesintothe queue
a solutionifitexits.
M oreover,it
has both timeand space complexity givenby,O(b). Here,b isthe Printc: glfe d & insert
'c'
Print child

step costsare samne).


nodesinto
the queue

factor
branching andd isthedepthofthe tree.
+ ...
+ |glfePrint'd' insertitschild

&
case isb+ b² + ba
Printd:
intheworst
b

Note that totalnumber of nodescreated in BES spacecomplexity, on


child the queue
nodesinto
to the number of nodes traversed Print its
& insert
'e'
Whiletimecomplexity isequivalent and robust
the fringeget.Due to highprecision Printe:
to how largecan
the other hand, itisequivalent likeP2P networks,Web Crawlers
and its nodesintotheqUeue
child
real-life solutions Print & insert
BFS is used inmultiple
implementation, Printf:
nodesintothequeue
child
NetworkBroadcasting. its
'a'& insert
Print
S to node G.
Find
Example: the BFS traversalfrom node Printg:

theQueue. inthe queuc.Thus,


Step1:Insertrootnode'a'into the child nodesof'a'
it
queue.print
and insert
fromthe
'a'
Op 2:Remove node queue,remove
and 'c'
are inserted. node inthe
nodes 'b' isthefirst
'b'
b'and'c'.
Since
node'd' and 'e'.
and has node Thatis, insert
Step 3: The queueis not empty
that are
the queue. inthe queue
So, atnote
node first'. of 'b'into nodes
'shallowest
itusingthe principle the nodes
chbild insertthose
a treeand traverses It,printit and insert Do not
Solution: The BFS creates -> ->G the queue gets empty.
bynodeG. Thus.Path isS Repeatthese steps until
D

S, node D be traversedfollowed
will
alreadyvisited.
CAPTER3

Searchlgorithn
eaith-ist Psecdocodie CostSearchUCS)
sore node Uniform
ssed
npcT: s as 3.6.4algrorithm
aoe
e
S (G, s) scenara,
the aigorirm
cemguteste
Such a
ie? De ee. node
thegoal
node to n
Sortingsdone

tsn the ransion


has
ncesngorcer
tese cos Remener
sStcach
st of a nodesdefineda

srs
Then
ommg
sid scadocodesshe
ods or
Dotmode of

Thesechtnods
tegn Gk ssserette
vsted ROGngsSo
n e

au
inF
fSshe
iI8,
pOde G hsa bige
oGse
sartnodeamd

o
here
go

D
sehenoeAsepiced
bGsrni
iolomed Thoug B
e s

The gocSSe mi sgT


beused
Itan
Applications
BES BI picph
SearchAgorithm
of Breadth-First
meodthariswideks
sedinthe followng
U Od

cost osre
Ifvoe ak wdrlsq e UCS BFS

is egesishe e
fhepath cost al ot

Craulers
inSearch
Engines
BFS grims sediarmng ebpags cachweb pags coesided
pplicznior z:
mOte mzgagn The zgucn mS Sng on hesouce page foloshe nkxatet
d
GPS Navigation
Systems 12
GPS sseBFS gorchoind eghbouing
locaioms
FIGURE3.18Uniformcostsearn
Pathforan Unweighted
FindtheShortest Graph gorithn wh ie
dpa compen n
isa conpleteandoptimal
The UCS lgorithm
For m eghed parh an be eayalcalaed
gaph theshortest
unberof etgesBFS hgo hnan do chisby esingaminimum
bychoosng2pathwithche
om
number ofnodessarting
ls Oe,
complexity where & is
the costand c ishe opinal
kowest
cost

e souneode Sartetherbrezdri-firs
eahor depch-firt
rersal
methodsan be sed Advantages
erysatt
the
br considering CO lex
Broadcasting
n coputernerworksda s broken down nto mll
packes befoeransision arosste
.
L. Ittndsan opimal

S.
UCSsComplete
UCSis
solution
and
are finite
onlyifstates
onlyitthereisno negae
optimal cost
is
tther ao loopwach erowegh

caaon media Thee packerssen lgorthm to computea patico he deszination For


messagrstha r broadcasted henodes n a network,BISSa preferredchoice
acrosS2ll Disadvantages
loops
an infinite
it consders oa cost

Peer-to-Peer 1. Thealgorithm may get stuckin


Networking
Stepstakento reachhegoal state.
BFS s ased n peer-to-peer
netwocks a nd alltheneighbouring
method to
nodes ineveryrection'.
versal
cmple.
Bir nodes,For ltexplores
lorrent
usesBFS forpeer-to-
peercommuncation
CHAPTER3
Artifhcialy
intelligetMachine
ofthe goalstate
3. Itdoesnothaveany ntormationaboutthe location G
more spaceforstoringinformatonaboutnodes.
S ->A
->B->
4. Itrequires
Path:
the
including longones.
5
5. The UCS mustexploreallpaths
Cost:
itsUCS traversalto reach node
Depth-First
Deepening Search (DDFS)
Example: Considerthe tree givenbelowand fromS. lterative

G
3.6.5 combinesthe featuresof DES
algorithm and BFS algorthrns
to find
Uniformcostsearch out
rativedeepeningcan be usedtoimplement
he DLS algorithm.
iterat that
limit IDDFS doe so by gradually
The depth
Level0 the best the until
limit thegoal isfound.
increasing performsdepth-first
1,
searchto level startsovet, executes a compete
depch-frx
The algorithm continues unilthe solutionisfound It nevercreates a node untlal
2 and ower odes
to level stackof nodes.
Level1 search Itonlysavesa
are generated. benefittedfastsearch techniqueof BFS algorithm
by and memory effiencythe
IDDES gets

f
o
algorithm. iswidely
Thisalgorithmn used whenscarch
space islarge,
2nd depch the

of
search
Level2 depth-first known.
node isnot
goal

E Advantages BES and DFS searchalgorithmsfzstsearchand memory


Level benefits of hienc
5
3
combinesthe
Itc
complete if
1. the branchinggfactorisfinite.
is
The alggorithm
is

2. ifppath costis a non-decreasing of thedepth the node.


function
algorithm
optimal

of
G 3. IDDES isan
Level
4

Example:Findthe pathand costto mnove from nodeS to nodeG inthegraphgiven


beloK Disadvantages
the previousphase.
1 1. Itrepeatsallthe work ot

goalnode.
reachthe
takesmore ime
2. It
to
(exponential)
when the BFS fais.
fails
3. The algorithm

searchalgorithn.
depth-first
Example:Traversethe givenreeusingtheiterativedeepening
5
node A at level
iteration,
Inthe first
Solution: O isexplored.

In nodesB and are traversedat level1.


theseconditeration, C

Solution
For a better
clarity,
we can drzwan Inthethird
iteration,nodesD. E,F andG aretraversed.
equivalent
searchtree forthe graph.
parhwiththe least
Cumulative
costischosen.
Using
UCS,te node H isreached.
Inthefourthiteration,
depthfirst
deepening
Iterative search

LevelO
1

Level2
5 5

ve'3
150 CHAPTER 3 Artificially
lnteligent
Machine 31)
a solutionat depthd.The
ends when it
Thealgorithm finds findsthesmallestpath from thesource node to the goal
node. Thus, bidirecaonal
nodes createddisb and at depthd-1isbd-1.
at depth In The algorithm
searchgraphwithtwo smaller sub graphs-one starting
from intial
number of IDDFS,we single or startnode
space
isO(b)and its DFS search)andthe otherstarting
of IDDESalgorithm pertor replaces (termed as forward from goal node towardsthesource
Timecomplexity
goalnodebackwardsearch).
anddepth
factor of "limited search
whereb ishe branching
isO(bd),
complexity keep depth tothe as
terminateswhen thetwo graphsintersect.
nd (known process Bidirectional
searchcan be
thetree isd. increasing
limited node search distancefrom sourceto goaland vice versa. Heuristc
the depth this The estimate remaining
of
means
and demonstrate iteration.aftereveN bya heuristic
Example:Considerthe tree given below gruided pathfrom
thecurrentnode in the graphto the goalnode.
ofIDDEFS.
appication che shortest
finding below andapplybidirectional
search on it
toreach goal node
thegraph given
Consider
14

Depth = 0 Example:node0.
tromsource
9
Depth=1
12

H Depth= 2

10
Depth =3

node 14.
one from node 0 and the other from
simultaneously-,
Depth=4 searchesare executed
R
Two p
this oint, have found a pathfrom node 0 to 7 and from
Solution: 7.
at node At we

intersect
searches unnecessaryexploration.
Boththese thereby
successfully, avoiding
The tree can be visited
as: A BEFCGDH 14to 7.The searchprocessterminates
a

Depth= {0, 1,2,


3,4)
Advantages
Depthlimits IDDFS Iitsfasterthanotheralgorithms
1. ofnodes
exploration
2. It
avoids unnecessary
is Oa +bdl), whichisfarlessthan O(b).Here,
b is
A of searching
complexity
3. Timeand space source node.
ofgoalnode from the
d isthedistance
1 factorof the tree and
BCD
A the branching simulaneous searches.
reducessearchingtimeby supporting
4. The algorithm drastically
2 ABEFCGDH tostoreallt he searches.
5. Ittakeslessmemory capacity
3 ABEIFJKCGLDHMN searchis
complete ifBFS isusedinbothsearches.
6. Bidirectional uniformcost.
4
ABEIFJKOPCGLRDHMNS 7. isoptimal
Thealgorithm ifBFS isusedfor searchand pathshave

3.6.6
Bidirectional
Search Disadvantages
thegoalstate isclearly
known.
can be usedonlywhen
l.Thealgorithm
In a bidirectional
forward
search,
frominitial
searching
isdone from boththe directions
stateand backwardfrom goal statetill
simultaneously. searches It 2. Itisdificult
to implement. pointwhere
intersection
itcan
both meet to identifycommon deduce the
correctly
state. must berobustenoughto
a
The path frominitial ne algorithm loop.
may getstuckinan infinite
stateisconcatenated
with the inverse Otherwise,
terminate. the algorithm
pathfrom the goalstate.
Each searchisdoneonly up to
half
of the totalpath. to searchbackwards
throughall
states.
t. It
isverydifficult
152 CHAPTER3
Machine
Intelligent
Artificially

Approach?
When to UseBidirectional Search
Heuristic
H
situations:
searchcan be bestusedinthe following
B1-directional Pure
7.1
3.7 witha large
problems number problem-specfic
possiblestates, knowledgeneeds to

of
node and the goal nodeare uniqueand completely large the eficiencyof searchalgorithms.
Insucha situation, heuristicscarch algorithm
When starting
both the Tosolve
defined. to increase
When thebranching isexactlythe same inboth directions.
factor headded
well. formof heuristicsearchalgorithms
isthe sinmplest that expandsnodesbased on
pertorns search The algorithmmaintainstwo lists--OPEN
Heuristic h(n). and CLOSED. All nodes that
Example:Consider thegraphgiven theapplication
belowand demonstrate of value
fromStartforward searchfrom node2 and backwardsearchfromnode 11. bidirectional
se heuristic expanded are placedinthe CLOSED list,
cheir
while othersthat have not beenexpanded
been
Do BFS frombothdirections. already list
have

Inthe backwardsearch
Intheforwardsearchprocess,nodes 1,6 and 8 are çxplored. are intheOPEN nodes vith
iteration,
thelowest
heuristic are expanded, Then,
value the heuristic
function
each
proCes,
On nodesandthey are placed theopen list
child according heuristic
to their value.The
7 Butno intersection
isexplored. nodeisencountered. mod to che
applied are savedand the longer ones are disposed.The processcontinuesunita goal stateIs
is paths
shorter
found. we willdiscuss
twoimportantinformed
search algorithms
-bestfirstsearch
Inthissection,
search)and A* searchalgorithm.
(greedy
algorithm
SearchAlgorithm(GreedySearch)
6 3.7.2Beest-First search
combines depth-first
searchalgorithm
Greedybest-first and alwaysselects
the path Heuristic evaluation
10 search algorithms
-first
12 13 and breadth- heuristic
It usesthe function functionscalculatethe
atthat moment.
whichappears best the most promising Cost of optimal path
Nextexplorenode 3 while searchat each step to choose between twostates.
doinga forwardsearch and node 3 while and best-first isthe one that isclosest
to rhe
doinga backward searh node
Here,we find nodeas node3, so the algorithmterminates
intersecting node.The mostpromisng
and the path is-
2 ->1>} is by the
implemented
algorithm
greedybestfirst
Goal node. The
->7-> 11.

queue.
priority
3.7 Informed
SearchAlgorithms searchalgorithm
Bestfirst
steps:

The uninformed searchalgorithms the starting


Step 1:Insert
nodeinthe OPEN ist.
thatwe have learntso far had no knowledge about searchspace
Butinformed searchalgorithm,as thename suggests, ifthe OPEN listisempty.
contains some informationabout how farwe ar Step 2:Stop andreturnfailure
from the goal,costof thepath,how to reach thegoal,
etc.This knowledge helpsagentsto exploreles remove the nodehavingthe lowestvalueof h(n),and insertit
inthe
to thesearchspaceand reachthe Step 3: From the OPEN list,
goalnodemoreefficiently.
Theinformed searchalgorithmwhichisextensivelyusedina large CLOSED list.
space is
alsoknownas heuristic
searchas itusesa heuristic
function. successors.
The heuristicfunction inStep3)and generate
its
takesthe currentstateofthe agentasits Step 4: Expand the node(removed
inputand estimates
how closetheagentis
itisthe goal node or not.If
from the goal. Though theheuristic node isfound to be
givethebestsolution,
itis,however,guaranteed method may not always
Step 5: Check eachsuccessor
to findif any successor
to find a goodsolution inreasonabletime. Step
A heuristic
functionh(n),calculates the and terminate
goalnode,thenreturnsuccess thesearch,elsego to 6.
the cost of an optinal path between the pair
valueof theheuristic
functionisalways 1he
of states.
If in
thenode isnot present
positive.
We can write, Step 6:Check
OPEN
ifeach successornodeisineither or CLOSED list.
h(n)<= h*(n)
any of then add
the lists, itto the OPEN ist.
whereh(n)isheuristiccost,and h*(n)
costshould
isthe estimated Thsmeans thatthe heuristic
cost. Step7:Go toStep 2.
be lessthan or equal to
the estimatedcost.
Advantages
1.Ittakesadvantageof bothBES andDFS algorithms.
ismore efficient
searchalgorithm thanBFS and DFS algorithms.
Bestfirst
154 CHAPTER3

Disadvantages
bestfirst
scenarios, searchcan behaveas an unguided
1. In some worst-case
can getstuckina loop. depth-first
2. Like searchalgorithm
DFS, bestfirst search

isnotan
searchalgorithm algorithm.
optimal
3. Bestfirst
3

Example:Consider it
thetree givenbelowandtraverse usinggreedy best-first
search 12
algoritm. 6
1%

10

Tableshowsthe heuristic
estimates:
Node hn) Node lh(n) Node h(n)
CLOSED list inthe
and place itssuccessors OPEN ist. Open IA B

Add nodeS inthe


4 |I,
J 3 Solution: It t
(S] as ithas minimum h(n),place inCLOSED znd put
5 F 2 15 Closed A from
the OPEN list
C, D 9 7 G Remove list
inthe OPEN
successors
E, DJ),Closed(S,A]
Open (B,C, as ithas minimumh(n), in CLOSED list
placeit and put
Expandthe node S and putit
Solution: intheCLOSED list.
Generateits
successors
anl C fromn
the OPEN list
Remove list.
placethem inthe OPEN list. inthe OPEN
successors [S,A, C]
D, HJ,Closed minimumh(n),placeitin CLOSED listand put
Open (B,E, list as ithas

ts
Open [A,B],Closed[S] OPEN
fronm the
B
Remove
list.
1:Sinceh(n)fornodeB islessthan that of nodeA, expandB and placeitinCLOSED
Iteration inthe OPEN C,.BI
G],Closed(S,A,
successors
and put its
NowonlynodeA isinthe OPEN list.
Open [A], Closed[S,B] Open E,D, H, placeit
as ithas minimum h(n),
inCLOSED list
Demove H from the PEN ist success.
returns
Iteration of nodeB and placethem inthe OPEN list.
2:Generatesuccessors Open (E, A],Closed of nodeH, thealgorithm
inthe OPEN list.Since Iisthe successor
secessors H
[S,B]. [S,A , C,B,
E,D, G, Closed
I, J],
Since
nodeF hasthelowestheuristic
valueamong all we will
nodesintheOPEN list, expandnode Open

E Now, Open (E,A],Closed[S,B,F]


3.7.3A* SearchAlgorithm and g(p)
functionh(n),
heuristic
Iteration3:Generatesuccessors of nodeF and place them inthe OPEN list. So,Open [I, G,E, A
form ofbestfirstsearch, uses
best-known Itsolvesthe searching
Closed[S,B, F) The A* search algorithm, thestartstate(refer 3.19).
Fig.
to reachthe
noden from faster.
Now,generate
succorsof node F andplacetheninOPEN ist. Sinceone ofthe successors node which the
specifies cost pathand givea n optimalresult
treeto find shortest
of
byexpanding less s earch first.
but expandsmostpromising
paths
Fisthegoalnode,thealgorithm returnssuccess Thepathisgiven
and terminates. by the nodes present problem efficiently
thatare alreadyexpensive,
intheCLOSED list. Open ([I,E, A],Closed[S,B, G] itavoidsexpandingpaths
That is,
Hence,the finalsolution be:S----> + h(n)
f(n)= g(n)
path will B----->F----> G
The worst-case
timecomplexity and space complexityofgreedybestfirstsearchisO(bm) where,
m isthe maximum depth of the searchspace. Although the algorithmiscomplete, itcan,at times, Costto reach
Estimatedcost
behavelikean incomplete
algorithm even ifthegivenstatespace isfinite.
Thismakes theGreedy best costtoreach fromnoden to
of thecheapest
first
searchalgorithm
not an optimal
one. ode n from goalnode
solutioñ.
Example:
nodeS.
Applygreedybest firstsearch algorithm
on the graphgivenbelowtoreach node I
from
tartstate.

Cost of A*Algorithm
FIGURE3.19Calculating
156 CHAPTER 3

Machine
Intelligent
Artificially
as the costto
as well
usessearchheuristic
TheA* searchalgorithm, reachthe
allgeneratednodesinthe memory. This makes it difficultto use
a number known as a number.
fitness node. more memory as itkeeps
the costsgives Sumf It uses
bo 3.. problems.
At each pointinthe searchspace,nodehavingthe minimum f(n)is forlarge-scale returnsthe path whichoccurred
expanded. algorithm first, s scarchingallother paths.
and ignores
found.Thesteps of this
algorithm The A*
terminateswhen the goal node is cantherefore
be algort At times,
ofA* algorithm depends on thequality
of heuristic.
4.
below.
given The efficiency
summarzed 5.

node inthe OPEN list. thegraph givenbelowand traverseitusingthe A* algorithm.


Put the starting
Step1: Consider
be calculated
by addingh(n)and the cost
Example: h(n) will reaching
thatnode.

of
isemptythen returnfailure
and stop. Notethan
Step2: If
the OPEN list
Stäte h(n)
Fromthe OPEN choosethenode having minimum valueof f(n).
list, Ifthis
Step 3: node is
the
2 5
node,then return and
success stop. goa
A
the nodeselected Put the node in
inStep 3 and generateitssuccessors.
Step 4: Expand theclosed
b
4
c heck ifit
is presentinthe OPEN CLOSED list.
Ifitisnot
For eachsuccessor,
or
ineither
present 2
hen
computeitsf(n)andplaceitintoOpen list. 10
6
Step 5: Else ifthesuccessornode is alreadyin OPEN or CLOSED list,
then attachit
totheback
pointer gn')
the lowest
reflecting value.

Step 6:Returnto Step 2.


Solution: {(S, 5)}
5. Therefore,
node S havingh(n) =

Pointsto Remember startwith


we
Initially, can reach node and node

G.
fn)of node A =
S.

A
we

1. Complete: iscompleteas longas:


A* algorithm From node A from node S is1.Therefore.
Iteration1: A is3 and the cost to reach node
fln)
factorisfinite. La)of node from node S is10.
Therefore,

of
(a) Branching the costto reachnode

G
h(n) = 0 and
G has
(b) Costat everyaction isfixed. 4.Similarly,
node

algorithm isoptimal ifitfollows


the two conditions: = 10.
2. Optimal:A* search node G 10)}
requires optimalityinthat h(n)should be an admisible (S-->G,
A, 4),
(a) Admissible: The firstcondition for (S--> we will
expand node A.
A* admissible is
heuristic optimisticin nature. f(n) as comparedto node G,fin) node B = 7.
heuristic
for tree search.A n SincenodeA hasless B from node S is3.Therefore,

of
Treration2:
condition foronly
isconsistency A*graph-search. B is and the cost to reach node is
2 . fln)of node
(b) Consistency: Thesecondrequired ofnode
bín) 4
to reach node
C from node S Therefore.
alwaysfindthe least the cost
nodeC hash(n)=2
searchwill costpath. and
Ifthe heuristic is
function then
admissible, A* tree
Similarlv,
algorithmdependson heuristic
function,
C=2. 10)}
Thetimecomplexity
3. TimeComplexity: of A*search
7),(S-->G,
expandedis exponentialto the depth of d.
solution So, the time A->C,4),(S-->A-->B,
{(S-->
and the number of nodes
whereb isthe branching
isO(b^d),
complexity factor.
10
The space complexity isO(b^d).
of A*searchalgorithm
4.. Space Complexity:

Advantages
1. Itisbetterthanallothersearchalgorithms.
isoptimaland complete.
2. A* search algorithm
3. Thealgorithm verycomplexproblems.
can be used to solve
path efficiently.
theshortest
find
is maps
4. It used by many games and web-based to

Disadvantages
approximation.
1.Itmay pathsince
not alwaysproducetheshortest itisbased on heuristics
and

ismore complexthanothersearch algorithms


2. A* searchalgorithm
158 CHAPTER3

Artifhcialy
inteligent
Machine
SincenodeC
Iteration3: comparedto othernodes,we will
has lessf(n)as
fromnode S is5. expand
h(n) node is6 and the cost to reach node node
A* VsAO*

D
of D
Therefore,
nodeG node S fln) 3.7.4.1AO* algorithms informedsearchtechnsque and
nodeG hash(n)
Similarly, = 0and the costto reach from is of
6.Therefore,
nodeD
are
use heustcvaluesto
A*and olve dhe
G= 2. Both
guranteesolution,
both the algorithms
11), onlyA* guarantees
{(S-->A-->C--->G, 6),(S-->A->C--->D, (S-->A-->B, 7).(S-->G, problen. an opumal
sohunon. B
10)} Although cheshortestpath withthe lowestcOst.Thc AO algorthm dosnotahwysprode
will we mcan
4: Since G isthe goalnode,the algorithm
returnsuccessand
terminate This isbecause AO* doesnot explorealithesolution
pachsonce n fndsa oluon
Iteration opdnmal,
solution.
gving

J
withcost6. h ft
pathas,S--->A--->C--->G anoptimal thetreegivenbelowandapplytheAO* algorthmon L
Consider
che graph givenbelowand traverseitfrom node S to
Example:Consider G using A* Example:
algorithm.
Step 5

10

Shortest
path= 11 D

10

Inchegraph,thecostto reachnodeA from nodeS is3 + 5 = 8,thecosttoreachnode B fromt


always moves towards
lowercost value The costfuncuon,
thatthe AO* algorithm

a
is6 + 4 = 10
and thecostto reachC is2 + 10= 12.Undoubtedly,
nodeA isprocessed No
further. Remember isthe heuristic or theestimatedvalueof the node and G(n)
where, H(n)
(S-->C,12)}
A, 8),(S-->B. 10),
(S--> (n) + H (n),
(F(o)= value,

G
node is foundto be reachedfrom A
Inthenextiteration, witha totalcost of3 + 10= 13.
theactual costor edge
is D or B-Ctogether.The costof both the paths
e

(S-->A -->G, (S-->B, 10),


13), (S-->C,12)} A. we can eitherchoose

the S -> B pathto reachG, we get totalcost= (6 + 5).Therefore. 11 Step 1:Fron node
Now, traversing as,
calculated
{(S-->A ->G, 13), (-->B-->G,11), (S-->C,12)} 1+10 = 11and
F(A to D)=
Thefinalpath to G from S isthus,S-->B-->Gwitha costof 11. F(A to B and C)
=1+1 +6 +12 = 20 has a lovwercostthan
as it
path B-C
node to traverse
choosenodeD as the next
will
We from node D iscalculated
H-I. Now thecost of H-I
3.7.4
AO* Algorithm withonlyone
are left
choice
Step2:From D,we
inwhich problemisbroken down probleminto
AO* algorithm isbased on problem decomposition a
as

smallerpieces. F(D to H-)=1+1+4 +4 =10H-IfromnodeA is11as,


can be applied onlyon thosealgorithms that can be dividedinto the cost of
Therefore, AO* algorithm Correspondingly,
a set of sub problems. Each sub problemcan be solved The
separately. finalresultisobtainedby
F(A to D to F-E)
=1+10=11 A thentheotherpath
H-I,
remainsunexplored.
on the path from
to
AND-OR representingthe
thegoalstateisfound
for solution.
combiningall the solutions.Usually, graphs/treesare used If We had calculated,
from nodeA to B-C.
Thedecomposition ofthe problem AND arcs.
generates theotherpath
Letus explore
Figure3.20shows an AND-OR graph.Itshowsthat if youwantto havebreakfastthenyou can F(A to
=1+
B and
+12 20
C) 1+6 =

milkt The
ogether. denotesAND condition. E and E
nodes can be reached-
eat bread or havefruitsand arc
are two
Step1:From B.there
and =7+ 1=8
F(B-)
Want havebreakfast? F(B-E)=5+1 = 6 movesto node

J.
to
the algorithm
ofthepath B-E.
valuefromE s 2.
than that
ismore
costfromFB-E) value5.So. the
newheurisic
otep 2:Since heuristic
2,whichisless
than
Eat bread Eat somefruits Drinka glass
of milk = 1 +1=
F(E-])

FIGURE3.20AND-OR graph
3
160 CHAPTER

from E to B,whichisnow Artificially


intelligent
Machine 161
Step 3:We need to updatethe cost
F(E-B)= 1+2=3
of B
value
the new heuristic is3.
Therefore, pisadvantages the optimalsolution
not find
ineverycase.

Step 4: We need to update thevalueof A as A


isassociatedwithboth andC. 1.It
does
is more than other algorthms.
complexity
Butto updatethe heuristic valueofA,we mustknow the value of nodeC. 2. lts
From C, node G can be reachedwith a cost of 1.So, the heuristic
valueof C is Climbing in Artificial
Algorithm Intelligence
Sincecostform C to G = F(C-G) =2whichislessthanitsheuristic
value, now
thenew l+|y 3.8 Hill search technique
that workswell
of C is2. heurisac Elis heuristic a on a largesetof
to find
inputs
sufficiently a
clinmbing
Hill Thissolution
to the problem.
may notbe the global
optimal
maxmum. Thealgonthm
Step 5: Now the updated from A- BC that is F(A-BC) = 1+1+2+3:
=7 whichisless solution problemsthat need to maximizeor minimize a given
realfunction
good to by choosingvalues
= 11. han F{A applied inthetravelling
in
-D be For example, salesman problem,hllclmtbngalgorithm
can
giveninputs. isused
This path A-BCismore costeffective
showschoosing and thusbetterpath from the bythe salesman.We know that heuristic
traveled
the distance function
A
usesall
a
the
chisis possible
However, ifthe algorithm
explores
thispath well.Butthe to minimize to rank all
the possible
alternatives
atany branchingstepinthe searchalgorithm
information

as
algorithm
bestrouteout of possible
thispath. We have just
explore shown thispathto demonstrate
the weaknessofthe available routes.
AO* the
TheAO* does notgive performanceinallthecases.
optimal algorithm and select

of HilIClimbing
3.7.4.2
Algorithm Features
3.8.1
algorithm is:a
variant of andtest
generate
TheAO* algorithm climbing
hill
maintains like
two lists theA* algorithm. che following
whichworksin
The manner: HeuristicC
searchalgorithm
The OPEN list
contains
the nodes thathavebeen traversedhave notbeen may not fndtheoptimal
markedas solvah, algorithm
unsolvable. possible solutions. solutionto the problem
all
Step1:Generating
TheCLOSE list butgivesa good solution
contains
nodesthat havealreadybeen processed. them to see ifitisthe expected
Testing
solution. ina reasonabletime.
Step2:
Stepsinthe Algorithm: isfound,the algorithmterminates
else
goes
the solution
If
Step 3:
Step 1:Put theinitial/ nodeinthe OPEN list.
starting 1.
to step
takesfeedbackfrom
algorithm the testprocedureand usesit
to generatethe
Step 2: Findthemostpromising
solution
treesay TO0. Thus,the climbing
hill
searchspace.
Step 3:Select
a node n thatisboth a next move inthe
member of TO as well inthe OPEN
as present ist. inthe statespace,the hill climbing algorithm usesthe greedyapproachto
Remow n At any point
from OPEN and placeitinCLOSE list. so that an opumal soluion
can be
t he costof function
mOVe the searchinthe direction
thatoptimizes
a heuristic
value whichincates
bow
Step 4: Ifn
isthe leafnode as well
as the goalnode,then label
n and allits
ancestors
as solved.the
obrainedat the end.To take such decisions,the algorithm uses
to the goal state.
the currentstateis
If
starting
node isnmarked as solved
thenreturnsuccessand ext. close
Elseifn isnot a solvable
node,thenmark n as unsolvable. If It
does not support backtracking inthe searchspace,as itdoenot remembercheprevious
thenreturnfailure
starting
node ismarked as unsolvable.
and exit. States.

Step5:Ifnisnot a leaf
node,thenexpandn.Enumerateall Rememberthe following:
its computetheirh(n)valus
successors,
and push them intoOPEN. + heuristics
1.Hillclimbing = generate-and-test
and a ralue.
Step 6:Returnto Step2. 2. A node of hill
climbing has two componentsstate
algorithm
good heuristicisavailable.
Step7:Exit. climbing
3. Hill ismostlyusedwhen
algorithm a
doesnotmaintain searchtree or graph. onlykeeps
and handlethe a

4. Thealgorithm
Advantages single currentstate.
thsalgorithm
of a geneic algorithm.Although
1.Itgivesoptimalsoluion. 3. cimbing
Hill isthe simplestimplementation
ones, it
executesf sterwhen comparedwithothergenetic
2. Itcan be used forbothOR thoroughthan the traditional
1s less
and AND graph when nodesare traversed
ina particular
order. algorithms.
16 CHAPTER3

Artificially
intelligent
Machine
Types
3.8.2 Climbing
of Hill isnothetterthan the beststate,thenmake beststateas the
Ifthe new state currentEate
we will of hill
variants
different
discuss algorithm
climbing (c) a solution
in theloop until isfound.
Inthissection, Continue

Hill
Climbing Hill
Climbing
Simple
3.8.2.1 Stochastic
thefirst 3.8.2.3 two variants, hill
the scholastic climbing
algorithm does not examineall
nodes and selects the
The algorithm examines theneighbouring previous
the
neighbouring
inthis beforedeciding which node to selectnext. Rather,itrandomly selects
The stepsperformed Unlike
the currentcost as the next node.
optimizes
node
algorithm wh can
nodes
whetherto move to that neighbour
and determines or to examne
neighbouringnode another
follows. in
ofimprovemnent that neighbour, Stepsto be performedin hill
scholastic
the
aneighbouring amount
on
the
Step 1: Evaluate initial Ifit
state. thenreturnsuccessand
isthe goalstate, depending below
terminate arelisted
stateas the current
initial state. the
climbing Ifit:
state. isthe oal state,
thenreturnsuccessand terminateche process.
Else,
make proce
the initial
stateisfound
thesolution or no newoperatorsare Step
1:
Evaluate
state the
initial
as currentstate.
Step 2: RepeatStep 2 until presentwhich make
state. canb Else, 2 until eitherthe solution stateisfoundor the currentstate
does not change.
appliedto the current Step
Repeat
this Step 2: beensetas the currentstate.
(a) Select statethat has not been set as the currentstate. Use to produce:
state
new state. a statethathas not
Selecta the neighbour
sates.
a
fnction tothe currentstateand generateall
(b) Evaluatethe new state. (a) successor function)a state the neighbouringstatesgenerated
from all
Apply probabilistic
If
(i) the current stateisthe goalstate,then returnsuccessand stop (b) select (or use a
Randomly thanthe currentstate.
t henset itas theCurrent better
(ii) tIf
he new stateis than
better the current state,
state
and in 2,b) and are
in
2 (c)is thenreturn
the goal state, success,elsemake it
the Currentstate and
selected
further.
processed
(c)
If
the state
the loop.
thenew stateisnot betterthan the currentstate,then continueinthe loas
If
(iii) continuewith
isfound.
a solution
for HilClimbina
StateSpaceDiagram
3.8.3 chatcan be attained
of the setof states
representation
Advantage 3.21)
(Fig. is graphical
a
(thef unctionthathas to
diagram function
of theobjective
íttakeslesstime.
The state-space
search algorithm withrespecttothevalue the values of obiectivefunction
on theX-axis,
the space isrepresented
state
La mavimized).
While the Y-axis.
stateare marked on (gobal
Disadvantages to a particular function has a maximum value
corresponding the objective
The bestsolution isthe statespace where global
the
find maximum and Jocalmaximum.
1. Solution
islessoptimal. is
to
algorithm
climbing
the hill
maNimum).Thegoal
of

2. It
doesnotguarantee
any solution
function Globalmaximum
Objective

3.8.2.2 Hill
Steepest-AscentClimbing
the node closest
nodes.Itthenselects to the solucon
The algorithm examinesallthe neighbouring
hill
steepest-ascent climbing
can be givenas follows: Localmaximum
stateas thenext node.Stepsto perform Shoulder local
"Flat" maximum
and terminatethe proces.
Step 1: the initial
Evaluate If
state. itisthegoalstate,
thenreturnsuccess
make initial
Else, stateas thecurrentstate.

statedoes notchange
stateisfoundor thecurrent
eitherthe solution
Step 2:Repeat Step2 until

(a) a statethat hasnotbeen setas thecurrent


Select state. Statespace
a new beststate'
Initialize Use thisstateto produce
egualto currentstate. a new state.
(b) Current
(c) Evaluatethe new state. state
(a) Ifthe current thenreturnsuccess
stateisthe goal state. andstop.
(b Ifthe new stateis better than the best state.thenmake it elsecontinue
the beststate: with Diagranmfor
Hill
Climbing
Space
thelooptogenerate and testanothernew state. FIGURE3.21 State
164 CHAPTER3
Artifcially
lntelligent
Machine
Different
Understanding intheState
Regions Space
3.8.3.1 Annealing
Diagram the beststate(also Simulated
cannotreach the optimalor 3.8.4 thar a hill-clmbing
algorthmmay get stuckon
Any hill chmbmg algorith spacediagrame
kuownas a localmaxmum or may not find
regionsinthe statc the scen
an

maxmum) ifit entersany of the following goh while doing random walk Simulated annealing
s an algornthmwhch s both
We havt
a

which betterthan itsneighbouring


iscertainly state.At solunon
Localmaximum isa state
this optmaland complete does not support downward movesbut
than itsneighbours.
ishigher sate, climbng algorithm
function a hill
sumulatedanncaling
valueof the objective it.This eicient
a statewhichisbetterthan better is
state known Usually. escapelocal maxma and guaranteeboth efficiency
and completenes.
However,there does exist ashe moves to
lo such the algorithm picks random move ratherthan the best move Ifthe
a

maxmmun. allows annealing,


stateinthe statespacediagramand hasthe Insimulated the state,then itfollowsthe same path Otherwsc,the algorthm moves
Globalmaximum isthebestpossible highesy moveimproves path.
randomn and chooses another
function.
for the objective
Plateau/Flat localmaximum is flatregioninthestatespace where neighbouring
a downhill
States
have
thesame value. Applications
Ridgeis a special
than itsneighbours
type of localmaxinmum thatishigher
butitself
hasalope
3.8.5 algorithm
inthefollowng
can be applied areas:
climbing
Thehill
inthe statespacediagramwhere thesearch
is
beingdone
Current stateisthe region currenty
as a flatplateauthathasan uphill
edge.
Shoulder isidentified
Marketing citesmultple
to several
algorithmisused by marketingpeople who needto travel
Resolving
3.8.3.2 RegionsinHill
ProblemsPosedBy Different Climbine
The hill-climbing thebest marketing
p lans. is
Thisproblem popularlyknown as travelling-
to develop
in year
a
can helpthem to optimizethe distancecovercdand reducetheir
cines The algorithm
LocalMaximum problem. thelocalminimaefficiently.
salesman by establishing
maximum,allneighbouring have valuelessthan thatof theove
states times
We know that at the local
a
travel
usesa greedyapproach, not1noveto the worscstateand termin.
it will
state.Since hill
climbing
will systemsand
maximumisattaincd. the problemhereisthat the algorithm
Therefore, termin. Robotics isuuseedto enhancethecoordinationamong different
once local
itself algorithm
climbing
hill used in inductivelcarningmethodsfor coordinatingwith mulbple
without exploring thatmay exist.
a bettersolution
. Inrobotics, Itis also
in robots.
thisproblem, backtracking technique can be used.A listof visited
statet
To overcome components
a team.
state,then itcan backtrackto a previoutot
robotsin
the searchreachesan undesirable
so that if
maintained
and explore
a new path.
JobScheduling a computer
tasks wthin
to different
are allocatcd
inwhichsystemresources node).In
Plateau Iobschedulingisa process (poibly a neghbourng
by jobsfromonc nodetoanother right
migrating m grationroute.
neighbourshavethe samne value.In sucha scenario, it
isdifficuk vstem.It isachieved the
can be uscd to establish
Plateauisa flatlandindicatingthat all algorithnn
the hill
ech a scenario, climbing
the best direction.
to find
to come out of this region.For this,a state
far
Algorithms
To overcomeplateaus, a bigjump isrequired
Prosand Consof Hill
Climbing
randomlyto incrcasethe probability in
of landing a non-plateau 3.8.6
away from the currentstateisselected
region.
Advantages management,
inportfolo
For exanple,
Ridge relatedproblems.
desgnng. ce
the
inrouting
climbing isuseful circuit
like
a pcak as movement inall
possibledirections
leads to 1. Hill vehiclerouting,automatc programmng,
that looks power.
Ridgeisany pointinthe space Itisa special chipdesigning,job scheduling, when thereislmited
computatonal
n such a when
terminates
the algorithm
situation, itrcachesa ridge. probles, especially
downwardvalue. can be usedinoptimization otherearchalgorithris.
2. It than
maximum.
formof local ismore efficient out thebestsuitable
atc
to Ridge, Use two or more rulesbefore testingtomove inseveral 3. Thealgorithm the goalisto point prvdes
To overcomeissues related work incaseswhere the grvenproblems.It
indifferent easily optimzng
bidirectional
atonce.For this,
directions search can be used or the algorithm
can be noved 4. Itcan
hill
climbing algorithm is
popularlyusedfor

directions. 5. Allin all, challengng situation


solutionsto conputationally
outstanding
CAPTER3

scenarnoswhuchae dscuedbeiou.
Disadvantages duferent rypesot garme
a
agorthm s hatitmay terminate a Loal There
are
of chis Information
Howevehe sadancage
with Perfect
Panez
Games
a
open and transparent
re the
5 everyplayerhscompletenformonTheplavers
game and the move of the opponerEmes
ew
Search S.h of
the status suchamandde of

3.9 Adversarial and


ethello go

than one entityEach kers,


that
hench
more
searchisa searchngalgorthm
has of

Adveraral
ina Imperfect Information
goas
conthcong nd objectvesThese enites partcipate
with
gme approach of eachplayer Games do nothaveanyinformation on the sKztusof theame Theyakeblind
game-hkesutuanonThesrategy
or Whdenormal msves
players
move Foreample,thegame situation search gams, and the outcomes. Eamplesof thegmes
depends on theopponents
a
single
entity, Ir
chese predicting
assumpaons
certain
incude.ic-tac-
whethera playerwould searchon the adversna
nd ntentof the opponent determnes otherhasa by mmaking and bridge.
blind.
or a mnmize ole While Maximizer. hasmore
thanone eitit battleship,
ake 2 mAzet role toe,
gtn,Mnimizer, on the other hand,makes best Games
maumizesthe
to imutche damage and minmizethe loss. Deterministic
efforrs in
are played ransparent manner. Al playerscan seethe moves
a the opponents nd
of

Mathenanallk, search is based on the concept


adversarial Adversaríal search an Thesegames rulesand pattern. Thereis no randonness2550Ciated wih determinnsc
a game
betweentwo be usedfor all
of gamne theory' whictstatesthat a game isplayed types of folowpre-defined
and patternsare followed verystricdy.For example. chess,
c heckers,
o c-tac-toe,
go are
other loses
thegame, one has to winthegame and the
To complete
players games with predictable
2s therules
as well
as unpredictabie games.
utomaticaly. determnisac
outcomes by followino
Each plaver
considersthemovenentsof otherplayers,
then
blind
Games
dynamically
formulatesa strategy While
to reach theend goals.
transparentor rules Non-Deterministic
non--deterministic
ganes are highly
unpredictable. takerandom moves
Plzyers
playing. may take unforeseenturns to upset the opponent
players suggests,
As the name like
luck or chance. For example,games poker,monopoy, backgammon fallinthis
and winthegame.So, a
quickreaction
isrequired andwinthegame.Tochooe.
tocounterstrategize win by sheer
and
ina limited
bestopcimalstrategy like
time,techniques pruningand heuristic
evaluation
areperforme category.

Zero-SumGames
Theseare purely competitivegames inwhich one player's gainiscompensatedbyanotherphyer'sloss.
M
w Thenet value of gainand lossi s
zero,thus,the name.

Herealso,eachplayer has different


conflicting
strategies. will
So, eachplayer eithertrytomaximize

rhe gainor minimize the los, depending on the gamne situation, likely
strategy to be adoptedby the

We areopponents-Iwin,
you loose. oDponent and the players game plan. Thisscenarioispopularly known as embeddedthinking in

problemresolution in Al.A player can easilybacktrackand change hisstrategy dependng on the


FIGURE 3.22 Game Theory FHence,itisalsoknown as backwardreasoninginAL.Chess.
directioninwhichthe game progresses.
Inpruning,
the unwantedportions tic-tac-toe inthisgroup.
are games thatare played
of searchtreethatmakesno difference
ignored.
a
initsfinal
result
are

Heuristic
evaluation
function TABLE3.2
approximates
the cost at eachlevel
of the search tree,
reachingthe goalnode. before
Deterministic ChanceMoves
3.9.1
Game Scenarios Perfectinformation Chess,Checkers,
go,Othello Backgammon,
monopoly
Adversarialsearchexamines information
Imperfect war
the problemwhicharises
when an agentplansaheadof Battleships, tic-tac-toe. Bridge,
blind, poker, nuçlear
scrabble,
agentsthatare planning other
against
it.Itisapplied ina multi-agent
thataremodelled environment,
as a search
problemand use theheuristic like
ingames
evaluation
function.

You might also like