sandermvdb / chess22k

Chessengine written in Java
GNU General Public License v3.0
31 stars 8 forks source link

Some issues in the C# port #11

Closed respel closed 4 years ago

respel commented 4 years ago

Hey, it's me again.

So, I was running the port with EngineConstants.Assert = true and was getting an error in ChessBoardTestUtil.TestValues().

I'm not really sure what's going wrong. To me, it looks like the only possible source of modification is the UCI "startpos" command. However, I'm not sure why the error is not there in the single-threaded version and also absent from the Java version.

Since the C# one is essentially a line-by-line rewrite of the Java version, I was hoping you'd have some idea as to what could be the cause of the error.

sandermvdb commented 4 years ago

If I understood you correctly, the error only occurs when multiple threads are being used? Is it reproducable in a way that it always crashes in exactly the same way? The ChessBoardTestUtil class verifies some iteratively calculated values with the complete recalculated values. Which value is different? After which method is being called (doMove, undoMove, ..)? You could maybe disable the evaluation caches to check if these caches are causing the issue.

respel commented 4 years ago

@sandermvdb Thanks for the comments

If I understood you correctly, the error only occurs when multiple threads are being used?

Yes, it only occurs during the usage of multiple threads.

Is it reproducable in a way that it always crashes in exactly the same way?

Yes, if I use 8 threads, then it will fail in the function TestValues in the first couple of moves. Though the exact move number at which it fails is not fixed.

Which value is different? After which method is being called (doMove, undoMove, ..)?

The value it fails on is not fixed. I have seen it fail on different values during the sample runs. The method is doMove and it is always failing in the helper thread, not the main one.

You could maybe disable the evaluation caches to check if these caches are causing the issue.

I just tried it and it doesn't seem to be the issue

respel commented 4 years ago

@sandermvdb I figured it out finally. The issue was I was starting the main thread before waiting for the chessboard to copied to the helper threads. Rubber duck debugging ftw!

respel commented 4 years ago

Just to give you the news, I have published the port at https://github.com/respel/Chess22kDotNet