kirillbobyrev / pabi

🤖 [WIP] Monte-Carlo Tree Search chess engine
https://kirillbobyrev.github.io/pabi/docs/pabi/
GNU General Public License v3.0
13 stars 1 forks source link

Refactor and improve `AttackInfo` handling #242

Open kirillbobyrev opened 3 months ago

kirillbobyrev commented 3 months ago

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

  1. Move generation
  2. 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:

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