3.9 Corrigés des exercices
3.9. 7 Coupes de transposition améliorées
int alphabeta ( int depth , int alpha , int beta ,
char joueur , lis t & vp ) {
if ( clock () - clockStart > maxClock )
return O;
if ( depth == 0)
return quiescence (alpha , beta , joueur );
char autre = virus . adversaire (joueur );
/* Coupes selectives avec coup nul */
int R = 2;
if (depth >R+ 1) {
1 i s t vptemp ;
}
int eval = -alphabeta ( depth
1 - R, -beta ,
if ( eval >= be ta )
return beta ;
-beta + 1, autre , vptemp );
/* fi n des coupes selectives avec coup nul */
Coup transpoMove ;
GenericTranspo *t =T T. look (& virus );
if (t != NULL) {
}
if (t->depth >= depth ) {
}
if (t->scoreExact ) return t->score ;
else alpha =m ax (alpha , (int )t->score );
if (alpha >= beta ) return beta ;
transpoMove = t->best ;
list listeCoups = virus .coupsLegaux (joueur );
if ( listeCoups . empty ())
63
return virus . evaluat ionSiPlusDeCoupsPossibles (joueur );
/* coupes de transposition améliorées */
if ( depth > 2)
for (list:: iterator it = listeCoups .begin ();
i t != listeCoups . end () && alpha < beta ;
++ i t) {
virus . joue (* it );
GenericTranspo * tl =TT . look (& virus );
if (tl != NULL)
if (tl ->d epth >= depth - 1)
if (tl ->scoreExact)
3.9. 7 Coupes de transposition améliorées
int alphabeta ( int depth , int alpha , int beta ,
char joueur , lis t
if ( clock () - clockStart > maxClock )
return O;
if ( depth == 0)
return quiescence (alpha , beta , joueur );
char autre = virus . adversaire (joueur );
/* Coupes selectives avec coup nul */
int R = 2;
if (depth >R+ 1) {
1 i s t
}
int eval = -alphabeta ( depth
1 - R, -beta ,
if ( eval >= be ta )
return beta ;
-beta + 1, autre , vptemp );
/* fi n des coupes selectives avec coup nul */
Coup transpoMove ;
GenericTranspo
if (t != NULL) {
}
if (t->depth >= depth ) {
}
if (t->scoreExact ) return t->score ;
else alpha =m ax (alpha , (int )t->score );
if (alpha >= beta ) return beta ;
transpoMove = t->best ;
list
if ( listeCoups . empty ())
63
return virus . evaluat ionSiPlusDeCoupsPossibles (joueur );
/* coupes de transposition améliorées */
if ( depth > 2)
for (list
i t != listeCoups . end () && alpha < beta ;
++ i t) {
virus . joue (* it );
GenericTranspo
if (tl != NULL)
if (tl ->d epth >= depth - 1)
if (tl ->scoreExact)
