From 4eb620a873064508683a2b33b8dc2a1e2a119de2 Mon Sep 17 00:00:00 2001 From: Bruno Raoult Date: Fri, 15 Mar 2024 09:14:10 +0100 Subject: [PATCH] add occ param in sq_attackers() --- src/attack.c | 8 +++++--- src/attack.h | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/attack.c b/src/attack.c index 9c2e003..bc09669 100644 --- a/src/attack.c +++ b/src/attack.c @@ -26,6 +26,7 @@ /** * sq_attackers() - find attackers on a square * @pos: position + * @occ: occupation mask used * @sq: square to test * @c: attacker color * @@ -39,11 +40,11 @@ * * @Return: a bitboard of attackers. */ -bitboard_t sq_attackers(const pos_t *pos, const square_t sq, const color_t c) +bitboard_t sq_attackers(const pos_t *pos, const bitboard_t occ, const square_t sq, const color_t c) { bitboard_t attackers = 0, tmp; bitboard_t sqbb = mask(sq); - bitboard_t occ = pos_occ(pos); + //bitboard_t occ = pos_occ(pos); bitboard_t to; color_t opp = OPPONENT(c); @@ -151,5 +152,6 @@ bitboard_t sq_pinners(const pos_t *pos, const square_t sq, const color_t color) */ bitboard_t sq_attackers_all(const pos_t *pos, const square_t sq) { - return sq_attackers(pos, sq, WHITE) | sq_attackers(pos, sq, BLACK); + bitboard_t occ = pos_occ(pos); + return sq_attackers(pos, occ, sq, WHITE) | sq_attackers(pos, occ, sq, BLACK); } diff --git a/src/attack.h b/src/attack.h index c388939..603a965 100644 --- a/src/attack.h +++ b/src/attack.h @@ -17,7 +17,7 @@ #include "chessdefs.h" #include "bitboard.h" -extern bitboard_t sq_attackers(const pos_t *pos, const square_t sq, const color_t c); -extern bitboard_t sq_attackers_all(const pos_t *pos, const square_t sq); -extern bitboard_t sq_pinners(const pos_t *pos, const square_t sq, const color_t c); +bitboard_t sq_attackers(const pos_t *pos, const bitboard_t occ, const square_t sq, const color_t c); +bitboard_t sq_attackers_all(const pos_t *pos, const square_t sq); +bitboard_t sq_pinners(const pos_t *pos, const square_t sq, const color_t c); #endif