"#define key_t" -> hkey_t type
This commit is contained in:
@@ -66,9 +66,9 @@ void zobrist_init(void)
|
||||
*
|
||||
* @return: @pos Zobrist key
|
||||
*/
|
||||
key_t zobrist_calc(pos_t *pos)
|
||||
hkey_t zobrist_calc(pos_t *pos)
|
||||
{
|
||||
key_t key = 0;
|
||||
hkey_t key = 0;
|
||||
|
||||
if (pos->turn == BLACK)
|
||||
key ^= zobrist_turn;
|
||||
|
14
src/hash.h
14
src/hash.h
@@ -24,7 +24,7 @@
|
||||
#define HASH_SIZE_MIN 4
|
||||
#define HASH_SIZE_MAX 32768 /* 32Gb */
|
||||
|
||||
#define key_t u64 /* cannot use typedef for key_t */
|
||||
typedef u64 hkey_t; /* cannot use typedef for key_t */
|
||||
|
||||
/**
|
||||
* hentry_t: hashtable bucket.
|
||||
@@ -33,7 +33,7 @@
|
||||
* 16 bytes in future, it should be updated to be exactly 32 bytes.
|
||||
*/
|
||||
typedef struct {
|
||||
key_t key; /* zobrist */
|
||||
hkey_t key; /* zobrist */
|
||||
union {
|
||||
u64 data;
|
||||
struct {
|
||||
@@ -81,15 +81,15 @@ typedef struct {
|
||||
*/
|
||||
#define EP_ZOBRIST_IDX(ep) ( ( (ep) >> 3 ) | sq_file(ep) )
|
||||
|
||||
extern key_t zobrist_pieces[16][64];
|
||||
extern key_t zobrist_castling[4 * 4 + 1];
|
||||
extern key_t zobrist_turn; /* for black, XOR each ply */
|
||||
extern key_t zobrist_ep[9]; /* 0-7: ep file, 8: SQUARE_NONE */
|
||||
extern hkey_t zobrist_pieces[16][64];
|
||||
extern hkey_t zobrist_castling[4 * 4 + 1];
|
||||
extern hkey_t zobrist_turn; /* for black, XOR each ply */
|
||||
extern hkey_t zobrist_ep[9]; /* 0-7: ep file, 8: SQUARE_NONE */
|
||||
|
||||
extern hasht_t hash_tt; /* main transposition table */
|
||||
|
||||
void zobrist_init(void);
|
||||
key_t zobrist_calc(pos_t *pos);
|
||||
hkey_t zobrist_calc(pos_t *pos);
|
||||
|
||||
#ifdef ZOBRIST_VERIFY
|
||||
bool zobrist_verify(pos_t *pos);
|
||||
|
@@ -61,7 +61,7 @@ pos_t *move_do(pos_t *pos, const move_t move) //, state_t *state)
|
||||
piece_type_t ptype = PIECE(piece);
|
||||
piece_t new_piece = piece;
|
||||
int up = sq_up(us);
|
||||
key_t key = pos->key;
|
||||
hkey_t key = pos->key;
|
||||
|
||||
/* update key: switch turn, reset castling and ep */
|
||||
key ^= zobrist_turn;
|
||||
@@ -146,7 +146,7 @@ pos_t *move_do(pos_t *pos, const move_t move) //, state_t *state)
|
||||
pos->castle = clr_oo(pos->castle, them);
|
||||
}
|
||||
|
||||
/* update castle key */
|
||||
/* update castling rights key */
|
||||
key ^= zobrist_castling[pos->castle];
|
||||
|
||||
pos->key = key;
|
||||
@@ -168,7 +168,7 @@ pos_t *move_do2(pos_t *pos, const move_t move, state_t *state)
|
||||
piece_type_t ptype = PIECE(piece);
|
||||
piece_t new_piece = piece;
|
||||
int up = sq_up(us);
|
||||
key_t key = pos->key;
|
||||
hkey_t key = pos->key;
|
||||
|
||||
*state = pos->state; /* save irreversible changes */
|
||||
|
||||
|
@@ -28,6 +28,13 @@
|
||||
#include "move.h"
|
||||
#include "board.h"
|
||||
|
||||
#define REPEAT_SIZE 1024
|
||||
|
||||
typedef struct {
|
||||
hkey_t key[REPEAT_SIZE];
|
||||
int moves;
|
||||
} repeat_t;
|
||||
|
||||
typedef struct __pos_s {
|
||||
u64 node_count; /* evaluated nodes */
|
||||
int turn; /* WHITE or BLACK */
|
||||
@@ -43,7 +50,7 @@ typedef struct __pos_s {
|
||||
* This allows a memcpy on this data (to save/restore position state).
|
||||
*/
|
||||
struct_group_tagged(state_s, state,
|
||||
key_t key;
|
||||
hkey_t key;
|
||||
square_t en_passant;
|
||||
castle_rights_t castle;
|
||||
int clock_50;
|
||||
@@ -57,6 +64,7 @@ typedef struct __pos_s {
|
||||
piece_t board[BOARDSIZE];
|
||||
bitboard_t bb[2][PIECE_TYPE_MAX]; /* bb[0][PAWN], bb[1][ALL_PIECES] */
|
||||
square_t king[2]; /* dup with bb, faster retrieval */
|
||||
repeat_t repeat; /* for repetition detection */
|
||||
} pos_t;
|
||||
|
||||
typedef struct state_s state_t;
|
||||
|
Reference in New Issue
Block a user