Bah j'ai essayé d'utiliser des zobrist keys :
<code>
long long rand64(void)
{
srand(time(NULL));
return rand() ^ ((long long)rand() << 15) ^ ((long long)rand() << 30) ^ ((long long)rand() << 45)
^ ((long long)rand() << 60);
}
void init_table(void)
{
for (int i = 0; i < SIZE10; i++) {
for (int j = 0; j < NB_PIECES; j++) {
for (int k = 0; k < NB_PIECES; k++)
table[j][k][i] = rand64();
}
}
}
long long zobrist_key(board_t *board)
{
long long h = 0;
int k = (int) (board->player == BLACK_DISC);
int size = (int) board->size * board->size;
for (int i = 0; i < size * size; i++) {
if ((board->black & (1 << i)) || (board->white & (1 << i))) {
long long j = (board->black & (1 << i)) ? 1 : 2;
h = h ^ table[i][k][j];
}
}
return h;
}
int search_node(board_t *board, int depth, int alpha, int beta)
{
hashe *entry = &hash_table[zobrist_key(board) % TABLE_SIZE];
if (entry->key == zobrist_key(board)) {
if (entry->depth >= depth) {
if (entry->flag == HASH_EXACT)
return entry->value;
if ((entry->flag == HASH_ALPHA) && (entry->value <= alpha))
return alpha;
if ((entry->flag == HASH_BETA) && (entry->value >= beta))
return beta;
}
}
return UNKNOWN;
}
void record_node(board_t *board, int depth, int value, int flag)
{
hashe *entry = &hash_table[zobrist_key(board) % TABLE_SIZE];
entry->key = zobrist_key(board);
entry->value = value;
entry->flag = flag;
entry->depth = depth;
}
</code>
Dans mon fichier.h j'ai mis ces variables :
<code>
typedef struct hashentry {
long long key;
int depth;
int value;
int flag;
} hashe;
long long table[NB_PIECES][NB_PIECES][SIZE10]; /* [color piece][player][square] */
hashe hash_table[TABLE_SIZE];
</code>
sauf que je reçois le message segmentation fault quand j'essaie de l'utiliser dans mon algo alpha beta