I'm looking for advices on how to fix and improve my engine.
I think there is something wrong in Cheese, I don't understand if the problem is only the weak evaluation fonction or if there are bugs in other parts of the code.
What should I do to find the origin of the problem ?
If you want to look at the code, it's available here :
https://gitlab.com/cheesechess/cheese
Bug hunting
Moderator: Ras
-
- Posts: 194
- Joined: Sat May 25, 2013 11:17 am
- Location: France
- Full name: Patrice Duhamel
Bug hunting
Anything that can go wrong will go wrong.
-
- Posts: 48
- Joined: Wed Sep 22, 2021 9:20 pm
- Full name: Jeremy Wright
Re: Bug hunting
The first place to start is probably: What are the things you consider to be problems with Cheese? What's giving you the impression there's something wrong?
That will help guide the rest of the debugging process.
That will help guide the rest of the debugging process.
Mantissa: https://github.com/jtheardw/mantissa
-
- Posts: 608
- Joined: Sun May 30, 2021 5:03 am
- Location: United States
- Full name: Christian Dean
Re: Bug hunting
Why do you think that exactly? That would be where to start.Patrice Duhamel wrote: ↑Sun Jan 09, 2022 11:57 am ...
I think there is something wrong in Cheese...
...
-
- Posts: 440
- Joined: Thu Apr 26, 2012 1:51 am
- Location: Oak Park, IL, USA
- Full name: Erik Madsen
Re: Bug hunting
This reminds me of pilot / maintenance humor on the “gripe sheet.”
Pilot: Something loose in cockpit.
Maintenance: Something tightened in cockpit.
Pilot: Something loose in cockpit.
Maintenance: Something tightened in cockpit.
Erik Madsen | My C# chess engine: https://www.madchess.net
-
- Posts: 2696
- Joined: Tue Aug 30, 2016 8:19 pm
- Full name: Rasmus Althoff
Re: Bug hunting
I recommend static code analysis. It seems your build chain is already using compiler warning, that's a good starter. However, CppCheck (free and open source tool) shows a lot of findings. Most of them are likely false positives, but e.g. the redundant if-conditions seem real and may mean that the code doesn't do what you intended. CppCheck is super easy to use. Make sure to show all sorts of findings in the GUI.Patrice Duhamel wrote: ↑Sun Jan 09, 2022 11:57 amWhat should I do to find the origin of the problem ?
The next step can be using Coverity Scan (https://scan.coverity.com) which is free for open source projects, but takes more work to get up and running. However, it provides deeper analysis also across functions.
Rasmus Althoff
https://www.ct800.net
https://www.ct800.net
-
- Posts: 219
- Joined: Fri Apr 11, 2014 10:45 am
- Full name: Fabio Gobbato
Re: Bug hunting
You can add in your code a lot of assert to find if something is not how you expect or compile the engine with sanitizers on to find some undefined behavior or memory problems. For memory problems is good also valgrind.
-
- Posts: 7251
- Joined: Mon May 27, 2013 10:31 am
Re: Bug hunting
Always the same procedure. Go back to a state where it worked. Then add back one feature at a time and test.
So just use simplification.
So just use simplification.
-
- Posts: 467
- Joined: Fri Dec 16, 2016 11:04 am
- Location: France
- Full name: Richard Delorme
Re: Bug hunting
I do not think an engine ranked over 2800 on CCRL is very buggy.
I sent you a merge request for a possible bug, probably with zero impact on the strength of your program though.
You are using YBWC for parallel search. Maybe replacing it with lazy SMP can make your code both simpler and more efficient, and maybe not
I will try to scrutinize your code more thoroughly but I do not expect to find many bugs or possible enhancements.
I sent you a merge request for a possible bug, probably with zero impact on the strength of your program though.
You are using YBWC for parallel search. Maybe replacing it with lazy SMP can make your code both simpler and more efficient, and maybe not

I will try to scrutinize your code more thoroughly but I do not expect to find many bugs or possible enhancements.
Richard Delorme
-
- Posts: 194
- Joined: Sat May 25, 2013 11:17 am
- Location: France
- Full name: Patrice Duhamel
Re: Bug hunting
Yes, I should give more details :
I found moves played during games that I can't reproduce when analyzing the position, and if it's not always blunders some moves are difficult to understand.
Cheese evaluation function is not great, but I was not able to improve eval parameters with Texel's tuning method or other methods, and trying to change parameters at hand is hard.
Now maybe I'm also doing something wrong when running games to test changes in my code, because my results are different compared to CCRL or CEGT.
I'm using clang-tidy, and there are few details to look at, but nothing important.
I also have some unit tests, and perft results are good.
I already tried clang address sanitizer, but I don't know how to use memory sanitizer, I had error with the C++ standard library.
Merci, I think you are right but it will not change the result, I will look at this.abulmo2 wrote: ↑Mon Jan 10, 2022 4:34 pm I sent you a merge request for a possible bug, probably with zero impact on the strength of your program though.
You are using YBWC for parallel search. Maybe replacing it with lazy SMP can make your code both simpler and more efficient, and maybe not
I will try to scrutinize your code more thoroughly but I do not expect to find many bugs or possible enhancements.
I have both, YBWC by default and optional Lazy SMP, but I'm not sure Lazy SMP works as expected I was only able to test with 4 threads.
Anything that can go wrong will go wrong.
-
- Posts: 48
- Joined: Wed Sep 22, 2021 9:20 pm
- Full name: Jeremy Wright
Re: Bug hunting
To me top possibility here is transposition table. I sometimes find Mantissa plays a move differently in a game than it would if I just started from the position cold (even single threaded), and this is usually due to the TT. Other things that can contribute here is threefold. An FEN string doesn't have history. I've found that occasionally there are positions that would be played/scored differently if the position were set up via `position fen ...` vs. `position startpos moves ...`. So another control could be to load in all previous moves from the pgn if you're trying to replicate a situation from a game. Thirdly, searches with lots of reductions/etc. get pretty unstable, as very small changes to the state can result in different outcomes, even if under *identical* conditions the results will be deterministic. Even using a different set of zobrist keys can cause different behaviors. Or if history tables age instead of clearing, etc. etc. IIRC Cheese plays at a pretty high level and so probably does have a lot of selectivity in its search.Patrice Duhamel wrote: ↑Mon Jan 10, 2022 6:21 pm
I found moves played during games that I can't reproduce when analyzing the position, and if it's not always blunders some moves are difficult to understand.
It's possible the inconsistency is caused by a bug but it could be something benign like the above as well. If you're trying to figure out the specific cause you should try to control for as many of these features in your experiments as you can.
Mantissa: https://github.com/jtheardw/mantissa