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 */
|
||||
|
||||
/**
|
||||
* hash_short: return the value of a hash first 7 MSB.
|
||||
*/
|
||||
#define hash_short(hash) ((hash) >> (64 - 8))
|
||||
|
||||
/**
|
||||
* hentry_t: hashtable bucket.
|
||||
*
|
||||
|
@@ -30,6 +30,7 @@
|
||||
#include "misc.h"
|
||||
#include "board.h"
|
||||
#include "attack.h"
|
||||
#include "hist.h"
|
||||
|
||||
/**
|
||||
* pos_new() - allocate a new position
|
||||
@@ -123,8 +124,6 @@ pos_t *pos_clear(pos_t *pos)
|
||||
pos->pinners = 0;
|
||||
pos->blockers = 0;
|
||||
|
||||
pos->repeat.moves = 0;
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
@@ -167,10 +166,12 @@ bool pos_cmp(const pos_t *pos1, const pos_t *pos2)
|
||||
if (_cmpf(checkers) ||_cmpf(pinners) || _cmpf(blockers))
|
||||
goto end;
|
||||
|
||||
if (_cmpf(repeat.moves) ||
|
||||
memcmp(pos1->repeat.key, pos2->repeat.key,
|
||||
pos1->repeat.moves * sizeof pos1->repeat.key))
|
||||
goto end;
|
||||
/*
|
||||
* if (_cmpf(repeat.moves) ||
|
||||
* memcmp(pos1->repeat.key, pos2->repeat.key,
|
||||
* pos1->repeat.moves * sizeof pos1->repeat.key))
|
||||
* goto end;
|
||||
*/
|
||||
|
||||
ret = true;
|
||||
end:
|
||||
@@ -429,7 +430,7 @@ void pos_print(const pos_t *pos)
|
||||
char str[128];
|
||||
|
||||
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("checkers:%s ", pos_checkers2str(pos, str, sizeof(str)));
|
||||
printf("pinners: %s ", pos_pinners2str(pos, str, sizeof(str)));
|
||||
|
@@ -28,13 +28,6 @@
|
||||
#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 */
|
||||
@@ -56,6 +49,8 @@ typedef struct __pos_s {
|
||||
int clock_50;
|
||||
int plycount; /* plies so far, start from 1 */
|
||||
piece_t captured; /* only used in move_undo */
|
||||
move_t move;
|
||||
struct state_s *prev;
|
||||
);
|
||||
bitboard_t checkers; /* opponent checkers */
|
||||
bitboard_t pinners; /* opponent pinners */
|
||||
@@ -64,7 +59,6 @@ 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