Open KingKobra7899 opened 1 year ago
you can filter the legal moves where the starting square is the square of the piece
I want to get all squares a piece is seeing. Not just the squares it can go to. How can I achieve this? Do I need to write a function for every piece that calculates the vision given a square?
Hi, the BitboardHelper class has some functions for getting a bitboard of all attacked squares by a given piece. See GetSliderAttacks/GetKnightAttacks/GetKingAttacks/GetPawnAttacks. You can then use the GetNumberOfSetBits function for example to count how many squares are set in the bitboard.
Hi, the BitboardHelper class has some functions for getting a bitboard of all attacked squares by a given piece. See GetSliderAttacks/GetKnightAttacks/GetKingAttacks/GetPawnAttacks. You can then use the GetNumberOfSetBits function for example to count how many squares are set in the bitboard.
is there a way to get the number of pieces attacking a particular square?
is there a way to get the number of pieces attacking a particular square?
Nope, SquareIsAttackedByOpponent is a boolean so can't give a number, and otherwise only the IsCapture boolean for moves or the get attacks functions for bitboards can find attacks.
You could create one yourself by iterating over each piece using the bitboard attack functions, or find every square that is attacked using SquareIsAttackedByOpponent and find out how many pieces are attacking it in reverse.
Hi, the BitboardHelper class has some functions for getting a bitboard of all attacked squares by a given piece. See GetSliderAttacks/GetKnightAttacks/GetKingAttacks/GetPawnAttacks. You can then use the GetNumberOfSetBits function for example to count how many squares are set in the bitboard.
Hi, do the GetAttacks functions only consider opponent pieces being attacked? If I use, say, the GetKnightAttacks with a white knight as input, does this return only black pieces in squares under the knight attack, or also white pieces?
Hi, do the GetAttacks functions only consider opponent pieces being attacked? If I use, say, the GetKnightAttacks with a white knight as input, does this return only black pieces in squares under the knight attack, or also white pieces? no, it's not working based on the board, it's just working on bitboard so the knight attacks will just return all 8 squares but, you could bitwise AND it with the bitboard of the opponent pieces so you get a bitboard of oppenent pieces that are attacked by your knight
Hi, do the GetAttacks functions only consider opponent pieces being attacked? If I use, say, the GetKnightAttacks with a white knight as input, does this return only black pieces in squares under the knight attack, or also white pieces? no, it's not working based on the board, it's just working on bitboard so the knight attacks will just return all 8 squares but, you could bitwise AND it with the bitboard of the opponent pieces so you get a bitboard of oppenent pieces that are attacked by your knight
Thank you
I made an eval function in c++ which uses this in addition to material and im trying to implement the same thing for this