zobrist hashing
This commit is contained in:
22
src/common/preCodeGen/util.c
Normal file
22
src/common/preCodeGen/util.c
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user