38
Minimax, Alpha-Bêta et heuristiques associées
const int ProfondeurMax = 64;
int quiescence ( int alpha , int beta , char joueur ) {
if (clock () - clockStart > maxClock )
}
return 0;
list coups = virus . coupsQuiescence (joueur );
if (coups . empty ())
return virus . evaluation (joueur );
char autre = virus . adversaire (joueur );
fo r (list:: iterator it = coups .begin ();
}
i t ! = coups . end () ; ++ i t ) {
virus .joue (* it );
int eval =- quiescence (-beta , -alpha , autre );
virus . dejoue (* it );
if (eval >a lpha)
alpha = eval ;
if (alpha >= beta )
return beta ;
return alpha ;
int alphabeta ( int depth , int alpha , int beta , char joueur ,
1 i s t & vp ) {
if (clock () - clockStart > maxClock )
return 0;
if ( depth == 0)
return quiescence (alpha , beta , joueur );
list listeCoups = virus . coupsLegaux (joueur );
if (listeCoups .empty ())
return virus . evaluationSiPlusDeCoupsPossibles (joueur );
char autre = virus . adversaire (joueur );
fo r (list:: iterator it = listeCoups . begin ();
i t ! = 1 i s te Coups . end ( ) ; ++ i t ) {
virus . joue (* it );
1 i s t vptemp ;
int eval = -alphabeta ( depth - 1, -beta , -alpha , autre ,
vptemp );
if (eval >a lpha) {
alpha = eval ;
vp = vptemp ;
Minimax, Alpha-Bêta et heuristiques associées
const int ProfondeurMax = 64;
int quiescence ( int alpha , int beta , char joueur ) {
if (clock () - clockStart > maxClock )
}
return 0;
list
if (coups . empty ())
return virus . evaluation (joueur );
char autre = virus . adversaire (joueur );
fo r (list
}
i t ! = coups . end () ; ++ i t ) {
virus .joue (* it );
int eval =- quiescence (-beta , -alpha , autre );
virus . dejoue (* it );
if (eval >a lpha)
alpha = eval ;
if (alpha >= beta )
return beta ;
return alpha ;
int alphabeta ( int depth , int alpha , int beta , char joueur ,
1 i s t
if (clock () - clockStart > maxClock )
return 0;
if ( depth == 0)
return quiescence (alpha , beta , joueur );
list
if (listeCoups .empty ())
return virus . evaluationSiPlusDeCoupsPossibles (joueur );
char autre = virus . adversaire (joueur );
fo r (list
i t ! = 1 i s te Coups . end ( ) ; ++ i t ) {
virus . joue (* it );
1 i s t
int eval = -alphabeta ( depth - 1, -beta , -alpha , autre ,
vptemp );
if (eval >a lpha) {
alpha = eval ;
vp = vptemp ;
