Page 1 of 4

Re: fast(er) movegen

Posted: Mon Dec 10, 2018 5:01 pm
by alessandro
AdaChess uses a 10x12 array for the board design plus and a pieces-list to quickly find where the pieces are located.

The most expensive task while generating moves is the test for validity: not leaving the king in check. Therefore, engines tends to either don't test it (and leave the search to skip those nodes) or perform the legality check only when strictly required. AdaChess uses this second approach, by considering absolute pinned pieces movement, king escapes and so on.

Those are the best number on my Surface Pro after some tries. No hash used, and 1 core.

Code: Select all

Depth     Nodes      Captures    En-Passant       Castles    Promotions        Checks    Checkmates   Time
1            20             0             0             0             0             0             0   0.00
2           400             0             0             0             0             0             0   0.00
3          8902            34             0             0             0            12             0   0.00
4        197281          1576             0             0             0           469             8   0.02
5       4865609         82719           258             0             0         27351           347   0.47
6     119060324       2812008          5248             0             0        809099         10828  11.50
AdaChess, however, performs a search to detect the kind of check (if a move checks the opponent king), that makes the generation a bit more heavy than necessary.
In the italian forum, by talking about perft with other italian programmers, we agreed that once the move generator is optimized to reduce the legality test on the minimum, then there's no reason to spend more time to optimize it further (due to the limited amount of time that the engine spend in generating moves).

I believe that the optimization of the move generator became significant only once the engine reaches 3000+ Elo or when every small improvements matters.

Re: fast(er) movegen

Posted: Mon Dec 10, 2018 7:35 pm
by hgm
xr_a_y wrote: Mon Dec 10, 2018 4:50 pm qperft is optimized a lot, this is not a move generator to use in engine I think.
It was used in Joker.

Re: fast(er) movegen

Posted: Mon Dec 10, 2018 8:21 pm
by xr_a_y
sorry, didn't know.

Re: fast(er) movegen

Posted: Mon Dec 10, 2018 8:58 pm
by Ratosh
HGM's move generation on qperft is a good reference for speed. If you want to change your board representation there is no doubt that bitboard representation is the fastest.

Re: fast(er) movegen

Posted: Mon Dec 10, 2018 9:01 pm
by hgm
Ratosh wrote: Mon Dec 10, 2018 8:58 pm HGM's move generation on qperft is a good reference for speed. If you want to change your board representation there is no doubt that bitboard representation is the fastest.
Actually I doubt that.

Re: fast(er) movegen

Posted: Mon Dec 10, 2018 9:20 pm
by Dann Corbit
hgm wrote: Mon Dec 10, 2018 9:01 pm
Ratosh wrote: Mon Dec 10, 2018 8:58 pm HGM's move generation on qperft is a good reference for speed. If you want to change your board representation there is no doubt that bitboard representation is the fastest.
Actually I doubt that.
The fastest is using GPUs.
Ankan's GPU perft is absurdly faster than anything else.

Re: fast(er) movegen

Posted: Mon Dec 10, 2018 10:50 pm
by Ratosh
Oh, i assumed it since most top engines use bitboard. What would be the reason why they would chose it over other options?

Re: fast(er) movegen

Posted: Mon Dec 10, 2018 11:09 pm
by Michael Sherwin
For people that have no idea how to program a GPU, like me, I did some CPU perft examples about 15 years ago.

On my computer, an i7-3930k, running at 3.2 GHz single threaded I get the following results.

Stockfish 10 bench 6 1,697,099 nodes/sec

My Examples: Every move made and unmade and no move counts cashed.

Carnivor: GNU 4 style move generator - enhanced
36,649,859 nodes/sec

Halfwit: Classic Chess 4.5 style bitboards - enhanced
25,930,980 nodes/sec

Conundrum: Move generation as a state machine (I think or maybe just incremental) 100% original
38,679,036 nodes/sec

Godzilla: A purely jump table driven move generator in x86 32 bit assembly 100% original with a top level C main() module
66,799,849 nodes/sec

NOTE: These examples are just for speed and not accuracy as they just count pseudo legal moves.

My processor i7-3930k CPU MARK 1935 an i9-9900k CPU MARK 2898

Source code for the examples is available on request.

Re: fast(er) movegen

Posted: Mon Dec 10, 2018 11:16 pm
by gbtami
It would be very kind if you can put these sources to a github repo.

Re: fast(er) movegen

Posted: Mon Dec 10, 2018 11:22 pm
by Michael Sherwin
gbtami wrote: Mon Dec 10, 2018 11:16 pm It would be very kind if you can put these sources to a github repo.
I'll see if I can figure out how to do that. But, I'm an old dog and it's not easy for me to learn new tricks, wuf wuf. :?