Closed Orbital-Web closed 1 year ago
Cool, thanks! Could you also document this in the docs? docs/board-object.md
and change the description to this?
/// @brief Returns a bitboard with the origin squares of the attacking pieces set.
/// @param color Attacker Color
/// @param square Attacked Square
/// @param occupied
/// @return
Yup, those changes are pushed now.
Hi, thanks again ^^
Just wanted to let you know that I moved the attackers
function into the attacks
namespace and moved that namespace (attacks
) out of the movegen namespace.
So previous movegen::attacks::
are now just attacks::
and board.attackers()
is attacks::attackers(board, ...)
Hi, I noticed a pretty important issue. After commit 96b5fae (where the namespaces have been moved around), any cpp files that includes the chess library no longer works. This can be tested by creating a cpp file with the content
#include <chess.hpp>
int main() {
std::cout << "Hello World!\n";
return 0;
}
The program compiles, but does not print Hello World as intended. This was just a demonstration to show that the cpp file does not work, but any code inside main will not run. I have no idea why this happens though.
Another thing, I noticed in the code I wrote that the attackers
method should be defined as a const method to avoid passing 'const chess::Board' as 'this' argument discards qualifiers [-fpermissive]
, though I guess this won't be a problem if attackers
is being moved into attacks
namespace taking board
as an input.
Thanks for pointing this out, idk how I missed this. Should be fixed now.
Hi, this is my first commit on a public repo so I apologize in advance if I made a terrible mistake somewhere (either in my code or in this general process).
Anyways, I made two main changes.
One is that I added a
attackers()
method inside of theBoard
class to get a bitboard for every piece of a certain color attacking a certain square. I addedoccupancy
as a parameter to help find xray attackers, which is mostly useful for implementing Static Exchange Evaluations in engines (hence why I made this PR). You can basically modify the occupancy you input to virtually remove certain pieces, such as the first rook in a double rook battery, allowing you to find more attackers without having to play out any move.The other change is a very minor one; I just replaced the
isAttacked
code inside game end detection withinCheck
for readability (and less repetition, I guess).