stellar

UCI Chess engine written in C++20
git clone git://git.dimitrijedobrota.com/stellar.git
Log | Files | Refs | README | LICENSE

commit 7ee440bb0ac6b207d99d69730ba6002bb908d96c
parent a5f8800b539804350d13c2d53d198c97a52bdfa1
author Dimitrije Dobrota <mail@dimitrijedobrota.com>
date Mon, 19 Sep 2022 17:18:23 +0200

Knight attack mask

Diffstat:
M src/engine.c | ++++++++++++++++++++ -

1 files changed, 20 insertions(+), 1 deletions(-)


diff --git a/ src/engine.c b/ src/engine.c

@@ -119,6 +119,9 @@ void bitboard_print(U64 bitboard) { // pawn attack table [side][square] U64 pawn_attacks[2][64];
// knight attack table [square]
U64 knight_attacks[64];
// generate pawn attack U64 mask_pawn_attacks(int side, int square) { U64 bitboard = C64(0), attacks;

@@ -130,11 +133,27 @@ U64 mask_pawn_attacks(int side, int square) { return soWeOne(bitboard) | soEaOne(bitboard); }
U64 mask_knight_attacks(int square) {
U64 bitboard = C64(0), attacks = C64(0), tmp;
bit_set(bitboard, square);
tmp = nortOne(nortOne(bitboard));
attacks |= westOne(tmp) | eastOne(tmp);
tmp = soutOne(soutOne(bitboard));
attacks |= westOne(tmp) | eastOne(tmp);
tmp = westOne(westOne(bitboard));
attacks |= soutOne(tmp) | nortOne(tmp);
tmp = eastOne(eastOne(bitboard));
attacks |= soutOne(tmp) | nortOne(tmp);
return attacks;
}
void init_leapers_attacks(void) { for (int square = 0; square < 64; square++) { pawn_attacks[WHITE][square] = mask_pawn_attacks(WHITE, square); pawn_attacks[BLACK][square] = mask_pawn_attacks(BLACK, square);
bitboard_print(pawn_attacks[WHITE][square]);
knight_attacks[square] = mask_knight_attacks(square);
} }