I just had a wrong implementation of the TT initially, now it's working. Interestingly, when used with threads in the faster version of my engine, it is only a little bit faster than in my future chess engine version (with a move array that can be sorted). The chess engine version doesn't abuse templates as much, so the binary and compile time are much smaller. I guess it has less TT hits, but I will verify the numbers.hgm wrote: ↑Sat Sep 20, 2025 9:40 pm You check whether the position reached by a move has already been searched. But you don't do that only in the leaf nodes. (Where in perft it would indeed be pretty useless, as you just want to count those, not process them in any other way that you could save time on.) You do it in every node in the tree. And that is also very useful in perft. The position after, say, 1. e3 d5 2. d4 is the same as that after 1. d4 e5 2. e3, and when calculating perft(7) you don't want to do the perft(4) from that position twice.
Engines store moves in a list, because they typically want to search them in a different order than they were generated. Unlike perft, the size of an alpha-beta tree is highly dependent on the move ordering. A factor 2 in speed that you might gain by skipping the sorting can easily mean you have to sort a thousand times larger tree.
Code: Select all
Depth: 9
Nodes: 2439530234167
Time: 33500 ms
Average: 72821.3 Mn/s
Code: Select all
Depth: 9
Nodes: 2439530234167
Time: 34910 ms
Average: 69879.3 Mn/s

Code: Select all
Depth: 9
Nodes: 2439530234167
Time: 17239 ms
Average: 141512 Mn/s