5.9 Corrigés des exercices
return somme / nb ;
}
fl oat moyenne ( int i, int j, int profondeur) {
if (pr ofondeur == 0) {
return ( sommeScore [ i] [ j] + 1)
(nbPlayoutsCoup [i] [j ] + 2);
}
else if (fils [i] [j ] != NULL)
119
return 1.0 - fils [i] [j]->moyenne (profondeur - 1);
else {
if (nbPlayoutsCoup [i] [j ] == 0)
return 0.0;
return sommeScore [ i] [ j] / nbPlayoutsCoup [ i] [ j];
}
}
int nbPlayouts ( int profondeur) {
int nb = O;
for (int i = O; i <= Taille ; i++)
for ( in t j = 0; j <= Tai 11 e ; j ++)
if (pr ofondeur == 0)
n b += n b P 1 a y ou t s Cou p [ i ] [ j ] ;
else if (fils [i] [j ] != NULL ) {
n b += f i 1 s [ i ] [ j ] - > n b P 1 a y o u t s ( p ro fo n de u r - 1 ) ;
}
return nb ;
}
int nbPlayoutsFils ( int i, int j, int profondeur) {
if (profondeur == 0)
return nbPlayoutsCoup [ i] [j ];
else if (fils [i] [j ] != NULL)
return fi ls [i] [j]->nbPlayouts (profondeur - 1);
el se
return nbPlayoutsCoup [ i] [ j];
}
void modifieAMAF ( int nbCoups , Go & goban ,
int couleur ) {
dejavu .init ();
for (int i = nbCoups ; i < goban . nbCoupsJoues ;
Intersection inter = goban . moves [i];
i f ( i n te r . _x ! = 0) {
if (! dejavu . marquee (inter )) {
dejavu . marque (inter );
if ((( i - nbCoups) & 1) == 0) {
++) {
Précédent

- 133/256

Suivant