An Analysis of Alpha-Beta Pruning

  • Upload
    xml

  • View
    225

  • Download
    0

Embed Size (px)

Citation preview

  • 8/14/2019 An Analysis of Alpha-Beta Pruning

    1/34

    ARTIFICIAL INTELLIGENCE 293

    A n A nalysis of A lpha-Beta Prim ing'D o n a l d E . K n u t h a n d R o n a l d W . M o o r eCo mp uter Science Department, Sta nf er d University,Stanford, Calif . 94305, U.S.A.

    Recommended by U. Montanari

    ABSTRACTThe a lpha-be ta t echnique for search ing ga m e t rees i s ana lyzed , in an a t t emp t to prov ide s om eins igh t in to i t s behav ior . The f i r s t por t ion o f th i s pape r i s an expos i tory presen ta t ion o f theme thod toge ther w i th a pro o f o f i t s correc tness and a h i s tor ica l ch 'scuss ion . The a lpha-be taprocedure i s show n to b e op t imal in a cer ta in sense , and bounds are ob ta ined for i t s runn ingt i m e w i t h v ar io u s k i n d s o f r a n d o m d a t a .

    Put one pound o f A lpha B e ta Prunesin a jar or dish that has a cover.Po ur one quart o f boiling water over prunes.

    The longer prunes so ak, the plumper they getA l p h a B e t a A c m e M a r k e t s , In c .,

    L a H a b r a , C a l i f o r n i a

    C o m p u t e r p r o g r a m s f o r p l a y in g g a m e s li ke e,he ss typ ic a l ly c hoos~ the i rm ov e s by se a xc h ing a l a rge t r e e o f po te n t i a l c on t inua t ions . A t e c h n iquec a ll ed " a l p h a - b e t a p r u n i n g " i s g e n e r a l ly ~u s e d t o s p e e d u p s u c h s e a r c hp r oc e ss e s w i t h o u t l os s o f i n f o r m a t i o n , T h e p u r p o s e o f t h is p a p e r i s t oa n a l y ze th e a l p h a - b e t a p r o c e d u r e i n o r d e r t o o b t a i n s o m e q u a n t i t a t iv ee s t im a te s o f i t s pe r f o r m a nc e c ha r a c te ri s t ic s .

    i This research was supported in part by the National Science Foun dation u nd er grantnumber GJ 36473X and by the O ffice of N aval R esearch under contract N R 044-402.Artificial Intelligence6 (1975), 293-326

    Copyright 1975 by N orth-Holland Pub lishing Com pany

  • 8/14/2019 An Analysis of Alpha-Beta Pruning

    2/34

    2 9 4 D . E . K N UT H A N D R . W . M O OR ESe c t ion 1 de f ine s t he b a s i c c onc e p t s a s soc i a t e d w i th g a m e t ree s . Se c t ion 2

    p r e s e n ts t h e a l p h a - b e t a m e t h o d t o g e t h e r w i t h a r e l a te d t e c h n iq u e w h i c h i ss imi l a r , bu t no t a s pow e r fu l , be c a use i t f a il s t o m a ke " de e p c u to f f s " . Thec o r re c tn e s s o f b o t h m e t h o d s i s d e m o n s t r a t e d , a n d S e c t io n 3 g i ve s e x a m p l e sa n d f u r t h e r d e v e l o p m e n t o f t h e a l g o r i t h m s . S e v e ra l s u g g e s ti o n s f o r a p p l y i n gt h e m e t h o d i n p r ac t ic e a p p e a r i n S e c ti o n 4, a n d t h e h i s t o r y o f a l p h a - b e t ap ru n ing i s d i sc usse d in Se c t ion 5 .

    S e c ti o n 6 b e g i n s th e q u a n t i ta t iv e a n a l y s is , b y d e r i v i n g l o w e r b o u n d s o nt h e a m o u n t o f s e a r ch i n g n e ed e d b y a l p h a - b e t a a n d b y a n y a l g o r it h m w h i c hs o lv e s th e s a m e g e n e r a l p ro b l e m . S e c t io n 7 d e r iv e s u p p e r b o u n d s , p r i m a r i l y b yc o n s i d e r in g t h e c a s e o f r a n d o m t re e s w h e n n o d e e p c u to f f s a r e m a d e . I t i sshow n tha t t he p roc e d ure i s r e a son a b ly e ff ic i en t e ve n u nd e r t he se w e a ka ssum pt ions . Se c t ion 8 show s how to i n t rodu c e so me o f the de e p c u to f fs in tothe a n a lys i s ; a n d Se c t ion 9 show s tha t t h e e f fi ci enc y m pro ve s w he n the re a rede pe nd e nc ie s be tw e e n suc ce ssive mov e s . T h i s p a pe r i s e s se n t ia l l y s e l f-c o n t a i n e d , e x c e p t f o r a f e w m a t h e m a t i c a l r e s u l t s q u o t e d i n t h e l a t er s e c-t ions .

    1 . G a m e s a nd Pos i t i on V a lue sT h e t w o - p e r so n g a m e s w e a r e d e a l in g w i t h c a n b e c h a r a c te r i ze d b y a s e t o f" po s i t i ons " , a n d b y a s e t o f ru l e s fo r m ov in g f rom one pos i t i on to ~ ,nother ,t he p l a ye rs mov ing a l te rna t ely . W e a s su m e tha t n o in f in it e s e que nc e o fpos i t i ons i s a l l ow e d b y the ru l es , 2 a n d tha t t he re a re on ly f i n i t e ly m a n y l e ga lmo ve s f rom e ve ry pos i t ion . I t fo l l ow s f rom the " in f in i t y l e m m a " ( se e [11,Se c t ion 2 .3 ,4 .3 ]) t ha t fo r e ve ry pos i t i on p t he re is a n um be r N (p) suc h tha t nog a m e s t a r ti n g a t p l a st s l o n g e r t h a n N ( p ) m o v e s .

    I f p i s a pos i t i on f rom w hic h the re a re no l e gal mo ve s , the re i s a n i n t ege r -v a l u e d f u n c t i o n f(p) w h ic h re p re se n t s t he valueo f th i s p o s i t io n t o t h e p l a y e rw hose t u rn i t i s to p l a y f rom p ; t he va lue t o t he o the r p l a ye r is as su ra ed to be

    - - - f ( p ) .I f p i s a p os i t i on f rom w hic h the re a re d l e ga l m ove s P l , . , Pd, w he red > 1, t he p ro b le m i s t o c hoose t he " b e s t " move . W e a s sume tha t t he be s tm o v e i s o n e w h i c h a c h ie v e s t h e g r e a te s t p o s s i b l e v a l u e w h e n t h e g a m e e n d s ,i f t h e o p p o n e n t a l s o c h o o se s m o v e s w h i c h a r e b e st f o r h i m . L e t F(p) be t h egre a te s t poss ib l e va lue a c h ie va b le f ro m pos i t i on p a ga ins t t he op t im a ld e f e n si v e s tr a te g y , f r o m t h e s t a n d p o i n t o f t h e p l a y e r w h o i s m o v i n g f r o m t h a t

    2 S t r ic tly speak ing , chess do es no t sa t is fy th i s co nd i t ion , s ince i t s ru les fo r repea tedpos i t ions on ly g ive the p layers the opt ion to reques t a d raw; in ce r ta in c i rcumstances ;i f ne i ther p layer ac tua l ly does ask fo r a d raw,: th e gam e can g o on fo rever . But th i s t echn i -c a l it y i s o f n o p r a c ti c a l i m p o r t a n c e , si n c e c o m p u t e r c h e s s p ro g r a m s o n l y l o o k f in i te l y m a n ym o v e s a h e a d . I r i s p o s s ib l e t o d e a l w i t h in f i n i t e g a m e s b y a s s ig n i n g a p p r o p r i a t e v al u e s t or e p e a t e d p o s i t io n s , b u t s u c h q u e s t i o n s a r e b e y o n d t h e s c o p e o f t h is p a p e r .Artificial Intelligence 6 f1975), 293-326

  • 8/14/2019 An Analysis of Alpha-Beta Pruning

    3/34

    AN ANALYSIS OF ALPHA-BETA PRUNING 295pos i t i on . S ince the va lue . ( to th i s p l aye r ) a ft e r m o ving to pos i t i on P t w i l l be- F ( p l ) , w e h a v e

    ~ f ( p ) i f d = 0, (1)F ( p ) = (max( -F (p l ) , . . . , i f d > 0.

    Thi s f o r m ula se r ves to de f ine F ( p ) f o r a l ! pos i t i ons p , by ind uc t ion on thel e n g t h o f th e l o n g e s t g a m e p l a y a b l e f r o m p .I n m o s t d i scuss ions o f gam e- p lay ing , a s l igh t ly d i f f er en t fo r m a l i sm is u sed ;

    t h e t w o p l a y e rs a r e n a m e d M a x a n d M i n , w h e re a l l v a l u e s a r e g i v en fr o mM a x ' s v i e w p o i n t. T h u s , i f p i s a t e r m i n a l p o s i ti o n w i t h M a x t o m o v e , i t sva lue i s f ( p ) as be f or e , bu t i f p i s a t e r m ina l pos i t i on w i th M in to m ove i t sva lue i s

    g O ' ) = - f ( P ) . (2 )M a x w i l l t r y t o m a x i m i z e t h e f i n a l v a l u e, a n d M i n w i l l t ry t o m i n i m i z e i t.T h e r e a re n o w t w o f u n c t i o n s c o r r e sp o n d i n g t o ( l ) , n a m e l y

    F ( p ) V = ~ f (P ) i f d = 0 ,[ m a x ( G ( p l ) , . . . , G(pd)) i f d > 0, (3)which i s t he bes t va lue M ax can gu a r an tee s t a r ti ng a t po s i t ion p , and

    f g ( p ) i f d = 0 ,G ( p ) = [ .m in( F( p l ) , . . . , F (Pd)) i f d > 0 , (4 )which i s t he bes t t ha t Min can be sur e o f ach iev ing . As be f or e , we a ssum etha t P l , . . , Pa a re the l ega l m o ves f r om po s i t ion p . I t i s e asy to p r ove byinduc t ion tha t t he two de f in i ti ons o f F in (1 ) an d ( 3 ) a r e i den t ica l , and tha tffi - F 0 , ) ( 5 )f o r a l l p . T hus the two appr oach es a r e equ iva len t.

    Som e t im es i t i s e a s ie r t o r ea son abou t gam e- p lay ing by us ing the "m in i -m a x " f r a m e w o r k o f (3 ) a n d (4 ) i n s t ea d o f t h e " n e g m a x " a p p r o a c h o f eq . ( 1 ) ;t he r ea son i s t ha t w e a r e som e t im es le s s conf used i f we cons i s t en t ly eva lua t et h e g a m e p o s i t io n s f r o m o n e p l a y e r ' s st a n d p o in t . O n t h e o t h e r h a n d , f o r m u l a -t ion ( 1 ) i s advan tageous when we ' r e t r y ing to p r ove th ings abou t gam es ,because we do n ' t have to dea l w i th two ( o r som e t im es even f our o r e igh t ) sep-a r a t e ca se s wh en we wan t t o e s t ab l i sh ou r r e su lt s . Eq . ( I ) i s ana log ous tot h e " N O R " o p e r a t io n w h i c h a r is e s i n c ir c u it d e s i g n ; tw o l ev e ls o f N O R l o g ica r e equ iva len t t o a l eve l o f A N D s f o l lowed by a l eve l o f OR~.

    T h e f u n c t i o n F ( p ) i s th e m a x i m u m f i n a l v a l ue t h a t c a n b e a c h ie v e d i f b o t hp laye r s p l ay o p t im a l ly ; bu t we sho u ld r em ar k th a t t h i s r ef lec ts a r a th e rconse r va t ive s t r a t egy tha t won ' t a lways be bes t aga ins t poor p l aye r s o raga ins t the no no pt im a l p l aye r s we encounte r i n the r ea l wor ld . For exam ple ,suppose th a t t he r e a r e two m ov es , to pos i t ions p~ an d P2 , whe re p~ a ssur e s adr aw ( va lue 0 ) bu t cann ot p oss ib ly w in , whi l e P2 g i v e a c h a n c e o f e i t h e rv i ct o ry o r d e f e a t d e p e n d i n g o n w h e t h e r o r n o t t h e o p p o n e n t o v e r lo o k s aArt i f ic ia l In te l l igence 6 (1975), 293-326

  • 8/14/2019 An Analysis of Alpha-Beta Pruning

    4/34

    2 9 6 D . E . K N U T H A N D R . W . M O OR E

    r a t h e r s u b t le w i n n i n g m o v e . W e m a y b e b e t t e r o f f g a m b l i n g o n t h e m o v e toP2, w h i c h is o u r o n l y c h a n c e t o w i n , u n le s s w e a r e c o n v i n c e d o f o u r o p p o n e n t ' sc o m p e t e n ce . I n d e e d , h u m a n s s e e m t o b e a t c h e s s- p la y i n g p r o g r a m s b y a d o p t i n gsuch a s t ra tegy.

    2 . D e v e l op m e n t o f t h e A l g o r it h mThe f o l lowing a lgor i thm ( expre ssed in an ad- h oc ALGOL-like l~ngnage )c l ea r ly com pute s F(p) , by f o l lowing de f in i t i on ( 1 ):integ er procedmre F (posi t ion p) :

    beg in in teger m, i , t, d ;d e t e rm i n e th e s u c ce s so r p o s i ti o n s P i , - . . , P ~;i f d = 0 th e n F : = f ( p ) e l s ebeg in m :ffi - Q o ;

    fo r i : - - 1 s te p 1 unt i l d dob e g i . t :f fi

    i f t > m t h e n m : = t ;e n d ;

    F : - " m;e n d ;

    e n d .Her e Qo deno te s a v a lue tha t i s g r ea t e r t ha n o r equa l t o ] f ( P ) l f o r a l l t e r m in a lp o s i ti o n s o f th e g a m e , h e n c e - u3 is le s s t h a n o r e q u a l t o + F ( p ) f o r a l l p .T h i s a l g o r i t h m i s a " b r u t e f o r c e " s e a r c h th r o u g h a l l p o s s i b le c o n t i n u a t i o n s ;the in f in i ty l em m a a ssur e s us t ha t t he a lgor i thm w i l l t e r m ina te i n f in i t e lym a n y s te p s.

    I t i s p o s s ib l e t o i m p r o v e o n t h e b r u te - fo r c e s e a r ch b y u s i n g a " b r a n c h - a n d -b o u n d " t e c h n i q u e [ 14 ], ig n o r i n g m o v e s w h i c h a r e i n c a p a b l e o f b e i n g b e t t e rt h a n m o v e s w h i c h a r e a l r e a d y k n o w n . F o r e x am p l e, i f F ( p i ) = - 1 0 , t h e nF(p) >i 1 0, a n d w e d o n ' t h a v e t o k n o w t h e e x a c t V alu e o f F ( p 2 ) i f w e c a nded uce tha t F (p2) >I - 10 ( i .e . , tha t - F ( p z ) ~ 1 0 ) . T h u s i f P ~ t i s a l e g alm o v e f r o m P2 s u c h t h a t F(P zl)( ~rbound. (6)Arti f ic ial Inte l l igence6 (1975) , 293.326

  • 8/14/2019 An Analysis of Alpha-Beta Pruning

    5/34

    AN ANALYSIS OF ALPHA-BETA PRUNING 297Th ese relat ions d o no t ful ly define F1 , b ut th ey are sufficiently pow erful tocalculate F ( p ) for any s ta r t ing pos i t ion p because they im ply tha t

    F l ( p , o o ) = F ( p ) . (7 )The fol lowing a lgor i thm corresponds to th i s branch-and-bound idea .integ er procedure F I (positioRp, integer bound):begin integer m, i , t , d;

    de te rmine the successor pos i t ions P l , . . , P j"i f d = 0 t h e n F l : = f (p ) e l sebegin m : - - - o o ;

    f o r i : = 1 step 1 nntil d d obegin t : = - F l ( p t , : m ) ;

    i f t > m t h e n m : = t ;i f m >i bound then go to done ;end;d o n e : F I : = m ;end;

    e n d .W e can p rove th a t th i s procedure satis fies (6) by a rguing as follows: A t thebeg inn ing o f t he t t h i te ra ti on o f t he fo r loop , w e have t he " in va r i a n t "c o n d i t i o n

    m = m a x ( - F ( p l ) , . . . , - F ( p H ) ) (8)jus t as in procedure F . (The m ax opera t ion over an em pty se t is conven t iona l lyd e f i n e d t o b e - o o . ) F o r i f , F ( p t ) i s >m, t hen F l ( p i , - m ) = F (p~), b ycondi t ion (6) and induct ion on the length of the gam e fol lowing p; therefore(8 ) w ill h o ld o n t h e n e x t i te ra ti on . A n d i f m a x ( - F ( p l ) , . . . , - F ( p i ) ) > ~ b o u n dfor an y i , then F(p ) >t bound . I t fol lows tha t cond i t ion (6) holds fo r a l l p.The procedure can be improved fur ther i f we int roduce both lower an duppe.r bounds; this idea, which is cal led alpha-beta pruning, is a significantextens ion to the one-s ided branch-and-bound method. (Unfor tuna te ly i tdoesn ' t apply to a l l branch-and-bound a lgor i thms, i t works only when agam e tree i s be ing explored. ) We define a procedure F 2 of three param eters p ,alpha, and beta , fo r alpha < beta , sat isfying the fol lowing condi t ionsana logous to (6) :F 2( p, alpha, be ta)

  • 8/14/2019 An Analysis of Alpha-Beta Pruning

    6/34

    2 9 8 D . E . K N U T H A N D R . W . M O O R E

    in tege r p rocedure F2 (pos it ion p , in teger a lpha , in teger be ta ) :begin in teger m, i , t, d ;

    de te rm ine th e successor p os i t ions p 1 , . , Pa ;i f d = 0 t h e n F 2 : = f ( p ) e l s ebeg in m := a lpha;f o r i : - 1 s t e p 1 u n t i l d d o

    b eg i n t : = - F2 (p l , - - b e t a , - m ) ;i f t > m t h en m : = t ;i f m >1 b e ta t h en g o t o d o n e ;

    end ;d o n e : F 2 : = m ;e n d ;

    e n d ;T o p r o v e th e v a l i d i t y o f F 2 , w e p ro c e e d a s w e d i d w i t h F I . T h e i n v a r i a n tr e l a t ion ana log ous to ( 8) is now

    m = m a x ( a l p h a , - F ( P i ) , . . . , - F ( p ~ - I ) ) ( 1 1 )a n d m < beta . I f - - F ( p ~ >i b e ta , t h e n - F 2 ( p l , - b e t a , - m ) wi l l a l so be>~beta, a nd i f m < - F ( p i ) < b e t a , t h e n - F 2 ( p t , - b e t a , - m ) = - F ( p t ) ; sothe p r oo f goes th r ou gh a s be f ore , e s t ab l i sh ing (9 ) by induc t ion .

    N o w t h a t w e h a v e f o u n d t w o i m p r o v e m e n t s o f t h e m i n i m a x p r o c e d u re ,i t i s na tu r a l t o a sk wh e the r s t i ll f u r the r im pr o vem ent is poss ib l e . I s the r e an" a l p h a - b e t a - g a m m a " p ~ ' o c e d u r e F 3 , w h i c h m a k e s u s e s a y o f t h e s e c o n d -

    l a r g e s t v a l u e f o u n d s o f a r , o r s o m e o t h e r g i m m i c k ? S e c ti o n 6 b e l o w s h o w stha t t he answer i s no , o r a t l e a s t t ha t t he r e i s a r ea sonab le sense in whichp r o c e d u r e F 2 i s o p t i m u m .3 . Exam ples and Re f inem ent s

    A s a n e x a m p l e o f t h e s e p ro c e d u re s , c o n s i d e r t h e t r e e i n F i g , 1 , w h i c h r ep r e -sen t s a p os i t i on tha t ha s t h r ee successors , e ach o f which ha s th r ee successor s ,e t c. , un t i l we ge t t o 34 = 81 pos i ti ons~poss ib l e a f t e r f ou r m ov es ; and the se8 1 p o s it i o n s h a v e b e e n a s s i g n e d ' , r a n d o m ' , f v a l u e s a c c o r d i n g t o t h e f i rs t I]1d i g it s o f n . F i g , 1 s h o w s t h e F v a l u e s c o m p u t e d f r o m t h e f ' s ; t h u s , t h e r o o tn o d e a t t h e t o p o f t h e t r ee h a s a n e ff ec ti ve v a l u e o f 2 a f t e r b e s t p l a y b y b o t hsides.

    F ig . 2 sho ws th e sam e s i tua t ion a s i t i s eva lua ted b y p r o ced ur e F I Cp, oo).N o t e t h a t o n l y 3 6 o f t h e 81 t e rm i n a l p o s it i o n s a r e e x a m i n e d , a n d t h a t o n eo f t h e n o d e s a t l e ve l 2 n o w h a s t h e " a p p r o x i m a t e " v a i u e 3 i n s t e a d o f it s tr u ev a l u e 7 ; b u t t h i s a p p r o x i m a t i o n d o e s n o t o f c o u rs e a ff ec t t h e v a l u e a t t h e t o p .

    F i g : 3 s h o w s t h e s a m e s i t u a t i o n a s i t i s ev a l u at e d b y t h e f u l l a l p h a - b e t ap r u n i n g p r o c e d u re . F 2 ( p, - o o , + o o) w i l l a l w a y s e x a m i n e t h e s a m e n o d e s a sF l ( p , o o) u n t i l t h e f o u r t h l ev e l o f l o o k a h e a d i s r ea c he d , i n a n y g a m e t r ee ;Artificial lntell~ence 6 (1975) , 293-326

  • 8/14/2019 An Analysis of Alpha-Beta Pruning

    7/34

    AN ANAE YSI S OF AL P HA-B E T A P R UNI NG 2 9 9th is i s a consequence o f the the ory developed below. O n levels 4 , 5 , . . . ,however , procedure F2 is occas ional ly able to make "deep cutof fs" whichF I i s incapable of finding. A com par ison of Fig . 3 wi th Fig . 2 ~hows tha tthe re are f ive deep cutoffs in this example.

    2

    11/\ /iX / i X / / X / i X / N I N / ~ \ / ~ \- 1 - 1 - 2 - 3 - 7 - 2 - 4 - 2 - 3 - 2 - 0 - 2 - 1 - 1 - 3 - 3 - 0 - 2 - 0 - 4 - 4 - 0 - 1 - 0 - 2 - 0 - 80 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

    F i G . I . C o m p l e t e e v ~ t l u a ti o a o f a g a m e t r e e .2

    - 2 2. i . / \ /e , . , . / \ .., .,._ ~ / ! i ! i " -/ i N , , , , . ,- 1 - 1 - 2 - 3 , , - 4 , - 2 - o - 2 I ~\ I : ~ , - - . . - o - l - o , , e / t e / t i ~ - . - e *

    /~ , ~ ' , ~ , , ~ , , , , , ,~ , , , , , ~ ' h , ; :~ ~ ~ ~ '3141 263358 846 3279502 0974944 230781640F=G. 2. Tit=' : : , u n e t r e e o f F ig . 1 e v a lu a t e d w i th p r o c e d u r e F I ( b r a n c h - a n d - b o u n d s tr a t e g y ) .

    . . 1 t / \ , . '" : " - . / \ " ' -2 / i \ 2 ~ . , 4 /

    , - , , ,I \ ;~', ;,",', I ~ \ , ~ \ , , ,--1 . 1 - 2 - 2 r t - 2 I . 2 - 0 - 2 s i: ~ e ' ~ , - 0 - 4 - 4 - 2 - 1 - 0 i* t ,O O O O | ~ 0 ~ % O O O t : \ o o e o O o ~ , ,/ ~ ~ , , / ~ ~ , ~ , ~ , , ~ : t , , ~ , ,~ , / ~ ~ , ; ~ , , ~ , , A ~ , , ~ ,A ,,o ~ , ~ , p , , ~ ~ ; ~ , , ~ , , ~ , ,3 1 4 1 2 65 3 58 8 4 6 3 2 9 5 0 2 ,1 ~ I I , , i t 2 7 81 64 0]F IG . 3 . T h e g a m e t r e e o f F ig . 1 e v a lu a t e d w i th p r o c e d u r e F 2 ( ~ d p ha - b et a s t r at e g y ) .

    All of these i l lus t ra t ions present the resul ts in terms of the "negamax"mo del of Sect ion 1; i f the reader prefers to see i t in " m inim ax" terms , i t i ssuff icient to ignore al l the m inus s igns in Figs. 1-3. Th e proc edure s of Sec tion 2can readi ly be con ver ted to the minim ax convent ions , for example by replac '-ing F2 l :y the following two proced ures : Art i f ic ia l In te l l igence 6 (1975), 293-326

  • 8/14/2019 An Analysis of Alpha-Beta Pruning

    8/34

    3 0 0 D . E . K N U T H A N D R . W . M O O RE

    i n t e g e r p r o c e d u r e F 2 ( p o s i t io n p , i n t e g e r a lpha , i n t e g e r b e t a ) :b e g i n i n t e g e r m , i , t , d ;

    d e t e r m i n e t h e s u c c e s s o r p o s i t i o n s P l , . , P ~ ;i f d = 0 t h e n F 2 : - - f ( p ) elseb e g ~ m : = a l p h a ;f o r i : - 1 s t e p 1 u n t i l d d o

    beg in t : = G2(ps , m , be ta ) ;i f t > m t h e n m : = t ;i f m >I be ta t h e n g o t o d o n e ;

    e n d ;d o n e : F 2 : - m ;e n d ;

    e n d ;i n t e g e r p r o c e d u r e G 2 ( p o s it io n p , i n t e g e r a lpha , i n t eger be ta ) ;b e g i n i n t e g e r m, i , t , d ;

    d e te r m in e t h e su c ce s so r p o s i t i o n s p l , . . . , P d;i f d = 0 t h e n G 2 : = g ( p ) e l seb e g i n m : - b e t a ;

    f o r i : = 1 s t e p 1 u n t i l d d ob e g i n t : - F 2 ( p ~ , a l ph a , m ) ;

    i f t < m t h e n m : = t ;i f m ~ a l p h a t h en g o t o d o n e ;

    e n d ;d o n e : F 2 : = m ;e n d ;

    e n d .I t i s a s i m p l e b u t i n s t r u c t i v e e x e r c i s e t o p r o v e t h a t G 2 ( p , a lpha , be ta ) a l w a y se q u a l s - F 2 ( p , - b e t a , - a lp /~ ) ,

    T h e a b o v e p r o c e d u r e s h a v e m a d e u s e o f a m a g i c r o u ti n e t h a t d e te r m i n e st h e s u c c e s s or s P l , - . , P J o f a g i ve n p o s i t i o n p . I f w e w a n t t o b e m o r e e x p l ic ita b o u t + ho w p o s i ti o n s a r e r e p r e s e n t e d , i t i s n a t u r a l t o u s e t h e f o r m a t o fl i n k e d r e c o r d s : W h e n p i s a r e f e r e n c e t o a r e ~ r d d e n o t i n g a p o si ti o n , l e t

    f i r s t ( p ) b e a r e f e r e n c e t o t h e f ir s t s u c c e s s o r o f t h a t p o s i t i o n , o r A ( a n u l lr e f e r e n c e ) i f t h e p o s i t i o n i s te r m i n a l . S i m i l a r l y i f q re f e r e n c e s a s u c c e s s o r p+o f p , l et n e x t ( q ) b e a r e f e r e n c e t o t h e n e x t s u c c e s so r P ++ I, o r A i f i - d .F i n a l l y l e t g e n e r a t e ( p ) b e a p r o c e d u r e t h a t c r e a t e s t h e r e c o r d s f o r P t , . . . , P J ,s e t s t h e i r n e x t f i e l d s , a n d m a k e s f i r s t( p ) p o i n t t o P l ( o r t o A i f d = 0 ) . T h e nt h e a l p h a - b e t a p r u n i n g m e t h o d t a k e s t h e f o ll o w i n g m o r e e x p l i ci t f o r m .i n te g e r p ro c e d u re F 2 ( t e l ( p o s i t i o n ) p , i n t e ge r a lpha , i n t e g e r b e t a ) :

    b e g i n i n t e g e r m , t ; r e f ( p o s i t io n ) q ;g en er a t e ( p ) ;q : = f i r s t ( p ) ;

    A r t i f i c i a l I n t e l l i g e n c e 6 (1975) , 293-326

  • 8/14/2019 An Analysis of Alpha-Beta Pruning

    9/34

    AN ANALYSIS OF ALPHA-BETA PRU NING 301i f q = A t h e n F 2 : = f ( p ) elsebeg in m := a l p h a ;

    while q ~ A a n d m < b e t a dobeg in t : - - F 2 ( q , - b e t a , - m ) ;i f t > m th e n m : = t ;q : - n e x t ( q ) ;e n d ;F 2 : = m ;

    end ;end.I t i s i n t e r e s t ing to conve r t t h i s r ecur s ive p r ocedur e to an i t e r a t ive ( non-r ec u rs iv e ) f o r m b y a s e q u en c e o f m e c h a n i c a l t r a n s fo r m a t i o n s , a n d t o a p p l y

    s im ple op t im iza t ions wh ich p r e se rve p r ogr am cor r ec tness ( see [ 13]) . Th er e su l t ing p r oced ur e i s su r pr i s ing ly s im ple , bu t no t a s ea sy to p r ove cor r ec t a sthe r ecur s ive f o r m :integer procedure a l p h a b e t a (ge l (pos i t ion) p ) ;

    b e g i n i n t e g e r I ; .o m m e n t l evel o f r ecur s ion ;i n te g e r a r r a y a [ - 2 : L ] ; c o m m e n t s t a c k fo r r ec u r si o n , w h e r e

    a l l - 2], a [ ! - 1], a l l ] , a l l + 1] deno te respe c t ive lya l p h a , - b e t a , m , - t i n p r o c ed u r e F 2 ;r e f ( pos i t ion) a r r ay r [ 0 :L + 1 ] ; com m ent ano the r s t ack f o rr ecur s ion , w he r e r i l l a n d r [ l + 1] deno te respec t ive lyp a n d q i n F 2 ;1 : = 0 ; a [ - 2 ] : = a [ - l ] : - - o o ; r[0] : = p ;

    1 : 2 : g e n e r a t e ( r i l l ) ;r [ / + 1 ] : - f i r s t ( r i l l ) ;i f r [ l + 1 = A then a [ l ] : = f ( r [ l ] ) e l s eb e g i n a [ l ] : = a [ / - 2 ];

    l o o p : 1 : = 1 + I ; g o t o F 2 ;r es u m e : i f - a l l + 1 ] > a l l ] t h e n

    b e g i n a l l ] : = - a l l + 1 ];i f a l l + 1] ~ a [ ! - 1] then go to d on e ;e n d ;

    r [ I + 1] := n e x t ( r [ 1 + 1]);i f r [ l + 1 :P A t h e n g o t o l o o p ;

    end;do ne: l : = I - 1 ; i f 1 t> 0 then go to resu m e;a l p h a b e t a : - a [ 0] ;

    end.T h i s p r o c e d u re a l p h a b e t a ( p ) wi l l com pute the sam e va lue a s F2( p , - oo, + oo) ;we m u s t choose L l a r ge enoug h so tha t t he l evel o f r ecur s ion nev e r exceeds L .Ar t i f lda l In te l ligence 6 (197~ , 293-326

  • 8/14/2019 An Analysis of Alpha-Beta Pruning

    10/34

    302 D.E. KNUTH AND R, W. MOORE4. Appl icat ions

    W he n a c om pute r i s p l a y ing a c om ple x ga me , i t w i l l r a re ly be a b l e t o :;e arch a l lposs ib i l i t i e s un t i l t ru ly t e rm ina l pos i t i ons a re r e a c he d ; e ve n the a lpha -b e t at e c hn iq ue w o n ' t b e l a s t e no ugh to so lve t he ga m e o f chess:! Bu t w e c a n s t i llu se t he a bove p roc e dure s , i f t he rou t ine t h a t ge ne ra t e s a l l mo ve s i s mo d i f i e dso tha t suff ic ient lyde e p pos i t i ons a re c ons ide re d to be t e rmina l . Fo r e xa m ple ,i f w e w i s h to l o o k s i x m o v e s a h e a d ( th r e e f o r e a c h p l a y e r) , w e c a n p r e t e n dtha t t he pos i t i ons re a c he d a t l e ve l 6 ha ve n o suc ce sso rs. To c om pute f a tsuc h a r t i f ic i a l ly - t e rmina l pos i ti ons , w e m us t o f c ourse use our be s t gue ssa b ou t t he va lue , hop ing tha t a su f f ic i e n tly de e p se a rc h w i l l a me l io ra t e t hei n a c c u r a c y o f o u r g u e ss . ( M o s t o f t h e t i m e w i ll b e s p e n t i n e v a l u a t i n g t h e seg u e s se d v a lu e s f o r f , u n l e s s t h e d e t e r m i n a t i o n o f l e g al m o v e s i s e s p ec ia l lyd i f fi c u lt , so som e qu ic k ly -c om pute d e s t ima te i s ne e de d .)

    Ins t e a d o f s e a rc h ing to a f i xe d de p th , i t i s a lso poss ib l e t o c a r ry some l i ne sfu r the r , e . g ., t o p l a y ou t a l l s e quenc e s o f c a p tu re s . A n in t e re s ti ng a ppro a c hw a s sugge st e d by F lo yd in 1965 [6] ), a l t ho ug h i t ha s a p pa r e n t ly no t ye t be e nt r i e d i n l a rge -sc a le e xpe r ime n t s . Ea c h m ov e in F loy d ' s s c he m e is a s s igne d a" l i k e l i h o o d " a c c o r d i n g t o t h e f o l l o w i n g g e n e r a l p l a n : A f o r c e d m o v e h a s" l i ke l iho od " o f 1 , w h i l e ve ry im pla us ib l e mov e s ( li ke que e n sa cr if ic e s i nc he ss ) ge t 0 .01 o r so . In c he ss a " re c a p tu re " ha s " l i k e l iho od " g re a t e r t ha n ~ ;a n d the be s t s t r a te g i c c ho ic e ou t o f 20 o r 30 poss ib il it i es ge t s a " l i k e l iho od "o f a bo u t 0 .1 , w h i l e t he w ors t c ho ic e s ge t s a y 0 .02 . W he n the p ro duc t o f a l l" l i ke l ihoods" l e a d ing to a pos i t i on be c ome s l e s s t ha n a g ive n th re sho ld( sa y 1 0-s ) , w e c ons ide r t ha t pos i t i on to be t e rmin a l a n d e s t ima te i ts va luew i t h o u t f u r t h e r s e a rc h in g . U n d e r t h i s s ch e m e , th e " m o s t l i k e l y " b r a n c h e s o fthe t re e a re g ive n the m os t a t t e n t ion .

    W h a t e v e r m e t h o d i s u s e d t o p r o d u c e a t re e o f r e a s o n a b l e s iz e , t h e a l p h a -b e t a p r o c e d u r e c a n b e s o m e w h a t im p r o v e d i f w e h a v e a n i d e a w h a t t h e v a l u eo f t h e i n i ti a l p o s i t io n w i ll b e . I n s t e a d o f c a ll i n g F 2 ~ , , o 0, . + ~ ) , w e c a nt r y F 2 ( p , a , b ) w h e r e w e e x p e ct t h e v a l u e t o b e g r e a te r t h a n a a n d l e s s t h a n b .F o r e x a m p l e , i f F 2 ( p , 0, 4 ) is u s e d i n s te a d o f F 2 ( p , - 1 0 , + 1 0 ) i n F i g . 3 , t h er i g h tm o s t " - 4 " o n l e v el 3 , a n d t h e " 4 " b e lo w it, d o n o t n e e d t o b e c o n -s id e r ed . I f o u r e x p e c ta t io n i s f u lf il le d , w e m a y h a v e p r u n e d o f f m o r e o f t h et r e e ; o n t h e o t h e r h a n d i f t h e v al u e t u r n s o u t t o b e lo w , s a y F 2 ( p , a , b ) f f i v ,wh ere v ~< a , w e can u se F 2 ( p , - c o , v ) t o d e d u c e th e c o r r e c t v a lu e . T h i s i d e aha s be e n u se d in some ve rs ions o f G re e n b la t t ' s c he ss p ro gra m [8] .

    5 . His tory --Be fo re w e be g in t o m a k e qua n t i t a ti ve a n a lyse s o f a lpha -be t a ' s e ffe ct ive ne ss ,l e t u s l o o k b r i e f ly a t i t s h is t o r ic a l d e v e l o p m e n t . T h e e a r l y h i s to r y i s s o m e w h a to b s c u r e , b e c a m e i t i s b a s e d o n u n d o c u m e n t e d r e c o l l e c ti o n s a n d b e c a u s eArt i f ic ia l In te l l igence 6 (1975), 293--326

  • 8/14/2019 An Analysis of Alpha-Beta Pruning

    11/34

    A N A N A L Y S IS O F A L P H A -B E TA P R U N I N G 3 0 3

    some peop le have confused p rocedure F1 wi th the s t ronger p rocedure F2 ;therefore the fo l lowing account is based on the bes t informat ion now avai l -able t o t h e a u t h o rs.M c C a r t h y [ 1 5 ] t h o u g h t o f t h e m e t h o d d u r in g t h e D a r t m o u t h S u m m e rResearch Conference on Art i fic ia l In te l ligence in 195 6, when Berns teindescribed an ea r ly ches s p rogram [3] which d idn ' t u se any so r t o f a lpha-be ta .McCar thy "cr i t ic ized i t on the spot for th is [ reason] , but Berns te in was notconvinced. No form al specif ication o f th e a lgor i thm was given at th at t im e."I t is p laus ib le tha t M cC ar thy ' s r ema rks a t tha t conference led to the use o falpha-beta pruning in gam e-playing prog ram s o f the . la te 1950s . Samuel h ass ta ted that the idea was present in h is checker-playing programs, but he d idno t allude to i t in his classic art icle [21] because he felt tha t th e oth er aspec tso f h is program were m ore s ignif icant .

    The f i rs t publ ished discuss ion of a m etho d fo r game t ree pruning ap pearedin Newell, S haw and Simo n 's descr ip t ion [16] of their ear ly chess p rogram .However , they i l lus t ra te only the "one-s ided" technique used in procedureF1 above , so i t is no t c lear whether they made use o f "d eep cu to f fs " .McCar thy co ined the name "a lpha-be ta" when he f i r s t wro te a L ISpprogram embodying the t echn ique . H is o r ig ina l approach was somewhatmore e laborate than the method descr ibed above, s ince he assumed theexis tence of two funct icns " o p t i m i s t i c v a l u e ( p ) " a n d " ' p e s s i m i s t i c v a l u e ( p ) ' "which were to be upp er and low er bounds on the va lue o f a pos i t ion .M cCa r thy ' s fo rm o f a lpha-beta s earch ing was equ iva len t to r ep lac ing thea b o r t: b o d y o f pr o c e d u re F 2 b y

    i f o p t i m i s t i c v a l u e ( p ) >. b e t a t he n F 2 : = b e t ae lse beg in < the above b ody o f p rocedure F 2 ) end .

    Because of th is e laborat ion, he thoug ht of a lpha-be ta as a (poss ib ly in-accurate) heur is tic device, not real iz ing that i t would a lso produce the samevalue as fu l l minimaxing in the special case that o p t i m i s t ic v a l u e ( p ) = + o oa n d p e s s i m i s t i c v a l u e (p ) = - c o for a l l p . He credi ts the la t ter d iscovery toH ar t a nd E dwards , who wro te a m em oran dum [10] on the sub jec t in 1961 .The i r unpub l i shed mem orandum g ives examples o f the genera l method ,inc lud ing deep cu to f fs ; bu t ( as usua l in t961) no a t t em pt was mad e toind icate why the method wo rked , much les s to dem ons t ra te i ts va l id i ty .Th e f ir s t pub l i shed accoun t o f a lpha-be ta p run ing ac tua l ly appeared inRuss ia , qu i te independen t ly o f the Am er ican work . Brudno , who w asone o f thedevelopers of ai~ ear ly R uss ian chess-playing program , descr ibed an algor i thmident ical tO alpha-b eta pruning, together with a ra the r com plicated p roof , in1963 (see [4]).

    The fa l l a lpha-be ta p run ing techn ique f ina lly appeared in "W es te rn "Artificial lnteUlgenc 6 (1975) , 293-326

  • 8/14/2019 An Analysis of Alpha-Beta Pruning

    12/34

    304 D .E . K N U T H A N D R . W. MO OR Ec o m p u t e r - s c i e n c e l i t e r a t u r e i n 1 9 6 8 , w i t h i n a n a r t i c l e o n t h e o r e m - p r o v i n gs t r a te g i e s b y S l a g le a n d B u r s k y [ 24 ], b u t t h e i r d e s c r i p t i o n w a s s o m e w h a tv a g u e a n d t h e y d i d n o t i l l u s t r a t e d e e p c u t o f f s . T h u s w e m i g h t s a y t h a t t h ef i r s t r e a l E n g l i sh d e s c r ip t i o n s o f t h e m e t h o d a p p e a r e d i n 1 96 9, i n a r ti c le s b yS l a g le a n d D i x o n [2 5] a n d b y S a m u e l [ 2 2 ]; b o t h o f t h e s e a r t ic l e s c le a r l ym e n t i o n t h e p o s s i b if i ty o f d e e p c u to f f s , a n d d i sc u s s t h e i d e a i n s o m ed e t a i l .

    T h e a l p h a - b e t a t e c h n i q u e s e e m s t o b e q u i t e d i f f i c u l t t o c o m m u n i c a t ev e r b a l l y , o r i n c o n v e n t i o n a l m a t h e m a t i c a l l a n g u a g e , a n d t h e a u t h o r s o ft h e p a p e r s c it e d a b o v e h a d t o r e s o r t t o r a t h e r c o m p l i c a t e d d e sc r i p ti o n s ;f u r t h e r m o r e , c o n s i d e r a b l e t h o u g h t s e e m s t o b e r e q u i r e d a t f i rs t e x p o s u r et o c o n v i n c e o n e s e l f t h a t t h e m e t h o d i s c o r r e c t , e s p e c ia l ly w h e n i t h a s b e e nd e s c r i b e d in o r d i n a r y l a n g u a g e a n d " d e e p c u t o f f s " m u s t b e j u s ti f ie d . P e r h a p st h i s is w h y m a n y y e a r s w e n t b y b e f o r e t h e t e c h n iq u e w a s p u b l is h e d . H o w e v e r ,w e h a v e s e en i n S e c t io n 2 t h a t t h e m e t h o d is ea s il y u n d e r s t o o d a n d p r o v e dc o r r e c t w h e n i t h a s b e e n e x p r e s ~ d i n a l g o r i t h m i c l a n g u a g e ; t h i s m a k e s ag o o d i ll u s tr a ti o n o f a c a s e w h e re a " d y n a m i c " a p p r o a c h t o p r o c e s s d e s c ri p ti o ni s c o n c e p t u a ll y s u p e r i o r t o t h e " ' s ta t i c " a p p r o a c h o f c o n v e n t i o n a l m a t h e -m a t i c s .

    E x c e ll en t p r e s e n t a ti o n s o f t h e m e t h o d a p p e a r i n t h e f e i n t t e x tb o o k s b yN i l s s o n [18 , S e c t i o n 4 ] a n d S l a g le [2 3 , p p . 1 6 -2 4 ], b u t i n p ro s e s t y l e i n s t e a d o ft h e e a s i e r - to - u n d e r s t a n d a l g o ri th m i c f o r m . A l p h a - b e t a p r u n i n g h a s b e c o m e" 'w e l l k n o w n " ; y e t to t h e a u t h o r s ' k n o w l e d g e o n l y t w o p u i~ l is he d d e s c r i p t io n sh a v e h e r e t o f o r e b e e n e x p r e s se d i n a n a l g o r i th m i c l a n g u a g e . I n f a c t t h e fi rs to f t h e s e , b y W e l l s [2 7 , S e c t i o n 4 . 3 . 3 ] , i s n ' t r e a l l y t h e fu l | a l p h a -b e t a p ro -c e d u r e , i t i s n ' t e v e n a s s t r o n g a s p r o c e d u r e F I . ( H o t o n l y i s h i s a l g o r i t h mi n c a p a b l e o f m a k i n g d e e p c u t o f f s , i t m a k e s s h a l l o w c u t o f f s o n l y o n s t r i c ti n e q u a l i ty . ) T h e o t h e r p u b l i s h e d a l g o r i t h m , b y D a h l a n d B e l sn e s [ 5, S e c t i o n8 . i] , a p p e a r s i n a r e c e n t N o r w e g i a n - la n g u a g e t e x t b o o k o n d a t a s t r u c tu r e s ;h o w e v e r , t h e a l p h a - b e t a m e t h o d i s p r e s e n t e d u s i n g i a b = l p a. ~ m e t e r s, s o t h ec o r r e s p o n d in g p r o o f o f c o r re c tn e s s b e c o m e s s o m e w h a t d i f f i c u l t . A n o t h e rr e c e n t t e x t b o o k [ 1 7, S e c ti o n 3 .3 .1 ] c o n t a i n s a n i n f o r m a l d e s c r i p t io n o f w h a ti s c a ll ed " a l p h a - b e t a p r tm i n g " , b u t a g a i n o n l y . t h e m e t h o d o f p r o c ed u r eF 1 i s g i v e n ; a p p a r e n t l y m a n y p e o p l e a r e u n a w a r e t h a t ~ th e a l p h a - b e t ap r o c e d u r e i s c a p a b l e o f m a k i n g d e e p c u t o f fs , s F o r t h e~ e r e a s o n s , t h e a u t h o r so f t h e p r e s e n t p a p e r d o n o t f e e ~ t r e d u n d a n t t o p r e s e n t a n e W e x p o m to r ya c c o u n t o f t h e m e t h o d , e v e n t h o u g h a l p h a - b e t a p r u n i n g h a s b e e n i n u s e f o rm o r e t h a n 1 5 y e a r s.

    s ~ d e ~ o n e o f t h e a u t ho r s o f t h e p r e s e n t P a p e r 0 D . E . K . ) d i d s o m e o f t h e re s e ar c hdescribed in Section 7 approxinuttelyfive ~ befo re he wa s awar~.~ hat de ep cuto ffswere possible. It is easy to understand procedm e F1 and to associate i t w ith the term"'alpha-beta pruning " yo ur colleagues are talking abou t, without discoveringF2.A r tO ~ ! Inte lligence6 (197 5), 293--326

  • 8/14/2019 An Analysis of Alpha-Beta Pruning

    13/34

    AN ANALYSIS OF ALPHA-BETA PRU NIN G 30 5

    6. Analysis of t h e Bes t CaseNo w le t us tu rn to a quan t i t a t ive s tudy o f the a lgor i thm. How much o f thetree needs to be exam ined ?Fo r th is purpose i t i s conven ien t to as sign coord ina te numb ers to the nodesof the t r ee as in the "De wey dec imal sys tem " [11 , p . 310]: Every pos it ion o nlevel l is assign ed a sequence o f po sitive integers ax a2 a t . The roo t node( the s tar t ing pos i t ion) corresponds to the em pty sequence, a nd the dsuccessorso f pos i tion a l . . . a t a re as signed the respec tive coord ina tes a t . . . a t l , . , a i . . . . a ~d . Thus , pos i t ion 314 is reached af ter making the th i rd poss ib lemove f rom the s tar t ing pos i t ion , then the f i r s t move f rom that pos i t ion , andthen the four th .Let us cal l pos i t ion a t . . . a t c r i t i c a l if a~ ffi I for all even values of i or foral l od d values of L Thus , pos i t ions 21412, 131512, 11121113, and 11 arecr i tical , and th e ro ot pos i t ion is a lways cr i t ical; bu t 12112 is not , s ince i t hasno n- l ' s in bo th even and odd pos i tions . The r e levance o f th i s concep t i s dueto the fo l lowing theorem , w hich character izes the act ion ok" a lpha-b etaprun ing when we a re lucky enough to cons ider the bes t move f i r s t f romevery pos i t ion .

    TH~OP,ZM 1. C o n s i d e r a g a m e t r e e f o r w h i c h t h e v a lu e o f th e r o o t p o s i t io n i sn o t + _-oo, a n d f o r w h i c h t h e f i r s t s u c c e s s o r o f e v e r y p o s i t i o n i s o p t i m u m ; i . e .,

    ~ f ( a z . . . a t ) i f a t . . . a4 i s t e r m i n a l , (12)F ( a i . . . a t) "= [ - F ( a l . . . a j l ) o t h e r w i s e .

    T h e a l p ha - b e ta p r o c e d u r e F 2 e x a m i n e s p r e c i s e ly t h e c r i t ic a l p o s i ti o n s o f t h i sg a m e t r e e .

    P r o o f . Let us s ay tha t a c ri ti ca l pos i t ion a i . . . a t i s o f type 1 i f a l l the a iare 1 ; i t i s of type 2 i f a t i s i t s f i r st en try > 1 and I - j i s even; o therwise ( i .e . ,wh en l , j i s odd, hence a t = I ) i t is of type 3 . I t i s easy to es tabl ish thefo llowing fac ts by ind uc t io n on the comp uta t ion , i .e ., b y showing tha t theyare inva r ian t as se rt ions:

    (1) A type i pos i tion p i s exam ined by cal ling F2(p , - ~ , + oo) . I f i t i s no tt e rm i n a l, i ts s uc c es so r p o s i t i o n p l i s o f t y p e 1, a n d F ( p ) = - F ( p 0 # + o o .The other succesror pos i t ions p , . . . , P d a r e o f t y p e 2 , a n d t h e y a r e a l lexamined by can ing F2(p i , - -o~ , F (p l ) ) .

    (2) A type 2 pos i t ion p is examined by cal l ing F 2 ( p , - c o , b e t a ) , where- Qo < beta t F ( p ) . I f i t i s no t term inal , each o f i ts successor pos i t ions Pli s o f type 2 and they a re a ll examined b y ca l l ing F 2 ( p i, - o o , - a l p h a ) .A r t i f i c i a l I n t e l l i g e n c e 6 (1975), 293-326

    23

  • 8/14/2019 An Analysis of Alpha-Beta Pruning

    14/34

    306 V.E. KNUTH AND R. W. MOOREI t f o ll o w s b y i n d u c t i o n o n I th a t e v e r y c r i t ic a l p o s i ti o n i s e x a m i n e d .COROLLARY 1. I f e v e r y p o s it io n o n l e ve l s O; I . . . . , 1 - - 1 o f a g a m e t r ee

    s a t i s f y in g t h e co n d i t io n s o f T h eo r em 1 h a s ex a e t l y d s u cces so r s , f o r s o m ef i x e d c o n s t a n t d , t h e n t h e a l ph a - be t a p r o c e d u r e e x a m i n e s e x a c t l y

    d tll2 j "t" d rl/21 - 1 (13tp o s i t i o n s o n l e ve l I .

    P r o o f . T h e r e are d i-|/2J sequences a t . . a t , w i th I ~< a l ~ d for a l l i , suc htha t a t = I fo r a l l odd va lue s o f / ; t he re a re d r ~/21 suc h se que nc e s w i th a | f fi 1f o r a l l e v e n v a l u e s o f i ; a n d w e su b t r a c t I f o r t h e s e q u e n c e I . . . I w h i c h w a sc oun te d tw ic e .

    T h i s c o r o ll a r y w a s f i rs t d e r iv e d b y L e v i n i n 1 96 1, b u t n o p r o o f w a sa p p a r e n t l y e v e r w r i t t e n d o w n a t t h e t im e . I n f a c t, t h e i n f o r m a l m e m o [ I 0 ]b y H a r t a n d E d w a r d s j u st if i es t h e r e s u l t b y s a y in g : , ' F o r a c o n v i n c i n gp e r s o n a l p r o o f u s i n g t h e n e w h e u r i s t ic h a n d w a v i n g t e c h n i q u e , s e e t h ea u t h o r o f t h is t h e o r e m . ~ A p r o o f w a s l a t e r p u b l is h e d b y S l a g l e a n d D i x o n[2 5]. H o w e ve r, n o n e o f t h es e a u th o r s p o i n t e d o u t t h a t t h e v a l u e o f th e r o o tp o s i t i o n m u s t n o t e q u a l + oo. A l t h o u g h t h i s i s a r a r e o c c u r r e n ce i n n o n t r i v i a lga me s , s i nc e i t me a ns t ha t t he roo t pos i t i on i s a fo rc e d w in o r l o s s , i t i s an e c e s s a r y h y p o t h e s i s f o r b o t h t h e t h e o r e m a n d t h e c o r o l l a r y , s i n c e t h en u m b e r o f p o s i t io n s e x a m i n e d o n l e v el I w i ll b e d t|/2J w h e n t h e r o o t v a l u e is+ c o , a n d it w i l l b e d r~/21 w h e n t h e r o o t v a l u e i s - c o . R o u g h l y s 'e a k ing , w eg a i n a f a c to r o f 2 w h e n t h e r o o t v a l u e is ~ o o.

    T h e c h a r a c t e r i z a t i o n o f p e r f e c t a l p h a - b e t a p r u n i n g i n t e r m s o f c r i t i c a lp o s i ti o n s a l lo w s u s t o e x t en d C o r o l l a r y 1 t o a m u c h m o r e g e n e ra l c l as s o fg a m e tr ee s , h a v i n g a n y d e s i r e d p r o b a b i l i t y d is t r i b u t io n o f l e g a l m o v e s o neach level

    COROLLARY 2 . L e t a r a nd o m g a m e t r e e b e g e n e r a t e d i n s u c h a w a y t h a t e a c hp o s i t i o n o n l e v e l j h a s p r o b a b i l i ty q l o f b e i n g no nte rm i~ ta l, a n d h a s a n a ver a g e o fd j s u ccess o rs . T h e n t h e exp ec t e d n u m b er o f p o s i t io ns o n l e ve l l i s d o d t . . . d t , l ;a n d t h e e x p e c t e d n u m b e r o f p o s it io n s o n l e v e l I e x a m ~ d b y a lp h a -b e tat ech n i q u e u n d er t h e a s su m p t i o n s o f T h e o r em l i sd o q l dz q 3 . . . d t - 2 q , - t ~ q od xq 2d 3 . . q i . 2 d | - t : q o q t . . . q t - i " ' " I e ven ; ~14~doqld~q~ . . . qr -2 dl - t ~ qo diq2 d3 . . . d l -2q~-x - q 0 q t : - 'J q l - t l od d. ( ')

    ( M r e p r e c is e ly . : t h e a s s u m p U o n s u n d e r ly i n g t h i s r a n d o m b r a n c lf i n gp r o c e s s a r e t h a t l e v el j :+ 1 o f th e: t r e e i s f o r m e d t o m l e v e l j a s f o l l o w s :E a c h p o s it io n p o n l e v e l j i s a s s ig n e d a p r o b a b i l it y ~ s t r i b u t i o n < r e( p) ,

    r l ~ ) , , , . > . w h e re ra(p )::~ t h e p r o b a b ~ t y t h a t p w i l l h a v e d su c ce ss or s; t h es ed i s t r i b u t io ns m a y be d :fiTeren t o r :d i f fe re n t pos i t i ons p , bu t le a ch m us t s a t i s fyt o ( P ) = i - q j, a n d e a c h m u s t h a v e t h e m e a n v a i u c r t ( p ) + 2 r~ (p ) + . . .Arti f~ial lnteJ l igenc 6 (1975)~ 7293,-326

  • 8/14/2019 An Analysis of Alpha-Beta Pruning

    15/34

    AN ANALYSIS OF ALPHA-BETA PRUN ING 307= d j . T h e n u m b e r o f s u cc e ss o r p o s i t io n s f o r p i s c h o s e n a t r a n d o m f r o m t h i sd i s tr i b u ti o n , i n d e p e n d e n t l y o f t h e n u m b e r o f s u c c es so r s o f o t h e r p o s i t io n s o nleve l j . )

    P r o o f I f x i s t he expected num ber o f pos i t i ons o f a ce r t a in type on l eve lAt h e n xd~ i s t he expec ted n um ber o f successor s o f t he se pos i ti ons , an d x q j ist h e e x p e ct ed n u m b e r o f " n u m b e r 1 " s u c c es so rs . It f o l lo w s a s in C o r o l l a r y 1tha t ( 14) is t he expec ted n um ber o f c ri t ic a l pos i t i ons on l eve l l ; f o r exam ple ,q o q l . . - q H i s t h e e x pe c te d n u m b e r o f p o s i t io n s o n l e v e l ! w h o s e id e n t i f y in gcoor d ina te s a r e a l l l ' s .

    No te tha t (14) reduces to (13) w he n qj = 1 an d dl - d for 0 ~< j < / .I n tu i ti v e ly w e m i g h t t h i n k t h a t a l p h a - b e t a p r u n i n g w o u l d b e m o s t e ff ec ti ve

    wh en pe r f ec t - o rde r ing a s sum pt ion ( 12) ho ld s ; i . e. , wh en the f i rs t successor o feve r y pos i t i on i s t he bes t poss ib l e m ove . But t h i s i s no t a lways the ca se :Fig . 4 shows two gam e t rees wh ich a re id ent ica l except for th e le f t -to- r ightor de r ing o f successor pos i t i ons ; a lpha - be ta sea r ch w i l l i nves t iga t e m or e o fthe l e f t - hand t r ee than the r igh t - hand t r ee , a l t hough the l e f t - hand t r ee hasi t s pos i ti ons pe r f ec t ly o r de r ed a t eve r y b r anch .

    4 4A A2 i f " " ~3 3A , ,- 2 - 1 - I - 2

    F IG. 4 . P e r f e c t o r d e r in g i s n o t a lwa y s b e s t .T h u s t h e t r u ly o p t i m u m o r d e r o f g a m e t re e s t ra v e r s al i s n ' t o b v io u s . O n t h e

    o t h e r h a n d i t i s p o ~ i b l e t o s h o w t h a t t h e re a l w a y s e x i st s a n o r d e r f o r p r o -c e s si n g t h e t re e s o t h a t a l p h a - b e ta e x a m i n e s a s f e w o f t h e t e r m i n a l p o s i t io n sa s p o s s i b l e ; n o a l g o r i t h m c a n d o b e t t e r . T h i s c a n b e d e m o n s t r a t e d b ys t r eng then ing the t echn ique used to p r ove T heor em I , a s we sha l l s ee .

    T t ~ o e ~ M 2 . A l p h a , b e t a p r u n in g i s o p t i m u m i n t h e f o l l o w i n g s e n s e : G i v e na n y g a m e t r ee a n d a n y a l g o r it h m w h i ch co m p u t e s t h e va l u e o f t h e r o o t p o si ti m~ ,t h e r e i s a w a y t o p e r m u t e t h e t r ee (b y r eo rd erin g s u cces s o r p o s i t i o n s i f n eces s a r y )s o t h a t eve r y t e r m i n a l p o s i t io n exa m i n ed b y t h e a lp h a -b e t a me t h o d u n d er t h i sp e r m u t a t io n i s e x a m i n e d b y t h e g i v e n a l go r it h m . F u r t h e rm o r e i f t h e v a lu e o fthe roo t i s no t +_ oo , the a ipha-be t~ proced ure exam ines prec i se ly the pos i t ion sw h i ch a r e c r i t i ca l u n d er t h i s p e r m u t a t i o n .

    ( I t i s a s s u m e d t h a t a l l t e r m i n a l p o s i t i o n s h a v e i n d e p e n d e n t v a l u e s , o rArtificial Intelligenc e6 (1975), 293-326

  • 8/14/2019 An Analysis of Alpha-Beta Pruning

    16/34

    308 D . E . KN UrH AND R. W, MOOREequ iva len t ly tha t the a lgo r i thm has no knowledge abou t dependenc ie sbe tween the va lues o f t e rmina l pos i tions . )An equ iva len t r e su l t has been ob ta ined by G. M. Ade l son -Ve l sk iy [ l ,A ppend ix l ] ; a som ew ha t simp le r p ro o f wi ll be p r e sen ted he re .

    Proof . The fo l low ing func t ions F~ a n d F~ Oefine the bes t poss ib le bou ndso n t h e v a l u e o f a n y p o s it io n p , b a s e d o n t h e t e rm i n a l p o s i ti o n s e x a m i n e d b ythe g iven a lgo r i thm :" ( , i f p i s t e r m i n a l a n d n o t e x a m i ne d ,F j (p ) = ~ f ( p ) i f p i s t e rmina l and examined , ( 15 )[ m a x ( - F ~ ( p 0 , . . , - F ~ ( p d) ) o th e rw i se ;+ ( , i f p i s t e rm i n a l a n d n o t e x a m i n ed ,F ~ (p ) - - ~ f ( p ) i f p i s t e rm i n a l a n d e x a m i n e d, ( 16 )[ m a x ( - F ~ ( p ) , . . . , - F~p~) ) o the rwi se .

    N ote tha t F z (p ) < F~ (p ) fo r a l l p . By independen tly va ry ing the va lues a tu n e x a m i n e d t e r m i n a l p o s i t i o n s b e lo w p , w e c a n m a k e F ( p ) a s su m e a n y g i v e nvalue be tween F ~ p ) a n d F.(p) , b u t w e c a n n e v e r g o b e y o n d t h e s e l im i ts .W hen p i s the roo t pos i t ion w e m us t the re fo re have F~(p) - - F~(p) = F(p ) .As sum e tha t th e ro o t va lue is no t _+ co. We w il l show how to pe rmu te th et r ee so tha t eve ry c ri ti ca l te rmina l pos i t ion ( acco rd ing to the ne w num ber ingo f pos it ions) i s exam ined by the g iven a l~o r i thm an d t ha t p r ec ise ly thec r i ti ca l pos it ions a r e examined by the a lpha -be ta p rocedu re F2 . The c r i t ica lposi t ions wi l l be c lass if ied as type 1 , 2 , o r 3 as in th e pro of o f Th eorem 1 ,the ro o t be ing type I . "Unefo llowing fac t s ca n be p rove d b y induc t ion :(1) A type I po s i t ion p has F t (p ) = ~ (p ) = F(p ) # _+ co , an d i t i s examineddu r ing the a lpha -be ta p rocedu re by ca i l ingF 2(p , - co , + co ). I f p i s t e rmina l ,i t m us t be examined by the given a lgo r i thm , s ince F dp ) # - co . I f i t i s no tt e rm i n a l , le t j a n d k b e su c h t h a t F ~ ( p ) = - F . ( p j ) a n d F. ( p) - - - - Fg( p t ) .Th en by (15) an d (16 ) we have

    , , ) , h en ce ~ ( p j ) = F z ( P t ) a n d w e m a y a s s u m e t h a t j ~ = k . By pe.rmuting thesuccessor posi ! i0ns w e m ay assum e in fa c t th a t j - k _ ~1. Posit~on P i (a f te rp e rm u t a ti on ) i s O f ~ 1 ; t h e o t h e r s U ~ o r p o sit io n s p c ' . . . , p ~ a r e o ft y p e 2 , a n t i't h e y a r e a l l e x a m i n e d b y c a l f in g P 2 ( p t , - c o , ' ~ F ( p 0 ) .

    (2 ) A t yp e 2 p o s it io n p h a S F ~ (p ) ~ - c o , a n d i t i s e x a m i n e d du r in g th ea l p h a ' b e t a p r ~ u r e b y c allin g F 2 (p , , c o , b e ta ), w h e i e ' - - o o < b e t a ~ F~ (p ).I f p ~ t e r m ~ a i , rit m n s t ~ e x ~ i n e d b y ~ g iv en a l go r it h m . O ther~v. s e l e t Jb e ~t/ch ~ a t ~ ( p ) = / ~ F . ( p j ) , ~ d ~ m u ~ t h e i S uc ceS s0 r p o si t io n s i fn e ce s sa ry S o t h a t j = L p o s it io n p k ( a f te r ~ r m u t a t i o n ) i s o f ty p e 3 a n d i sexamined by ca l l ing F 2 (p x , - b e t a , + co ). Since F . ( p O - - F ~ p ) < ~ -b eta ,t h is c a l l r et u rn s a v a l u e ~ - b e t a ; h e n ce t h e o t h e r su c c es so r s P 2 , - . . , P dArtificial Intelligence6(197 5); 293-326

  • 8/14/2019 An Analysis of Alpha-Beta Pruning

    17/34

    AN ANALYSIS OF ALPHA-BErA PRUNING 309( w h i ch a r e n o t c r it ic a l p o s i ti o n s ) a r e n o t e x a m i n e d b y t h e a l p h a - b e t a m e t h o d ,no r a r e the i r de scendan t s .

    ( 3) A type 3 po s i t i on p has F ,.( p) < co, and i t i s exam ined dur ing th ea l p h a . b e t a p r o c e d u r e b y c a l l in g F2 (p, alpha, + co), w h e r e F~ (p) F ( p j ) > F ( p z) > . . . > F( p~ ) > - b e t a i s sa t i s f ied. ) O n the oth erArtbqclal ln tel f lgenc e 6 (1975), 293-326

  • 8/14/2019 An Analysis of Alpha-Beta Pruning

    18/34

    3 1 0 D .E . K N U T H A N D R . W . M O O R Ehand , there a re gam e t rees wi th d i st inc t te rmina l va lues fo rw hich thea lpha -beta procedure wi l l a lways f ind some cutof fs no mat ter how the branchesare permuted , as sho w nin F ig. 5 . (P rocedure F I does no t en joy th i s p roper ty . )

    / \ . . l \ .! \ . / , , . ! \ . / \/ \ / \ / \ / \ / \ / \ / ' \ / \al a2 bl b 2 a3 a4 b3 b4 a5 a6 b 5 be a7 a8 b7 b8

    F XG . 5 . I f m a x ( a b . . . . a s ) < m i n ( b h . . . , b e ) , t h e al p h a -b e ta p r o c e d u re w i l l a lw a y s f in d a tl e a s t t w o c u t o ff s , n o m a t t e r h o w w e p e r m u t e t i c b r a n c h e s o f t h i s g a m e tr e e .Since game-playing programs usual ly use some sor t o f order ing s t ra tegy inconnect ion wi th a lpha-beta pruning, these facts about the wors t case are oft i tt le or no pract ical s ignif icance. A mo re useful up pe r bou nd relevant to thebe hav ior we m a y expec t in p rac t ice can be based on the as sumpt ion o f

    random data . Fel ler , Gaschnig and GiUogly have recent ly und er taken a s tudy[7] of the average number of terminal pos i t ions examined when the a lpha-beta procedure i s appl ied to a u ni form t ree of degree d an d height h, g ivingindepend ent rand om values to the term inal pos i tions on level h . They haveob ta ined fo rmulas by which th i s average num ber can be com puted , in rough lyd s s t~,s , and their theoretically-pred icted results Were on ly Slightly high ertha n empir icaUy, observed d at a obtain ed f rom a mod if ied chess-playingprogram. Unfor tuna te ly the fo rmulas tu rn ou t to be ex t remely compl ica ted ,even fo r th is r easonab ly simple theore ti ca l model , so t h a t t h e asym pto t i cbehav ior for large d and /or h seems to defy analys is .S ince we a re look ing fo r upper bound s ~ yw a y , i t is na tu ra l to cons iderthe b ehav ior o f th e We.aker p rocedure F L ~ S m ethod i s weaker s ince i td o es n ' t fi n d an y " d ee p cu to f fs " ; b u t i t is m ~ b e t t e r t h an co m p l e te m ir~ i-n i ax in g , an d F i g s . 1 - 3 i n d i c a t e t h a t d ee p cu to f fs p ro b ab l y h av e o n l y asecond-order ef fect /on the eff ic iency. Fur therm ore, proc edu re F I has thegrea t v i r tue tha t i t s ana lysi s i s much s impler than tha t o f th e fu ll a lpha-be taprocedure F2 .

    O n t h e o t h e r h an d , t h e an a ly s is o f F l i s b y n o m ean s a s e a sy a s it lo o k s,an d t h e m a t h em a t ic s t u r n s o u ~ t o b e ex t r em e l y i nt er es ti ng . I n f act , t h eA r t i f i c i a l I n t e l l i g e n c e 6 (1975), 293.37,,6

  • 8/14/2019 An Analysis of Alpha-Beta Pruning

    19/34

    A N A N A LY S IS O F A L P H A - B E T A P R U N I N G 3 l l

    au th or s ' f i rs t ana ly s i s was f oun d to be incor rec t , a l t houg h seve r a l com pe ten tpeop le had checked i t w i thou t see ing any m is t akes . S ince the e r r o r i s qu i t eins t ruc t ive , we sh a l l p r e sen t ou r o r ig ina l ( bu t f a l l ac ious ) ana lys i s he r e ,c h a l l e n g in g t h e r e a d e r t o " f i n d t h e b u g " ; t h e n w e s h a l l s tu d y h o w t o f i xt h i n g s u p .W i th th is unde r s t and ing , l e t us cons ide~ the fo l lowing pr ob lem : A u n i f o r mg a m e t re e o f d eg r ee d a n d h e i g h t h i s co n s t ru c t ed w i t h r a n d o m v a l u es a t t a c h e dto i t s d ~ e r m in a l pos i t i ons . Wh a t i s t he expected nu m be r o f t e r m ina l pos i t i onse x a m i n e d w h e n p r o c e d u r e F I i s a p p l i e d t o t h i s t r e e ? T h e a n s w e r t o t h i spr o b lem w~H be d eno ted by T ( d , h ) .

    Since the sea r ch p r ocedu r e d epen ds o n ly on the r e l a t ive o r de r o f t he d ht e r m ina l va lues, no t o n the i r m ag ni tudes , and s ince the r e i s ze r o p r ob ab i l i t ytha t two d i f f e r en t t e r m ina l pos i ti ons ge t t he sam e va lue , we m ay a ssum e tha tthe r e spect ive va lues a s signed to the t e r m ina l pos i ti ons a r e p~ r m uta t ions o f{1, 2 , . . . . , dh}, ea ch perm uta t io n occu r r ing w i th pro ba bi l i ty 1/(dh)! . F ro mth i s obse r va t ion i t i s c l ea r t ha t t he d ~ va lues o f p os i t i ons on each l evel I a r ea l so in r and om or de r , f o r 0 ~< l < h . A l thoug h p r ocedur e F l does n o ta lw ays com pu te th e e xac t F va lues a t every posi t ion, i t i s no t d i f f icul t tO r've r i f y tha t t he d ec i s ions F1 m a kes a~ au t , 'a to ff s dep end en t i r e ly on th e Fva lues (no t o n the app r ox im a te va lues Fl i~p)) ; so we m ay con c lude tha t t hee x p e ct e d n u m b e r o f p o s i t io n s e x a m i n e d o n l ev e l I is T ( d , l ) for 0 ~< l ~< h.Th i s j us t if i e s r e s t ri c t ing a t t en t ion to a s ing le l eve l h wh en we coun t t hen u m b e r o f p o s it i o n s ex a m i n e d .

    I n o r de r t o s im p l i f y the n o ta t ion , l e t us cons ide r f i rs t t he ca se o f t e r na r yt rees, d = 3; the gene ra l case wi l l fo l low eas i ly once th is on e i s und ers tood .O ur f ir s t s t ep i s t o c l a s si f y the po s i t i ons o f the t r ee in to types A , B , C a sf o l lows :

    The r oo t p os i t i on i s t ype A .The f i r st successor o f eve r y no n te r m ina l pos i t i on i s t ype A .The second successor o f eve r y non te r m in a l pos i t i on i s t ype B .T h e t h i r d s u c c e ss o r o f e v e ry n o n t e r m i n a l p o s i t io n i s t y p e C .

    1 1 1 1 314 3/5 1 9/14 9/20I i \ I I \ I I \

    11 V12 Y13 Y21 Y22 Y23 Y31 Y32 Y33

    F z o . 6 . P a r t o f a u n i f o r m t e r n a r y t re e . A r t i f i c i a l I n t e l l i g e n c e 6 (1975). 293-32 6

  • 8/14/2019 An Analysis of Alpha-Beta Pruning

    20/34

    3 1 2 D . E . K N UT H A N D R. W. MOOREFig. 6 shows the loca l "envi ronm ent" o f typica l A , B , C pos i tions , as theyappea r be low a non t e rmina l pos i ti on p which m ay be o f any t ype . The F-va luesof these three pos i t ions a re x l , x2 , x3 , respect ively, and their descendantshave respective F-vahles Y1 1,- - . ,Y3 3. O ur assum pt ions guarantee tha tY l l , - . . , Y33 are in rand om order , no m at te r wh at level of the t ree we ares tudy ing; hence the va lues

    x ~ = m a x ( - Y l t , - - Y l 2 , - Y 1 3 ) , . , x 3 ~-" m a x ( - y ~ l , - -Y 3 2 , - - 7 3 3)a re a l so i n random orde r .I f pos i t ion p i s examined by ca ll ing Fl (p , bored) , then pos i t ion A wi l l beexamined b y the subsequ ent ca ll F I(A , + o0), by def ini tion of F 1 (see Sec t ion2) . Even tua ll y t he va lu~ x t wi ll be re tu rned ; and i f - x l < bound, posi t ion Bwi l l be exam ined b y ca ll ing FI(B , xt ) . Even tua l ly the va lue x2 wi l l be re turned ;o r , i f x 2 > i x i , a n y v a lu e ~ >t X l m a y b e r et ur n ed . I f m a x ( - x l , - x ~ ) Y2~ obviously h olds w ith p rob abi l i ty .Similarlythe th i rd successor of a B pos i t ion i s eva lua ted i f an d on ly i f the va luessa t i s fy min(y l l , YI2, YI3)

  • 8/14/2019 An Analysis of Alpha-Beta Pruning

    21/34

    A N A N A LY S IS O F A L P H A - B E T A P R U N I N G 313

    A (z) = ~ A , z ~, B(z) = #~o B~ z" , C(z) = E C , z ' ,n~-O n~>Oso tha t (18) is equivalent to

    A(z ) - 1 = zA (z) + .zB(z) + zC(z),B ( z ) - 1 = zA (z) + ~}z B( z)+ ~}zC(z),C (z) - 1 = zA (z) + ,-~4zB(z) + 2-~zC (z).

    By Cram er ' s ru le , A(z) - U ( z ) / V ( z ) , whereU ( z ) = d e 1 ~ z - 1 ] z ,

    V (z ) d e t z - I ] z. ~-g4z ~f-6z--

    ( 1 9 )

    ( 2 o )

    1 c2 C3+ + , (2 1)A(z) = 1 - r l z 1 - - r 2 z 1 - - r 3 z

    c , = - r , U ( 1 / r t ) / r ' ( l / r ~ ) . (22)Consequent ly A(z) = ~ . ) o ( c l ( r l z ) " + c z( r zz ) " + e a ( r a z) ') , and we have

    A , = + c 2 z +by equ ating coeflicie,Rs of z, . If w e n um be r the roots so tha t {rl [ > I t21 >~ Ir3[(and the theorem o f Perron [17] assures us that th is can be done) , we haveasymptot ical lyA , . ., c l r ~ . (23)

    Nu m erical calcu lation gives r t - 2.533911, ci---- 1.162125; thus, the alph a-be ta p rocedure wi thou t deep cu to f f s i n a r andom te rnary t r ee w/l l examineabo u t as m any nodes a s in a t r ee o f the ' s ame he igh t w i th average degree2,534 ins tead of 3 . ( I t i s wor thwhile to note that (23) - redicts about 48pos i t ions to be examined on: the fou r th level, whi le on:~ ; 35 occurred inFig . 2 ; th e reason for th is d iscrepancy is chiefly that the one-digi t values inFig . 2 are non rand om because of f requen t equali t ies .)E lementa ry m an ipu la t ion o f de te rminan ts shows tha t the equa t ion z 3 V( l /z )= 0 i s t h e s a m e a s

    1 - z 1 z /d e t I - z = 0 ;

    henc e r s is the l a rges t e igenva lue o f t h e m a t r ixArt i f ic ia l In te l l igence 6 ( 1 9 7 5 ) , 2 9 3 - 3 2 6

    where

    are polynom ials in z . I f the eq uat ion z 3 V ( l /z) = 0 has dis tin ct roo ts r l , r z, r3,there will be a par t ia l f ract ion expan s ion o f the form . -

  • 8/14/2019 An Analysis of Alpha-Beta Pruning

    22/34

    314 D . E . K N U T H A N D R . W . M O OR E

    W e m igh t have deduced th i s d i rec t ly f rom eq . (18), i f we ha d known enoughma t r ix theory to ca lco la t the cons tan t c l by mat r ix -theore t ic means ins teadof funct ion- theoret io means .This solves the case d .-- 3 . For general dw e f ind s imilar ly tha t the expectednum ber o f te rmina l pos i tions examined by the a lpha-be ta p rocedure wi tho u tdeep cu to f fs , in a r ando m un i fo rm game t r ee o f deg ree d and he igh t h , isasympto t ica l ly

    T ( d , h ) , . . c o ( d ) r o ( d ) ~' (24)fo r f ixed d as h ~ 00, wh ere re(d) is the largest eigenvalue of a certain d x d

    M d --

    m a t r i xr P l l P 1 2 " ' " P td ~P 2 1 P 2 2 - - - P 2 4

    i

    P d t P d 2 " ' - P d d

    (25)

    an d where co(d) is an approl ~riate co ns en t . The general ma tr ix e lement p~jin (25) is the pro bab i l i ty thatma x (m in (Y lt , . . . , Y~d)) < ra in Y~ (26)l ~ k< l 1~/< /

    in a sequence of ( i - l )d + ( j - 1) independent ident ically d is t r ibutedrando m var iab les YI t , . . . , Y lc j- t~ -W hen i - 1 o r j - 1 , the proba bi l i ty in (26) is 1 , s ince the ra in over anem pty se t i s + 00 and the max i s -Q o . W hen i , j > 1 we c an evaluate th eprob abi l i ty in several way s , of which the s imp les t seems to be combina tor ia l :Fo r (26) to ho ld , the min imum of a ll the Y ' s mu s t b~ Yt,tl fo r some k l < i ,a n d t h is oc c u rs w i t h p r o b a b i l i t y ( i - l ) d / ( ( ! - l ) d + j - I ) ; r em o v -ing Yk, t , . . . . ,Y t i4 f rom cons idera tion , the m in im um of the r emain ingY 's m ust be Y~a,2 fo r some k 2 < i , a n d t h is o c c u r s w i t h p r o b a b il it y

    ( i - 2 ) d / ( ( i - 2 ) d + j - 1); and s o o n . There fo re (26) occurs w i th p ro -babi l i ty _ , / .( i - 1 )d ( i - 2 )d d~ .. . . a e BP u = ( i - D d + j ' - I ( i - 2 ) d + j - - 1 d + i - I

    - - l / ( i - I t 2 1 - 1 ) / d ) . ( 2 7 )Th is exp l ic i t fo rm ula a l lows us to ca lcu la te to (d )num er ica l ly fo r smal l dwi thou t much d i ff icu lty , and to ca lcu la te c o ( d ) f o r smal l d w i th somewhatm ore d if ficulty us ing (22).Arti~:intelliocnce:6 ( 1 9 7 5 ), 2 9 3 - 3 2 6

  • 8/14/2019 An Analysis of Alpha-Beta Pruning

    23/34

    A N A N A L Y S IS OF ALPHA-BETA PRUNILNG 315

    T h e f o r m o f ( 2 7 ) i s n ' t v e r y c o n v e n i e n t f o r a s y m p t o t i c c a l c u l a t i o n s ; t h e r e i sa m u c h s i m p l e r e x p r e s s i o n w h i c h y i e ld s a n e x c el le n t a p p r o x i m a t i o n :

    LEMMA 1. W hen 0

  • 8/14/2019 An Analysis of Alpha-Beta Pruning

    24/34

    316 v. E. KNUTH AND X. W. MOORE

    l e~t,j~dd d--I

    = d + 1 kN ow f o r k = d ' w e h av e k - l J d f e x p ( - - t In d / d ) f f i l - t In d / d+ O ( ( I og d/d)Z),h e nc e f o r x / d g k ~ < d, ( 1 - k - l ) / ( l - k - l / a ) lie s b e tw e en d / l n d a n d2d/In d times 1 + O(lo g d/d). The bou nds in 01 ) now fo l low eas ily .

    W hen the values of re(d) for d ~< 30 are p lo t ted on log log pape r , they seemto be approaching a s t ra ight l ine , sugges t ing that re(d) is approximately ofor de r d '75. In fac t, a least-squa res fit fo r 10

  • 8/14/2019 An Analysis of Alpha-Beta Pruning

    25/34

    A N A N A L Y S I S O F A L P H A -B E T A P R U N I N G 3 17f 7 > m i n ( j ~ ,f 6 ) , (32)m i n ( f s ,f 6 ) < m a x ( m m ( f i , f 2 ), m i n ( f s , f ,) ) .

    E a c h o f t h e s e t w o e v e n t s h a s p r o b a b i l i t y { , b u t t h e y a r e n o t i n d e p e n d e n t .Ai

    I A ( I B Q A ( l i b O A ( li b Q A ( l iBt l #2 f3 f4 vs fe f7 f8

    F I G . 7. A t r e e w h i c h r e v e a l s t h e f a l l a c i o u s r e a s o n i n g .W h e n t h e f a l la c y i s s t a t e d i n t h e s e t e r m s , t h e e r r o r i s q u i t e p l a i n , b u t t h e

    d e p e n d e nc e w a s m u c h h a r d e r t o s ~ ; in t h e d i a g r a m s w e h a d b e e n d r aw i n g f o ro u r se l v es . F o r e x a m p l e , w h e n w e a r g u e d u s i n g F ig . 6 t h a t t h e s e c o n d s u c c e s s o ro f a B p o s i t i o n i s e x a m i n e d w i t h p r o b a b i l i t y , w e n e g l e c t e d t o c o n s i d e r t h a t ,w h e n p i s i t s e lf o f t y p e B o r C , t h e B n o d e i n F i g . 6 is e n t e r e d o n l y w h e nra i n (y 1 1 , Y1 2, Y t 3 ) i s l e ss t h a n t h e b o u n d a t p ; s o r a i n (y , t , Y t 2, Y l 3 ) i s s o m e-w h a t s m a ll e r t h a n a r a n d o m v a l u e w o u l d b e . W h a t w e s h o u l d h a v e c o m p u t e di s t h e p r o b a b i l i t y t h a t Y zt > m i n ( y t l , Y l 2 , Y ~ 3)given that p o s i t i o n B i s n o tc u t o ff . A n d u n f o r t u n a t e l y t h is c a n d e p e n d i n a v e r y c o m p l i c a t e d w a y o n t h eancestors of p.

    T o m a k e m a t t e r s w o r s e, o u r e r r o r i s i n t h e w r o n g d i r e c ti o n , i t d o e s n ' t e v e np r o v i d e a n u p p e r b o u n d f o r a l p t m - ~ e t a s e a r c h i n g ; i t y i e l d s o n l y a l o w e rb o u n d o n a n u p p e r b o u n d ( i.e ., n o t h in g ) . I n o r d e r t o g e t in f o r m a t i o n r e le v a n tt o t h e be h a v io r o f p r o c e d u r e F 2 o n r a n d o m d a t a, w e n e e d a t l ea s t a n u p p e rb o u n d o n t h e b e h a v i o r o f p r o c e d u r e F 1 .A c o r r e c t a n a l y s is o f t h e b i n a tr y c a s e ( d 2 ) i n v o l v e s th e s o l u t io n o fr e c u r r e n c e s

    A . + t - - An + B . ) 'B i ,+ ) ,= A a + ~ tB C t t ) fo r k ~ 0 , 0 3 )A o = ) = B oo = ] 3I , ) = - " = l ,

    w h e r e t h e P t a r e a p p r o p r i a t e p r o ba b i li ti e s . F o r e x a m p l e , P o = ~ ; PoP. i s t h ep r o b a b i l i ty t h a t ( 32 ) h o l d s ; a n d p o p t p 2 i s t h e p r o b a b i l i ty t h a t f if te e n i n d e p e n -d e n t r a n d o m v a r i a b le s s a ti s fy

    As>f13Aft,t,f 13 A f i * < ( f , A f r o ) V ( f i t A f t 2 ) , ( 34 )

    ( f g ^ f t o ) V ( f i t A f t 2 ) > ( ( f l ^ f , ) V ( f3 ^ f , ) ) A ( (f s A f ) v (f'n A f s ) ) ,A r t i f i c i a l I n t e l li g e n c e 6 ( 1 9 7 5 ), 2 9 3 - 3 2 6

  • 8/14/2019 An Analysis of Alpha-Beta Pruning

    26/34

    318 D . E . KNUTH AND g. W. MOORE

    writ ing v for m ax and ^ for min. These probabi l i ties can be com putedexac t ly by eva lua t ing app ropr ia te in tegra ls , bug the formu las a re com plica tedand i t i s eas ie r to look for up per boun ds . W e can a t leas t show eas i ly tha t th epro bab ili ty in (34) is g } , s ince the fLrStand th i rd cond i tions a re independent ,and they each ho ld w i th p robab il i ty ~ . Thu s we ob ta in an uppe r boun d i f wese t Po - - P , ffi P4 f fi . - - ffi ~ and Pt = Pa = . - . - - 1 ; th is is equiva lent to

    A o - B o = 1~= A n + e n ,

    e n+ ~ = A . + } A , .

    the recurrence( 3 5 )

    Simila r ly in the case of degree 3 , we obta in an u pper b oun d on th e averagenum ber of nodes examined without deep cutoffs by solving the recurrenceA o - B o f f i C o - - - 1 ,

    A.+ I = An + Bn + C ., (36)S . + ~ = A . + ~ } A . + ~ jA n.C .+ , = A . + ~2~A. + z~oAn,

    in place of (18). This is equivalent toA.+I - - A . + ( I + + t + 1 + ~ + ~o)An-t

    an d fo r general degree d we ge t the recurrenceAn +l ffi An + $~A n-l, (37)

    where Ao --- 1, Al --- d, andS d ~ " 2 ~ l ~ d P lJ " (38)This g ives a va l id upper b ou nd on th e behavior o f procedure F 1, because i t i sequ iva len t to s e tt ing bound , - - + o o a t c e r ta in pos it ions ( an d th i s ope ra t ionneve r decrea se s the nu m be r o f pos i tions examined ) . F ur the rmo re we cansolve (37) expl ic it ly , to o bta in an asym ptot ic up per bou nd on T(d , h ) o f t h efo rm c t (d ) r~ (d) s , whe re th e g rowth ra t io i s

    rl (d ) ffi ~/(Sd + ) + . (39)Un for tuna te ly i t tu rns o u t tha t Sa i s o f o rde r d2 / log d , by T heorem 3 ; so(39) i s o f o rde r d / ~ / l o g d , wh i l e a n u p p e r b o u n d o f b r d e r d /l og d i s desired.A n o t h e r w a y t o g e t a n u p p e r b o u n d r e ti e s O n a m o r e d e ta il ed a n al ys is o fthe s t ruc tu ra l beh av io ro f p rocedure F 1 , a s in the fo llowing theorem.

    T t ~ o m ~ 4 . T h e e x p o c te d n u m b e r o f t er tn in a l p o s it io n s e x a m i n e d b y : h ea lpha-be ta procedure wi thou t deep cu to ff s, i n a random un i form g a m e t ree o fdegree d a nd height h , sat is f iesT (d , h ) < c* (d ) r * (d ) h , ( 4 0 )

    wh ere r* (d ) i s the larges t e igenva lue -o f th e m atr ixAr tificial Intellt'gence6(197 5), 293-326

  • 8/14/2019 An Analysis of Alpha-Beta Pruning

    27/34

    ANA NALY SIS OF ALPHA-BETA PRUNING

    g~

    / P d l ~ P d 2an d c*(d) is an appropriate constant.( T h e p ~ i n ( 4 1) a r e t h ~ s a m e a s i n ( 2 5 ) ,)

    O a ~

    ~/P2a

    ~ P d d

    3 1 9

    (40

    Proof . A s s i g n c o o r d i n a t e s a t . . a~ t o t h e p o s i ti o n s o f t h e t r e e a s in S e c t i o n6 . F o r 1 1> 1 , i t i s e a s y t o p r o v e b y i n d u c t i o n t h a t p o s i t i o n a t . . . a~ h a sbound = m i n { F ( a , . . . a:_ lk ) i I ~< k < a l } w h e n i t i s e x a m i n e d b y p r o c e d u r eF ! ; h e n c e i t is e x a m i n e d i f a n d o n l y i f a t . . a H is e x a m i n e d a n d

    - m i n F ( a l . . . a ~ _ l k ) < r a i n F ( a l . . . a ~ - 2 k ) o r I = 1 , ( 4 2 )1

  • 8/14/2019 An Analysis of Alpha-Beta Pruning

    28/34

    3 2 0 D . e . K l qU a ~ A m 3 x . w . MOO Rewh ich sa t i s f i es

    d d ~c S ~ . o ~ , ~< r(d~ i C 3 d ] lo g d .T h e l a r g es t ei g e nv a l ue o f a m a t r ix w i t h p o s it iv e e n t r i e s p ~ l i s k n o w n t o b e> ~ m i n ~ ( ~ jp ~ j ) , a c c o r d i n g t o t h e t h e o r y o f P e r r o n [ 1 9] ; s e e [2 6 , S e c t io n 2 .1 ]f o r a m o d e m a c c o u n t o f th i s t h eo r y ,4 T h e r e fo r e b y L e m m a 1,

    ( Z i ' u 1 ' ~ ' ~r e ( d ) ~ C r a i n - ' )l - - zC m i n ( ' , . I i . ~ 2 ~ , . ~ , k l - i j .

    1 d - t d- 1- C l . d . ~ / , z > C - J ' ~ d - '

    w h e re C = 0 . 8 8 5 6 0 3 = i n fo ~ = ~ t F (1 + x ) , s i n c e d " i l a ffi e x p ( - l n d / d ) >I - i n d i d . . . . . . . .. . - ,

    T o g e t t h e u p p e r b o u n d i n ( 4 4 ), w e s h al l p r o v e t h a t r * ( d ) < C 4 d / l o g d ,u s i n g a r a t h e r c u r i o u s m a t r i x n o r m . I f s a n d t a r e p o si t iv e e a l n u m b e r s w i t h

    1 I- + = i , ( 4 6 )

    t h e n a l l e i g e n v a lu e s ~ o f a m a t r i x A w i t h e n t r ie s :a~ s a t i s f y

    T o p r o v e t h i s , l e t 24x = ' ~ , w h e r e i s a n o n ~ e r o v e c t o r ; b y H ~ l d e r 's i n -e q u a l i t y [ 9 , S e c t i o n 2 . 7 ],p t ( E i" = ( E / X a , s x j l ' ~ l ~ "

    x .t , I . - , . ~ , ~ I Ir " ' a * * I t ~ 1 t# t

    W e are indebted to D r-L H . W ilkinson or suggesting his proo f of the low er bound.A ra flda l Intetllger.ee6 (197b':),293-326

  • 8/14/2019 An Analysis of Alpha-Beta Pruning

    29/34

    AN ANALYSIS OF ALPHA-BETA PRUN ING 321- - ( ~ ( ' ~ l a ~ j l ) s / ' ) I / * / ~ l X ~ i l) / s

    a n d ( 4 7 ) f o l l o w s .I f w e l e t s - t = 2 , i n e q u a l i t y (4 7 ) y i e l d s r * ( d ) = O ( d / x / l o g d ) , w h i l e i f s

    o r t ~ o o t h e u p p e r b o u n d i s m e r e l y O ( d ) . T h e r e f o r e s o m e c a r e is n e c e s s a r y ins e le c t in g t h e b e s t s a n d t ; fo r o u r p u r p o s e s w e c h o o s e s = f ( d ) a n d t =f ( d ) / ( f ( d ) -1 ), wheref(d)= n d/ ln In d . Then\ 1 -,~ ~.d\ l -,Q'~d

    < ( v / d d ' / ' ' F ( d - / d ) G ~ ' v / d - '( ' i - ' ) / 2 d ) s " ) ' / ' " ( 4 8 )T h e i n n e r s u m i s 9 ( d ) = l / ( 1 - d - f / t d ) = ( 4 d / i n d ) ( l + O ( l n I n d / I n d ) ) , s o

    d g ( d ) "/* = d s ( a ) - x / 2 e xp ( I n 4 I n d / I n l n d + I n I n d + O ( 1 ) ) .H e n c e t h e r i g h t - h a n d s i d e o f ( 4 8 ) is

    e x p ( l n d - I n I n d + I n 4 + O ( ( l n I n d ) 2 / l n d ) ) ;w e h a v e p r o v e d t h a t

    r * ( d ) ~< ( 4 d / I n d ) ( l + O ( ( l n i n d ) Z / l n d ) ) a s d --~ ~ .

    8910111213141516

    t ll

    TASx~ 1. Bo un ds for the b ranch ing factor i n a r andom treewh en no deep cu to f f s are per formedi l l i

    d r o ( d )2 1 . 8 4 73 2.5344 3.1425 3.7016 4.2267 4.7245.2035.6646.!126.5476.9727.3887.7958,1958:589

    t I

    ii ir l ( d ) r * ( d )1.884 ! .9122.666 2.7223.397 3.4734.095 4.1864.767 4.8715.421 5.5326.059 6.1766.684 6.8057.298 7.4207.902 8.0248.498 876189.086 9'2039.668 9.7811 0 . 2 4 3 1 0 ' 3 5 01 0 . 8 1 3 1 0 . 9 1 3

    ii i

    I

    d1718192O2122232423262728293031

    i |

    i

    r o ( d )8.9769.3589.73410.10610.47310.83611.19411.55011.90112.25012.59512.93713.27713.61413.948

    I l l l . I I I I

    u l , i , L i i

    r l ( t O r * ( d )11 378 11 .4 7011 .938 12 .0211 2 . 4 9 4 1 2 . 5 6 71 3 . 0 4 5 1 3 . 1 0 81 3 . 5 9 3 1 3 . 6 4 414d37 14 .1761 4 . 6 7 8 1 4 . 7 0 41 5 . 2 1 5 1 5 . 2 2 815 .750 " .5 .7481 6 . 2 8 2 1 6 . 2 6 516 .811 16 .77817.337 17., ]8! 7 , 8 6 1 1 7 . 7 9 61 8 . 3 8 3 1 8 . 3 0 01 8 . 9 0 3 1 8 . 8 0 2

    i i i i i

    T a b l e 1 s h o w s t h e v a r io u s b o u n d s w e h a v e o b t a in e d o n r ( d ), n a m e l y t h el o w e r b o u n d t o ( d ) a n d t h e u p p e r b o u n d s r l ( d ) a n d r * ( d ). W e h a v e p r o v e dt h a t t o (d ) a n d r * ( d ) g r o w a s d / l o g d , a n d t h a t r l ( d ) g r o w s ~a s d / v / l o g d ; b u tt h e ta b l e s h o w s t h a t r l ( d ) i s a c t u a ll y a b e t te r b o u n d f o r d ~ 2 4 .A r t i fi c i a l I n t e l li g e n c e 6 (1975L 293-326

    24

  • 8/14/2019 An Analysis of Alpha-Beta Pruning

    30/34

    32 2 D . E . K N U T H A N D R . W . M O OR E8 . D i sc ussion o f the M od e l

    T h e t h e o re t ic a l m o d e l w e h a v e s tu d i ed g i v e s u s a n u p p e r b o u n d o n t h e a ct u a lb e h a v i o r o b t a i n e d i n p r a c ti c e. I t is a n u p p e r b o u n d f o r f o u r s e p a ra t e r e a s o n s :

    ( a ) the de e p c u to f f s a r e no t c ons ide r e d ;( 5 ) the o r de r ing o f suc c e sso r pos i t ions i s r a ndom ;( c ) the t e r m ina l pos i t ions a r e a s sum e d to ha ve d i s t inc t va lue s ;( d ) the t e r m ina l va lue s a r e a s sum e d to b e inde pe nde n t o f e a c h o the r .

    E a c h o f t h e se c o n d i t io n s m a k e s o u r m o d e l p e s si m i st ic ; f o r e x a m p l e , i t isusua l ly poss ib le in p r a c t i c e to m a ke p la us ib le gue sse s tha t som e m ove s wi l lb e b e t t e r t h a n o t h e rs . F u r t h e r m o r e , t h e l a rg e n u m b e r o f e q u a l t e rm i n a lva lue s in typ ic a l ga m e s he lp s to p r ov ide a d d i t iona l c u to i fs . The e f fe c t o fa s su m pt ion ( d ) is le s s c l e a r , a n d i t w il l be s tud ie d in S e c t ion 9 .

    I n sp i te o f a l l the se pe ss im is ti c a s sum p t ions , t he r e su l ts o f ou r c a l c u la tionsshow tha t a lp ha - be ta p r un ing wi ll be r e a sona b ly e ffi cie nt.

    Le t u s no w t r y to e s t im a te the e ff e ct o f de e p c u to ff s v s no de e p c u to f fs .O n e w a y t o s t u d y t h i s i s in t e r m s o f t h e b e s t c a s e : U n d e r ' id e a l o rd e r i n g o fS uc c e sso r pos it ions , wh a t i s t he a na lo gue f o r p r oc e dur e F 1 o f the the o r yde ve lope d in S e c t ion 67 I t i s no t d i f fi c ul t t o se e tha t t he po s i t ions a i . . a te x a m i n e d b y F I i n th e b e s t c a s e a r e pr e ci se ly t h o s e w i th n o t w o n o n - l ' s i n arow , i . e ., those fo r which a~ > 1 impl ies a~+t = 1 .

    I n the t e r na r y c a se unde r be s t o r de r ing , we ob ta in the r e c u r r e nc eAo = Bo = Co = 1 ,

    A n + l - A n + B n + C n, (49 )B . + I = A . ,C , + t = A n ,

    h e n c e A n i - A , -I- 2 A . _ i . F o r g e n e r a l d t h e c o r r e s p o n d i n g r e c u r r e n c e i sA o = 1, A1 - d, An+ 2 = An+t + ( d - 1)An. (50)

    The so lu t ion to th i s r e c u r r e nc e i s1A n - x / ( 4 d 3 ) ( x / ( d - ) ~ + ) . + 2 _ ( _ x / ( d - i ) + ) "+ 2 ) ; ( 5 1)

    s o t h e g r o w t h r a t e o r e f fe ct iv e r a n c h i n g f a c t o r i s x / ( d - I ) + , n o t m u c hh i g h e r t h a n t h e v a l u e x / d o b t a i n e d f o r t h e fu ll e t h o d i n c l u d i n g d e e p c ut of fs .T h i s r e s u l t t e n d s t o s u p p o r t t h e r c o n t e n t i o n t h a t d e e p c u t o f f s a v e o n l y as e c o n d , r d e r e f fe ct , l t h o u g h w e m u s t a d m i t t h a t p o o r o r d e r i n g o f s u c ce s s o rm o v e s w i l l m a k e d e e p c u t o f f s n c r e a si n g l y a lu a bl e .

    9 . D e p e n d e n t T e r m i n a l V a l u e sO u r m o d e l g iv e s i n d e p e n d e n t v a l u es t o a l l t h e t e r m i n a l p o s i ti o n s , b u t s u c hi nd ep en d en c e d o e s E t h a p p e n v er y o f t e n i n r e al g a m e s. F o r ex a m p le , i f f ( p )Ar t i f i c ia l I n t el li g en ee : 6 ( L 9 7 5 ) , 2 9 3 - , 3 2 6

  • 8/14/2019 An Analysis of Alpha-Beta Pruning

    31/34

    AN ANALYSIS OF ALPHA=BETA PRUNING 32:3

    i s ba se d on the p ie c e c oun t in a c he ss ga m e , a l l t he pos i t ions f o l lowing ab lun de r w i ll t e nd to ha ve low sc o r e s f o r the p la ye r who lose s h i s m e n .

    I n th i s s e c t ion we sha l l t r y to a c c ou n t f o r suc h de pe nde nc ie s b y c ons ide r inga total dependency m ode l , wh ic h ha ~ the f o l lowing p r ope r ty f o r a l l non-t e r m i n a l p o s i ti o n s p : F o r e a c h i a n d A a l l o f t h e t e r m i n a l s u c ce s so r s o f p~e i the r h a ve g r e a te r va lue th a n a l l te r m ina l suc c e sso r s o f p j , o r t he y a l l ha vel es s er v a lu e , T h is m o d e l i s e q u i v a le n t t o a s s i g n in g a p e r m u t a t i o n o f {0 , 1 , . . . ,d - 1} to th e m ove s a t e ve r y pos i t ion , a n d the n l~ sing the c on c a te na t io n o f a llm o v e n u m b e r s l e a d i n g t o a t e r m i n a l p o s i t i o n a s t h a t p o s i t i o n ' s v a l u e ,c o n s i d e re d a s a r a d i x - d n u m b e r . F o r e x a m p l e , F i g . 8 s h o w s a u n i f o r mt e r n a r y g a m e t r e e o f h e i g h t 3 c o n s t r u c te d i n t h i s w a y .

    . / 0 , \ / 1 ~ o , _ / ~ . , ~ ) _2 0 1 . 0 2 1 2 1 0 2 0 1 1 0 2 . 2 0 1 1 0 2 . 0 2 1 . 1 2 0 .

    / ~ I I \ I \ I . ~ \1 0 2 1 ( ~ 0 1 0 1 / [ ~ 1 2 2 1 2 1 1 2 0 / I ~ 0 2 1 0 ~ 0 0 2 2 / I ~ 2 0 ' i 2 ~ 00 ~ 20 2 / ~ z L ~ 1 22 2 22 01 1 0 1 1 2 1 1 1 .0 1 2 0 1 0 0 1 1 0 0 2 O 0 Q0 0 1 2 1 0 2 1 2 2 1 1Fz(~. 8. A t ree wi th " to ta l ly dependent" va lues,

    A n o t h e r w a y t o l o o k a t t h i s m o d e l i s t o i m a g i n e a s s i g n i n g t h e v a l u e s0 , 1 , . . . , d ~ - ! in d - a r y no ta t ion to the t e r m ina l pos i tions , a n d the n to a pp lya r a n d o m p e r m u t a t i o n t o t h e b ra n c h e s e m a n a t i n g f r o m e v e r y n o n t e r m i n a lpos i t ion . I t fo l lows tha t t he F va lue a t t he r o o t o f a t e r n a r y t r e e is a lwa ys- ( 0 2 0 2 . . . 2 0)s i f h i s o d d , + ( 2 0 2 0 . . . 2 0)s i f h i s e ven .

    THEOREM 6. Th e exp ec t ed n u m b er o f t e r m i n a l p o s it io n s exa m i n ed b y t h ealpha-beta procedure, in a random total ly depend ent un i form gam e tree ofdegree d and height h , i s

    d -//~,~,~rht21 dt~12 j H i+- ~ , . - + H a i _ H i ) + H i , ( 52 )w h e re H a = 1 + + . . . + l /d .

    Proo f . A s i n o u r o t h e r p r o o f s , w e d i v id e t h e p o s i t i o n s o f t h e t r ee i n t o af in it e nu m be r o f c l a sse s o r type s f o r wh ic h r e c u r r e nc e r e l a t ion s c a n be g ive n .I n t h i s ca s e w e u se t h re e t y p e s , s o m e w h a t a s i n o u r p r o o f o f T h e o r e m s I a n d 2 .

    A t y p e 1 p o s i t io n p i s e x a m i n e d b y c a l l in g F2(p, a lpha, beta) whe r e a l lt e r m i n a l d e s c e n d an t