KYLChiu / sporkfish

Chess engine in Python
MIT License
5 stars 0 forks source link

[SPORK-70] Incremental Zobrist hash and use transposition table in Quiescence search #110

Closed KYLChiu closed 5 months ago

KYLChiu commented 7 months ago

This leads the performance of transposition table to be fairly equal/slightly better to base case:

FEN: 8/8/8/8/5R2/2pk4/5K2/8 b - - 0 1 (depth 6) Base, 20302099 function calls (20229039 primitive calls) in 6.205 seconds Transposition table, 11647835 function calls (11604146 primitive calls) in 4.043 seconds

FEN: r1b2rk1/ppqn1pbp/6p1/3pp3/7B/2PB1N2/PP3PPP/R2QR1K1 w - - 0 16 (depth 6) Base, 48916378 function calls (48808919 primitive calls) in 17.582 seconds TT, 44415536 function calls (44317989 primitive calls) in 17.193 seconds

However at higher depths: FEN: r1b2rk1/ppq2ppp/3bpn2/3pP3/8/2PB2B1/PP1N1PPP/R2QK2R b KQ - 0 11 (depth 7): Base, 361472569 function calls (360480492 primitive calls) in 130.606 seconds TT, 372255883 function calls (371297000 primitive calls) in 141.766 seconds

I am not quite happy with it yet, but would like this to go in as this is a vast improvement over full hash computation. Will explore avenues of improvement of TT and optimizing the hash calculation in next PR.

ccjeremylo commented 7 months ago
  • Implements incremental Zobrist hash as opposed to computing the hash via full information.
  • Added transposition table usage in Quiescence search.
  • Cleanup runner
  • Fix docstrings of runner and transposition table.

This leads the performance of transposition table to be fairly equal/slightly better to base case:

FEN: 8/8/8/8/5R2/2pk4/5K2/8 b - - 0 1 (depth 6) Base, 20302099 function calls (20229039 primitive calls) in 6.205 seconds Transposition table, 11647835 function calls (11604146 primitive calls) in 4.043 seconds

FEN: r1b2rk1/ppqn1pbp/6p1/3pp3/7B/2PB1N2/PP3PPP/R2QR1K1 w - - 0 16 (depth 6) Base, 48916378 function calls (48808919 primitive calls) in 17.582 seconds TT, 44415536 function calls (44317989 primitive calls) in 17.193 seconds

However at higher depths: FEN: r1b2rk1/ppq2ppp/3bpn2/3pP3/8/2PB2B1/PP1N1PPP/R2QK2R b KQ - 0 11 (depth 7): Base, 361472569 function calls (360480492 primitive calls) in 130.606 seconds TT, 372255883 function calls (371297000 primitive calls) in 141.766 seconds

I am not quite happy with it yet, but would like this to go in as this is a vast improvement over full hash computation. Will explore avenues of improvement of TT and optimizing the hash calculation in next PR.

I believe TT is switched on by default right?

KYLChiu commented 7 months ago
  • Implements incremental Zobrist hash as opposed to computing the hash via full information.

  • Added transposition table usage in Quiescence search.

  • Cleanup runner

  • Fix docstrings of runner and transposition table.

This leads the performance of transposition table to be fairly equal/slightly better to base case:

FEN: 8/8/8/8/5R2/2pk4/5K2/8 b - - 0 1 (depth 6) Base, 20302099 function calls (20229039 primitive calls) in 6.205 seconds Transposition table, 11647835 function calls (11604146 primitive calls) in 4.043 seconds

FEN: r1b2rk1/ppqn1pbp/6p1/3pp3/7B/2PB1N2/PP3PPP/R2QR1K1 w - - 0 16 (depth 6) Base, 48916378 function calls (48808919 primitive calls) in 17.582 seconds TT, 44415536 function calls (44317989 primitive calls) in 17.193 seconds

However at higher depths: FEN: r1b2rk1/ppq2ppp/3bpn2/3pP3/8/2PB2B1/PP1N1PPP/R2QK2R b KQ - 0 11 (depth 7): Base, 361472569 function calls (360480492 primitive calls) in 130.606 seconds TT, 372255883 function calls (371297000 primitive calls) in 141.766 seconds

I am not quite happy with it yet, but would like this to go in as this is a vast improvement over full hash computation. Will explore avenues of improvement of TT and optimizing the hash calculation in next PR.

I believe TT is switched on by default right?

Off by default, the performance stats don't justify it yet