zobrist hashing

This commit is contained in:
2024-09-22 11:45:30 +02:00
parent 4d2a86c7b7
commit db958dcac1
21 changed files with 273 additions and 176 deletions

View File

@ -0,0 +1,22 @@
#include <stdint.h>
#include <stdlib.h>
#include <chess/util.h>
uint_least64_t rand_64() {
uint_least64_t u1, u2, u3, u4;
u1 = (uint_least64_t)(rand()) & 0xFFFF; u2 = (uint_least64_t)(rand()) & 0xFFFF;
u3 = (uint_least64_t)(rand()) & 0xFFFF; u4 = (uint_least64_t)(rand()) & 0xFFFF;
return u1 | (u2 << 16) | (u3 << 32) | (u4 << 48);
}
uint_least64_t zobristPieceI(struct piece_t piece, uint_least8_t field) {
return field * 2 * PIECES_LENGTH + piece.color * PIECES_LENGTH + piece.type;
}
uint_least8_t getFile(const uint_least8_t field) {
return field % BOARD_SIZE;
}
uint_least8_t getRank(const uint_least8_t field) {
return field / BOARD_SIZE;
}