From 2dfa7cecdacacf7ef84e1ca768db6d636e225a0c Mon Sep 17 00:00:00 2001 From: eug-vs Date: Wed, 14 Sep 2022 05:43:13 +0300 Subject: feat: compute pawn attack table --- src/board.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/board.c') diff --git a/src/board.c b/src/board.c index a0b1bb7..0c133a8 100644 --- a/src/board.c +++ b/src/board.c @@ -37,9 +37,18 @@ void precompute_king_attack_table(Bitboard attacks[64]) { U64 position = BIT << index; attacks[index] = - (position & notAFile) << 7 | (position << 8) | (position & notHFile) << 9 | - (position & notAFile) >> 1 | (position & notHFile) << 1 | - (position & notAFile) >> 9 | (position >> 8) | (position & notHFile) >> 7; + (position & notAFile) << 7 | (position << 8) | (position & notHFile) << 9 | + (position & notAFile) >> 1 | (position & notHFile) << 1 | + (position & notAFile) >> 9 | (position >> 8) | (position & notHFile) >> 7; + } +} + +void precompute_pawn_attack_table(Bitboard attacks[64], BYTE color) { + for (int index = 0; index < 64; index++) { + U64 position = BIT << index; + + if (color == WHITE) attacks[index] = (position & notAFile) << 7 | (position & notHFile) << 9; + else attacks[index] = (position & notAFile) >> 9 | (position & notHFile) >> 7; } } -- cgit v1.2.3