deanmchris / blunder

A UCI compatible chess engine written in Golang
MIT License
246 stars 15 forks source link

Different search results on the same position after a ucinewgame command #22

Open kurt1288 opened 2 years ago

kurt1288 commented 2 years ago

I've been using your engine a bunch to compare the output to what mine is doing. In testing a particular endgame position, I noticed an the search was giving the same results after a ucinewgame command.

This position: 8/4k3/B7/4K2R/8/8/8/8 w - - 0 1

Run command "ucinewgame" followed by "position fen 8/4k3/B7/4K2R/8/8/8/8 w - - 0 1" then "go depth 12". At the end of the search, depth 12 has search 333340 nodes and found a mate-in-5. Then, repeat all the previous commands (ucinewgame, position, go). The output is now different: depth 12 has only searched 235775 nodes and only found a mate-in-7.

The outputs should be the same after a ucinewgame command.

deanmchris commented 2 years ago

Having a different result isn't necessarily a bug, as the Zobrist hashing values can be initialized to new random number when ucinewgame is called, resulting in a different result.

However in this case it is odd as I remember I don't change the seed value for my pseduo-random number generator, so the Zobrist hash should stay the same. I'll need to look into why this is happening given that should be the case. Thanks!