diff options
author | eug-vs <eugene@eug-vs.xyz> | 2022-09-14 05:43:13 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2022-09-14 05:43:13 +0300 |
commit | 2dfa7cecdacacf7ef84e1ca768db6d636e225a0c (patch) | |
tree | d3573f22aabe6567c15a489aabe4d01792d76a50 /src/board.c | |
parent | 9bbba5c582ea2dcbf5f22503127765999f06264c (diff) | |
download | j1chess-2dfa7cecdacacf7ef84e1ca768db6d636e225a0c.tar.gz |
feat: compute pawn attack table
Diffstat (limited to 'src/board.c')
-rw-r--r-- | src/board.c | 15 |
1 files changed, 12 insertions, 3 deletions
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; } } |