Chess-Challenge icon indicating copy to clipboard operation
Chess-Challenge copied to clipboard

.SquareIsAttackedByOpponent() is problematic to use

Open TomaszJaworski777 opened this issue 2 years ago • 1 comments

.SquareIsAttackedByOpponent() generates the mask of attacks everytime you call it, which is slow, which creates a problem. There should be a way to cache an attack mask and use it in the same position for performance.

I would like to have public mathod .GetAttackMask() that basically returns the mask and allows me to call BitboardHelper.SquareIsSet(moveGen.GetOpponentAttackMap(board), square);

This function already exists, but its hidden in APIMoveGen, just make it public.

TomaszJaworski777 avatar Aug 02 '23 18:08 TomaszJaworski777

The result is cached (the init function is called, which granted it probably shouldn’t be, but it does exit immediately if the initialization step has already been done). I agree it would have been good to expose the underlying bitboard, but as of Aug 1 I’m no longer making changes to the API.

SebLague avatar Aug 05 '23 09:08 SebLague