5.9 Corrigés des exercices
107
Intersection choisirUnCoup (int couleur ) {
}
int urgence [Taille + 2] [Taille + 2] , nbUrgences = O;
Intersection inter ;
fo r (int i = 1; i <= Taille ; i++)
for ( in t j = 1 ; j <= Tai Il e ; j + +)
if (goban [ i] [j ] == Vide ) {
urgence [i] [j ] = l;
nb Urgences++;
}
el se
urgence [i] [j ] = O;
do {
}
i f ( n b Urgence s <= 0)
return Intersection (0 , O);
int index = (int ) (nbUrgences *
(rand () / (RAND_MAX + 1. 0)));
int somme = O;
for ( in t i = l ; ( ( i <= Tai 11 e ) && (somme <= index ) ) ;
i ++)
for ( i n t j = l ; ( ( j <= T a i Il e ) &&
(somme <= index )); j++)
if (urgence [i] [j ] > 0) {
}
somme += urgence [ i ] [ j ] ;
i f ( somme > index ) {
inter = Intersection (i , j );
}
nbUrgences -= urgence [inter ._x] [inter ._y];
urgence [ inter . _x ] [ i nt e r . _y ] = 0;
while ( entouree (inter , couleur ) 11
!coupLegal (inter , couleur ));
return inter ;
void playout (int couleur ) {
for (;;) {
if (( nbCoupsJoues >= MaxCoups ) Il
gameOver ())
break ;
Intersection inter = choisirUnCoup (couleur );
Précédent

- 121/256

Suivant