hash: add hash_short macro, state_s: add prev and move
This commit is contained in:
@@ -30,6 +30,11 @@
|
|||||||
|
|
||||||
typedef u64 hkey_t; /* cannot use typedef for key_t */
|
typedef u64 hkey_t; /* cannot use typedef for key_t */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* hash_short: return the value of a hash first 7 MSB.
|
||||||
|
*/
|
||||||
|
#define hash_short(hash) ((hash) >> (64 - 8))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hentry_t: hashtable bucket.
|
* hentry_t: hashtable bucket.
|
||||||
*
|
*
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
#include "attack.h"
|
#include "attack.h"
|
||||||
|
#include "hist.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pos_new() - allocate a new position
|
* pos_new() - allocate a new position
|
||||||
@@ -123,8 +124,6 @@ pos_t *pos_clear(pos_t *pos)
|
|||||||
pos->pinners = 0;
|
pos->pinners = 0;
|
||||||
pos->blockers = 0;
|
pos->blockers = 0;
|
||||||
|
|
||||||
pos->repeat.moves = 0;
|
|
||||||
|
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,10 +166,12 @@ bool pos_cmp(const pos_t *pos1, const pos_t *pos2)
|
|||||||
if (_cmpf(checkers) ||_cmpf(pinners) || _cmpf(blockers))
|
if (_cmpf(checkers) ||_cmpf(pinners) || _cmpf(blockers))
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
if (_cmpf(repeat.moves) ||
|
/*
|
||||||
memcmp(pos1->repeat.key, pos2->repeat.key,
|
* if (_cmpf(repeat.moves) ||
|
||||||
pos1->repeat.moves * sizeof pos1->repeat.key))
|
* memcmp(pos1->repeat.key, pos2->repeat.key,
|
||||||
goto end;
|
* pos1->repeat.moves * sizeof pos1->repeat.key))
|
||||||
|
* goto end;
|
||||||
|
*/
|
||||||
|
|
||||||
ret = true;
|
ret = true;
|
||||||
end:
|
end:
|
||||||
@@ -429,7 +430,7 @@ void pos_print(const pos_t *pos)
|
|||||||
char str[128];
|
char str[128];
|
||||||
|
|
||||||
board_print(pos->board);
|
board_print(pos->board);
|
||||||
printf("key:%lx ", pos->key);
|
printf("key:%lx (#%lx)", pos->key, hash_short(pos->key));
|
||||||
printf("fen: %s\n", pos2fen(pos, str));
|
printf("fen: %s\n", pos2fen(pos, str));
|
||||||
printf("checkers:%s ", pos_checkers2str(pos, str, sizeof(str)));
|
printf("checkers:%s ", pos_checkers2str(pos, str, sizeof(str)));
|
||||||
printf("pinners: %s ", pos_pinners2str(pos, str, sizeof(str)));
|
printf("pinners: %s ", pos_pinners2str(pos, str, sizeof(str)));
|
||||||
|
@@ -28,13 +28,6 @@
|
|||||||
#include "move.h"
|
#include "move.h"
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
|
|
||||||
#define REPEAT_SIZE 1024
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
hkey_t key[REPEAT_SIZE];
|
|
||||||
int moves;
|
|
||||||
} repeat_t;
|
|
||||||
|
|
||||||
typedef struct __pos_s {
|
typedef struct __pos_s {
|
||||||
u64 node_count; /* evaluated nodes */
|
u64 node_count; /* evaluated nodes */
|
||||||
int turn; /* WHITE or BLACK */
|
int turn; /* WHITE or BLACK */
|
||||||
@@ -56,6 +49,8 @@ typedef struct __pos_s {
|
|||||||
int clock_50;
|
int clock_50;
|
||||||
int plycount; /* plies so far, start from 1 */
|
int plycount; /* plies so far, start from 1 */
|
||||||
piece_t captured; /* only used in move_undo */
|
piece_t captured; /* only used in move_undo */
|
||||||
|
move_t move;
|
||||||
|
struct state_s *prev;
|
||||||
);
|
);
|
||||||
bitboard_t checkers; /* opponent checkers */
|
bitboard_t checkers; /* opponent checkers */
|
||||||
bitboard_t pinners; /* opponent pinners */
|
bitboard_t pinners; /* opponent pinners */
|
||||||
@@ -64,7 +59,6 @@ typedef struct __pos_s {
|
|||||||
piece_t board[BOARDSIZE];
|
piece_t board[BOARDSIZE];
|
||||||
bitboard_t bb[2][PIECE_TYPE_MAX]; /* bb[0][PAWN], bb[1][ALL_PIECES] */
|
bitboard_t bb[2][PIECE_TYPE_MAX]; /* bb[0][PAWN], bb[1][ALL_PIECES] */
|
||||||
square_t king[2]; /* dup with bb, faster retrieval */
|
square_t king[2]; /* dup with bb, faster retrieval */
|
||||||
repeat_t repeat; /* for repetition detection */
|
|
||||||
} pos_t;
|
} pos_t;
|
||||||
|
|
||||||
typedef struct state_s state_t;
|
typedef struct state_s state_t;
|
||||||
|
Reference in New Issue
Block a user