134
}
Recherche en meilleur d'abord pour les jeux à deux joueurs
for (int i = 1; i <= Taille ; i++)
for (int j = 1; j <= Taille ; j++) {
HashArray [ c] [ i] [ j] = 0;
}
for (int b = O; b < 64; b++)
if (( rand ( ) / (RAND_MAX + 1. 0)) > 0. 5)
HashArray [c] [i] [j ] I = ( llJLL « b);
void joue ( int x, int y, int couleur ) {
goban [x] [y] = couleur ;
hash A: HashArray [couleur ] [x] [y];
}
void dejoue ( int x, int y, int couleur ) {
goban [x] [y] =V ide ;
hash A= HashArray [couleur ] [x] [y];
}
bool gagne ( int x, int y, int couleur ) {
int nb [8] = {O } ;
for ( int i = 1; i < TailleAlignement ; i ++) {
i f ( n b [ 0 ] == i - 1 )
}
if (goban [x] [y - i] == couleur )
nb [O]++;
i f ( n b [ 1 ] == i - 1 )
if ( goba n [ x + i ] [ y - i ] -- c o u 1 e u r )
nb [1]++;
if ( n b [ 2] == i - 1)
if (goban [x + i] [y] -- couleur )
nb [2]++;
if ( n b [ 3] == i - 1 )
if ( goba n [ x + i ] [ y + i ] -- cou 1 eu r )
nb [3]++;
if ( nb [ 4] == i - 1)
if (goban [x] [y + i] -- couleur )
nb [4]++;
i f ( n b [ 5 ] == i - 1 )
if ( goba n [ x - i ] [ y + i ] -- cou 1 eu r )
nb [5]++;
if ( nb [ 6] == i - 1)
if (goban [x - i] [y] -- couleur )
nb [6]++;
i f ( n b [ 7 ] == i - 1 )
if (goban [x - i] [y - i] -- couleur )
nb [7]++;
}
Recherche en meilleur d'abord pour les jeux à deux joueurs
for (int i = 1; i <= Taille ; i++)
for (int j = 1; j <= Taille ; j++) {
HashArray [ c] [ i] [ j] = 0;
}
for (int b = O; b < 64; b++)
if (( rand ( ) / (RAND_MAX + 1. 0)) > 0. 5)
HashArray [c] [i] [j ] I = ( llJLL « b);
void joue ( int x, int y, int couleur ) {
goban [x] [y] = couleur ;
hash A: HashArray [couleur ] [x] [y];
}
void dejoue ( int x, int y, int couleur ) {
goban [x] [y] =V ide ;
hash A= HashArray [couleur ] [x] [y];
}
bool gagne ( int x, int y, int couleur ) {
int nb [8] = {O } ;
for ( int i = 1; i < TailleAlignement ; i ++) {
i f ( n b [ 0 ] == i - 1 )
}
if (goban [x] [y - i] == couleur )
nb [O]++;
i f ( n b [ 1 ] == i - 1 )
if ( goba n [ x + i ] [ y - i ] -- c o u 1 e u r )
nb [1]++;
if ( n b [ 2] == i - 1)
if (goban [x + i] [y] -- couleur )
nb [2]++;
if ( n b [ 3] == i - 1 )
if ( goba n [ x + i ] [ y + i ] -- cou 1 eu r )
nb [3]++;
if ( nb [ 4] == i - 1)
if (goban [x] [y + i] -- couleur )
nb [4]++;
i f ( n b [ 5 ] == i - 1 )
if ( goba n [ x - i ] [ y + i ] -- cou 1 eu r )
nb [5]++;
if ( nb [ 6] == i - 1)
if (goban [x - i] [y] -- couleur )
nb [6]++;
i f ( n b [ 7 ] == i - 1 )
if (goban [x - i] [y - i] -- couleur )
nb [7]++;
