74
Recherche avec menaces
}
((joueur == JoueurGauche ) &&
(inter.X > Taille - 1)) Il
( (jo ueur == JoueurGauche ) && in ter . legale () &&
( i n t e r . x == T a i 11 e - 1 ) ) )
return true ;
return false ;
bool coupsLegaux ( int joueur , Iist & liste ) {
for (int i = O; i < Taille ; i++)
}
for (int j = 0; j < Taille ; j++)
i f ( dam i e r [ i ] [ j ] == ' + ' ) {
Intersection inter ;
inte r.X = i;
}
inter .y =j ;
Coup coup ;
coup. 1.push_back (inter );
liste .push_back (coup );
Coup coup ;
coup . 1. push_back (balle );
damier [balle .x] [balle .y] =' +' ;
bool gagne = coupsBalle (joueur , coup , liste );
damier [balle .x] [balle .y] = '@ ' ;
return gagne ;
bool coups Balle ( int joueur , Coup & coup ,
1 i s t & 1 i s te ) {
bool coupGagnant = fa lse ;
for (int i = -1; i <= l; i++)
for (int j = -1; j <= l; j++) {
Intersection inter = balle ;
i n te r . x += i ;
i n t e r . y += j ;
if (inter . legale ())
i f ( damier [ i n ter . x ] [ i n te r . y ] == '0 ' ) {
Coup coupl = coup ;
Iist pierresEnlevees ;
white ( true ) {
coup l .1. push_back ( inter );
pierresEnlevees . push_back (inter );
inter .X += i;
i n te r . y += j ;
if (( inter.X < 0) Il (inter .X >= Taille ) Il
(inter.y < 0) Il (inter .y >= Taille ) Il
(damier [inter .X] [inter .y] != 'O' ))
Recherche avec menaces
}
((joueur == JoueurGauche ) &&
(inter.X > Taille - 1)) Il
( (jo ueur == JoueurGauche ) && in ter . legale () &&
( i n t e r . x == T a i 11 e - 1 ) ) )
return true ;
return false ;
bool coupsLegaux ( int joueur , Iist
for (int i = O; i < Taille ; i++)
}
for (int j = 0; j < Taille ; j++)
i f ( dam i e r [ i ] [ j ] == ' + ' ) {
Intersection inter ;
inte r.X = i;
}
inter .y =j ;
Coup coup ;
coup. 1.push_back (inter );
liste .push_back (coup );
Coup coup ;
coup . 1. push_back (balle );
damier [balle .x] [balle .y] =' +' ;
bool gagne = coupsBalle (joueur , coup , liste );
damier [balle .x] [balle .y] = '@ ' ;
return gagne ;
bool coups Balle ( int joueur , Coup & coup ,
1 i s t
bool coupGagnant = fa lse ;
for (int i = -1; i <= l; i++)
for (int j = -1; j <= l; j++) {
Intersection inter = balle ;
i n te r . x += i ;
i n t e r . y += j ;
if (inter . legale ())
i f ( damier [ i n ter . x ] [ i n te r . y ] == '0 ' ) {
Coup coupl = coup ;
Iist
white ( true ) {
coup l .1. push_back ( inter );
pierresEnlevees . push_back (inter );
inter .X += i;
i n te r . y += j ;
if (( inter.X < 0) Il (inter .X >= Taille ) Il
(inter.y < 0) Il (inter .y >= Taille ) Il
(damier [inter .X] [inter .y] != 'O' ))
