Professional Documents
Culture Documents
AI Observers
AI Observers
- PuzzLE PROBUEM
CUA BES)
AiM
To rite a Python prog 1am to implemank
a tu- tost
d
Hhan rctan
olitun: (rode)
PrvbleM, GtOAL-TEST (mode.STATE)
FIFo /ueu with
wode f h e ony element
ontter<a
eplored*an empty Bet
oop do return ure
Emr7y ? (Jronter) Hhen
6
mode Pop Chonter)
add mode. state xplared
o
poblem. Ac haio ode. STATE)do
r ch aeton n
Cld-CHILD- NoDE Cprsblew,
mde, aCta)
rovter s e t Cehil n e
*Sample Tnpat7 Output
date
5
6 7
2 O
3HS
618
O2
3 45
678
012
67 8 goal
Proc edure
Sates
lotaher t a e
A. state dtotpleon fuien the
y he zht l e and he
ohere
dependig
hoss arc pbe
the ank ë .
s turmie dete
seulhia a pt. 7
tue
t 4tate the
has the
SCno
the lau
Cnd he blauk
ltitate
htothuon
Hhe . Alate
wethun
noal tut- Th thetke
tatyuratmi
mothes h e geal
(oit
ath
.fath: ath stepe ost1, ein hte
e peth;
uwbe4 4tep
the
Resls t ktat
the Pytihonf r a
TAus éfs nettuted
etu rd,
-Punyyle problem i e
8- Pagle Prblen
Sampe /o
8
Enter norom
Evdes roo rom Enter te mbnyt
te tthe numbor :
nte He 2 Mber
huwber 8 nter the 3mb:2
nte Hhe
2
e r the
humber: 2
enley the umben 0
: 0
*umbr
Futer tht ken : 4
ter te
nwmbe : y nfe tue 6uwwb3
5
nter the
ummbu: 3 Bn ter t e hube7
hder me
he number +
the hu !
buter enter
6
ter he & nwbe (Eu ter te wwbe
Dsiabmter e humbu S
unlue
h e Purle sovable
The PuYJe u
Reptada h on
enurateol pota elk uun3 )
Explohy Nd
Move :one2
fe,ult:
Hab'feu6 3
Aodeuwbu:D
Move r a t
Peault
elie
elueliea
hode umb 3
3 gtcha
7L 6
Move P
Resulk
de wwbn 1
WATER JUUI PRoBLE M
AIM
To wrte Pathow pngrdu fo mplemant
Acareh.
iut
Water- dug toblem iing epta
AlDtl Pmudlode
2pty i t
Stack dutflows
as ept iFo
nadeCohilol, e d )
For Cld u
Pefine uldjlouo- uegtHoo
mn tlow and culd, nottn pata:
dtd louw >=
duflocoa byurde
Colleet Sn outpa Chole, loco) t
Saple Inpuoulput
Iput 6, 6,
Staoting wore
Pseing
Co e,4)
Cs, o,
Ce,A
3,8, 1
C1, O,)
Cn,i,o)
C6,
C6,4,
Sample 7/0:-
.(2,)>(a-3-3), 9
t)23
and 2>
into the
water roun the hgalle
jag
Pour i
iau
i l the
3
gallrm jug
-gallenjg
C7y) (o,2r})
u t the 3 allou )
lo,2)> (2,)
Pour e gallons hrom te 3-7allon
tie -9allor lg
a in
C2,2) (o,2)
e 40und
mply tueA- 9allonjug
TMPLEMENTATIONl OF
A ALORITH.
AM
To ne the hortest Patt vng A
goton í Kython
ALORITHM: Node
lontamung onhy tae startirg
onake an 0penlst
empty
Closcd duot
make
ode hoa not b e
am
dytnaluo»
owle (he ea nnd )
the owest
owesl
the ooll
Connelen s6
Store tn the pen
node u our dotuauoin, node)
Cthus
we are
tnusked
ot node a
the clased
the elose
current n eh jhkour guoour
Put heand all
a ll 'u
leok a t
t
umt ode)
hukborthe
gorCah loven 2
valut thon
than
neghbor han elosed t
closed ut));
:
n e
awe
Currat hew,
utAe
t h i hughbor
eplace Current node
vaul
oue
ouwe,
ow
eh bor's
h e ntughbas paron paremt
rrent value
As owe ang
2lse
us the Open Jot ):
h neahbou
he'ghbor
oifh then e ,
#he
plate ower vaue
Agbors paromt
ho our
change the
Gaurront nod
to step-06
netir S to the node
evalualon
the st
6 Arr'y not been n u
node hao
he
adol fo DPEM
b Stp-02.
7Unobark
AO ALCORITHM
AIM
To impletut Ao alejorhm Python to 3d
un amol vised oxt
ALLoRITHM
to alartnode
Ttialise theJraph
the Curremt
Jollowing
Travese 4ie grapk hal
tha have
haue
modu
P at
Pat actumulat ng olved
expamclol
4olved
bun
quot 4et
naok amol expamol it
3 Pck auyfhere ctestors ealu ths
has n o
amo
mark
the
the node
a
a SoL VED.
SoLVED.
o theu
o
f or ha neuoy
5 chauge valu
the
BuCteso
Ceateol nod to leet
back pAgakn
mort promu'ainy
Wheavon poetble Vse the marked as
a s
node
outes no mack the parent node as
node a i
thtm
SoLven
SoLvED
Value greater
gr eater
node oLVED lo) Value
7 sdadin ebe peat shp.
FULILITY, 4op,
ham
RoUE DURE
Cost Functuon FCn) - u(n) 4 H (n).
5: close
nade thn lueleo
6 n ai the feminal gaal
naw sdved amal levelec all the antes hor
sfarttug mode marke
au olved . the
and 'erit
olveol h e n
Auetes
as
mark n
mot a kolvable mocle, hen
n ub node us marked ay
as unodvable. 4 t4rhig
amo t
amd eet
then Aturn 9oilure
unolva ble,
all i
sutestore
amd nd
Expowmonind
8 them into BFe.
value, push
+heir hCn)
&tep2
9 Rehun
X No5,
AIM
"implemmt 6ngle playen Anake hame usfng
tteunush umtluon n Python
* AL1ORITHM
Start
Create a
game
piholouw ne 720 1eo
2 4nake to (loo, ) pixe l
pasttu of
3- Sek inital
'n the awndow
Co-ordinalien
t
nake
direeiov altordung
6 ehamgg -the
VA input
6
Repea p 4
8 Shop.
RoCEDURE
Uhrare
Firsy we are impordfng nee may
te
to itHaliye
Ubrar'es 1oe teol
impovtng
metud.
P19ame inst C)
geme
we are
the shake
Shake
thetkrng that u dhake
Alter ha, wall eo t
a htta
th a
w
w l e a l lqame overumcuar.
wal we
AIM
Tre Ta Toe
To ímplemeut he fwo pla
Gome
N Virg Heihe Juntuo n Python
ALGTORITHM:-
is
Mrnmarnade, derth, marimiirg player )
deph onode aHermínal node then
=o
Modle
turn Stortfe evaluatuo
Marmiyingflayen
themartva - in t t
do
or each childl Rodle
eya miwmax (child, depth- I, falbe )
Max eva > mar Cmax Eva, eva)
u r n Maxeva
dse
neva+ intn
Mode do
eack cild
o true)
va
min'ma Ciilad, deyth-1,
munva min Cminta eva)
nturn muintva.
rodeolure:
the lom mand
We wtll be plasying Te-Hae-oe n
tWe
e kave to dlo
ne, thefore, -the Ziat tting
koe
s Create a dewg for otur He dae-
Cruual
inssamt tfme, Ve heeol two
At amy
nor maden
hawe a odada
the grid -
ne mut
8taktus o slate, thet ,
tach tells
strutture hat tore
Ae to a
kng
mwot tnput
tnpu
ierdtuoin a playen must
6 ver
n every me
w move
payt npuk,
we neeol do uplt a
ome at a me,
Since .each plaeye 0nly mov
1 we
we
tack Aucceul uov
theu hore ofter
hawe do swap the
urrent
pay
The tntornuatuin hke the Qurrent playo the
ktojeboard nteol
amd he
ckpiee e Playeos
the Carremt playon u
h Aorec By defeult,
he
enteud
nane frat
rat
the playerwho
pop or Mamaqina
we need
amothe 9ame
. eauh modch
madches t e - t a c - doe
ultple mark
a r k x'or
('x'or 'o')
ehooses his
he Current play
must be dwplayeol
The menu or choosng
ame
terafo
in eyery
the doda ka
douda ben
haz been
the players luotte,
|Aceordira
aAceordirg
Ta mpos tonot Ante after taeh
Sroren
tore ull ells shich plagu
game inishen,
13 Aler4brig
Aler all he mecesmasy 'normalio, if
Madeh Omd
independlsmt
tfme to eeeoute am