diff --git a/src/chessdefs.h b/src/chessdefs.h index 136f3bc..c531ed4 100644 --- a/src/chessdefs.h +++ b/src/chessdefs.h @@ -18,9 +18,10 @@ #define ONE 1ull #define U64(const_u64) const_u64##ULL -#define BIT(i) ( (u64) (ONE << (i)) ) +#define BIT(i) ( (u64) (ONE << (i)) ) #define BOARDSIZE (8*8) +#define GAMESIZE 1024 /* max game size (512 moves) */ /** * sq_rel - get relative square diff --git a/src/eval.h b/src/eval.h index de16353..07158ee 100644 --- a/src/eval.h +++ b/src/eval.h @@ -1,6 +1,6 @@ /* eval.h - static position evaluation. * - * Copyright (C) 2021 Bruno Raoult ("br") + * Copyright (C) 2021-2024 Bruno Raoult ("br") * Licensed under the GNU General Public License v3.0 or later. * Some rights reserved. See COPYING. * diff --git a/src/position.c b/src/position.c index faaaa0a..53fd591 100644 --- a/src/position.c +++ b/src/position.c @@ -123,7 +123,8 @@ pos_t *pos_clear(pos_t *pos) pos->pinners = 0; pos->blockers = 0; - //pos->moves.nmoves = 0; + pos->repeat.moves = 0; + return pos; } @@ -131,9 +132,11 @@ pos_t *pos_clear(pos_t *pos) * pos_cmp() - compare two positions.. * @pos1, @pos2: The two &position. * + * Used only for move_{do,undo} test/debug. + * * @return: true if equal, false otherwise. */ -bool pos_cmp(__unused const pos_t *pos1, __unused const pos_t *pos2) +bool pos_cmp(const pos_t *pos1, const pos_t *pos2) { #define _cmpf(a) (pos1->a != pos2->a) bool ret = false; @@ -142,8 +145,11 @@ bool pos_cmp(__unused const pos_t *pos1, __unused const pos_t *pos2) goto end; /* move_do/undo position state */ - if (_cmpf(en_passant) || _cmpf(castle) || - _cmpf(clock_50) || _cmpf(plycount)) + if (_cmpf(key) || _cmpf(en_passant) || _cmpf(castle) || + _cmpf(clock_50) || _cmpf(plycount) || _cmpf(captured)) + goto end; + + if (_cmpf(checkers) || _cmpf(pinners) || _cmpf(blockers)) goto end; for (square_t sq = A1; sq <= H8; ++sq) @@ -151,7 +157,7 @@ bool pos_cmp(__unused const pos_t *pos1, __unused const pos_t *pos2) goto end; for (color_t color = WHITE; color <= BLACK; ++color) { - for (piece_type_t piece = 0; piece <= KING; ++piece) + for (piece_type_t piece = ALL_PIECES; piece <= KING; ++piece) if (_cmpf(bb[color][piece])) goto end; if (_cmpf(king[color])) @@ -161,6 +167,11 @@ bool pos_cmp(__unused const pos_t *pos1, __unused 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; + ret = true; end: return ret; diff --git a/src/util.h b/src/util.h index 8ce8dd8..94a1e02 100644 --- a/src/util.h +++ b/src/util.h @@ -43,6 +43,6 @@ /* restore BUG_ON */ -# pragma pop_macro("BUG_ON") +#pragma pop_macro("BUG_ON") #endif /* UTIL_H */