Im trying to add AttacksTo() function using bitboards but has became a headache and Im sorry for the stupid question
Im using this example: https://chessprogramming.wikispaces.com ... l%20Pieces
The problem that Im facing it's how it works?, I store each piece bb in the variable:
Code: Select all
U64 pieceBB[COLOR][PIECE_TYPE]Code: Select all
U64 arrPawnAttacks[COLOR][SQUARE]Code: Select all
U64 arrKnightAttacks[BOTH][SQUARE]Im testing using this example position:
[d]8/8/6k1/4pnp1/8/5PPP/6K1/8 w - - 0 37
The occupied pieces bb is: 70849795211264
I use A1 = 0, H8 = 63 bitboard, so Im looking if there is an attacker in the G3 = 22 that is the KNIGH in the F5 square
Now this is the problem, in the variable:
Code: Select all
U64 arrKnightAttacks[BOTH][22]Do I have to set one bit in each square attaked? for example:
Pseudo code:
Code: Select all
U64 attack_squares = KnightsAttacks(1ULL << sq)
while (attack_squares) {
POP(&attack_squares)
if (arrKnightAttacks[BOTH][attack_squares] == 0ULL)
arrKnightAttacks[BOTH][attack_squares] = 1ULL << sq
}