AttackInfo calculation isn't very neat and the code is pretty bad, but it is correct, so it stays like that for now. However, ultimately the AttackInfo is only used in
Move generation
Position::in_check
Both of these are on very hot paths and would benefit from refactoring, simplifying and making it easier to tweak for performance reason.
Specifically, what could be done is:
[ ] (possibly) Inline and simplify AttackInfo calculation in attacks.rs, so that it's maintainable and easier to modify
[ ] Stop calculating AttackInfo in Position::in_check at all and just calculate attacks on the king directly, also possibly separate it into a different function that will be used in the Move Generation (since attacks on the king are part of the AttackInfo calculation anyway for the purpose of generating the moves)
The latter is definitely a performance gainer, but it's unclear how much. Given that it's on the very hot path, it should be important enough.
AttackInfo
calculation isn't very neat and the code is pretty bad, but it is correct, so it stays like that for now. However, ultimately theAttackInfo
is only used inPosition::in_check
Both of these are on very hot paths and would benefit from refactoring, simplifying and making it easier to tweak for performance reason.
Specifically, what could be done is:
AttackInfo
calculation inattacks.rs
, so that it's maintainable and easier to modifyAttackInfo
inPosition::in_check
at all and just calculate attacks on the king directly, also possibly separate it into a different function that will be used in the Move Generation (since attacks on the king are part of theAttackInfo
calculation anyway for the purpose of generating the moves)The latter is definitely a performance gainer, but it's unclear how much. Given that it's on the very hot path, it should be important enough.
https://github.com/kirillbobyrev/pabi/blob/9b99bd27d8f0e7e42ca384f4152dc0889bf13e77/src/chess/position.rs#L745-L756