zxul767 / pawn

A chess engine and machine learning testbed
4 stars 2 forks source link

Optimize moves generation for Bishop #27

Open zxul767 opened 2 years ago

zxul767 commented 2 years ago

I recently discovered and read the source code for python-chess and found that they have quite an efficient (and clever) implementation for legal moves of a bishop (and other sliding pieces, like rooks and queens).

See this link for details (in particular, the implementation of the _attack_table function)

zxul767 commented 2 years ago

It is not clear how much this particular optimization would accelerate the search overall (we'd need to profile this a bit since maybe a major bottleneck is currently elsewhere--e.g., in position evaluation), but given that there's a reference implementation which is not too convoluted, it may be worth trying (though it would be important to measure performance before and after the change)