From 374116b1e793f106772327bc0049e7e062e827b9 Mon Sep 17 00:00:00 2001 From: Bruno Raoult Date: Wed, 10 Apr 2024 15:59:24 +0200 Subject: [PATCH] simplify pos_set_checkers_pinners_blockers() (cont'd) --- src/position.c | 9 +++------ test/perft-test.c | 2 ++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/position.c b/src/position.c index 047a561..533ff8f 100644 --- a/src/position.c +++ b/src/position.c @@ -201,9 +201,8 @@ void pos_set_checkers_pinners_blockers(pos_t *pos) bitboard_t occ = pos_occ(pos); bitboard_t attackers; bitboard_t checkers = 0, blockers = 0, pinners = 0; - bitboard_t targets, tmpcheckers, maybeblockers, tmppinners, tmpbb; + bitboard_t targets, tmpcheckers, maybeblockers, tmppinners; square_t king = pos->king[us]; - bitboard_t king_bb = mask(king); int pinner; /* bishop type - we attack with a bishop from king position */ @@ -216,7 +215,7 @@ void pos_set_checkers_pinners_blockers(pos_t *pos) tmpcheckers = targets & attackers; checkers |= tmpcheckers; - /* maybe blockers = not checkers */ + /* maybe blockers = we remove checkers, to look "behind" */ maybeblockers = targets & ~tmpcheckers; /* we find second targets, by removing first ones (excl. checkers) */ @@ -256,9 +255,7 @@ void pos_set_checkers_pinners_blockers(pos_t *pos) checkers |= bb_pawn_attacks[us][king] & pos->bb[them][PAWN]; /* knight */ - attackers = pos->bb[them][KNIGHT]; - targets = bb_knight[king] & attackers; - checkers |= targets; + checkers |= bb_knight[king] & pos->bb[them][KNIGHT]; pos->checkers = checkers; pos->pinners = pinners; diff --git a/test/perft-test.c b/test/perft-test.c index c813bf0..695335c 100644 --- a/test/perft-test.c +++ b/test/perft-test.c @@ -299,6 +299,8 @@ int main(int __unused ac, __unused char**av) pos_del(savepos); pos_del(pos); i++; + /* to run first test only */ + // exit(0); } if (run & 1) printf("total perft %'ldms\n", ms1_total);