Mauritz8 / Vividmind

A UCI-compatible chess engine written from scratch in C++
0 stars 0 forks source link

Store threatened squares in board state #62

Closed Mauritz8 closed 10 months ago

Mauritz8 commented 11 months ago

The threatened squares of each piece should be stored in the game state. Then they should be updated as the game goes on, instead of recalculating all of them after every move. After a move has been played the only pieces that needs to update their threatened squares, are those that threatens either the start- or the end-square of the move. This will greatly increase performance.

Mauritz8 commented 11 months ago

This is how long the move generation tests take currently, just for reference image

Mauritz8 commented 10 months ago

While working on this, I've come to the realization that this is only viable to implement if it's represented using bitboards. Storing everything in vectors/sets or maps is very slow, mainly because copying the entire game state to the history becomes a very slow operation. Recalculating all the legal moves after every move is actually much more performant.