What would be the most direct way to influence SF pruning?

Discussion of chess software programming and technical issues.

Moderators: hgm, Dann Corbit, Harvey Williamson

User avatar
Ozymandias
Posts: 1529
Joined: Sun Oct 25, 2009 2:30 am

What would be the most direct way to influence SF pruning?

Post by Ozymandias »

In absence of an UCI parameter, where in the code, should I look for the most relevant section? From what I can understand, it's disseminated throughout the search.cpp file. Of all those bits and pieces, which one has a larger impact on whether SF prunes more or less?
User avatar
Eelco de Groot
Posts: 4557
Joined: Sun Mar 12, 2006 2:40 am
Full name:   

Re: What would be the most direct way to influence SF prunin

Post by Eelco de Groot »

Hello,

I think this is difficult to answer becayse as you say there are so many sections all influencing the width of the search in some way. Can you say a bit more about what you want to do, make Stockfish prune more, or less or just in specific types of positions or a version that prunes similarly to a less selective program etc.
The sections are reasonably modular and most have simple comments about what they do, so you could just alter a few things and see if the effect is what you expected. You would learn more by doing I think. Disabling nullmove probably would have always the largest effect, in most positions, and is easy to achieve.

Been away from the forum for a while, maybe I will have to skip it again for a week or so. No idea what has been happening in the world really, reading no newspapers etc. :) A bit like Robinson Crusoe but he never had Internet and most things did not happen quite as quickly in those days.

Regards, Eelco
Debugging is twice as hard as writing the code in the first
place. Therefore, if you write the code as cleverly as possible, you
are, by definition, not smart enough to debug it.
-- Brian W. Kernighan
User avatar
Ozymandias
Posts: 1529
Joined: Sun Oct 25, 2009 2:30 am

Re: What would be the most direct way to influence SF prunin

Post by Ozymandias »

I'd like it to prune less, in general.
Disabling a portion of the code probably isn't what I want. More like modifying some value, so I can tweak it, until it prunes as much as I'd like.
kbhearn
Posts: 411
Joined: Thu Dec 30, 2010 4:48 am

Re: What would be the most direct way to influence SF prunin

Post by kbhearn »

tweaking the values for LMR is probably what you want for something that will just generally make the tree wider/narrower. There's probably a fairly wide range of values with not much strength difference so you'll probably be making the engine weaker but not by much.
User avatar
Ozymandias
Posts: 1529
Joined: Sun Oct 25, 2009 2:30 am

Re: What would be the most direct way to influence SF prunin

Post by Ozymandias »

Would this be a good place to start?:

Code: Select all

      if (    depth >= 3 * ONE_PLY
          &&  moveCount > 1
          && !captureOrPromotion)
(Lines 1009 to 1011 from the last search.cpp)
User avatar
Eelco de Groot
Posts: 4557
Joined: Sun Mar 12, 2006 2:40 am
Full name:   

Re: What would be the most direct way to influence SF prunin

Post by Eelco de Groot »

I think that is what Kevin was suggesting, but to clarify then you would want to make the reduction less, which is a few lines further line 1013

Code: Select all

          Depth r = reduction<PvNode>&#40;improving, depth, moveCount&#41;;
and the formula for the reduction you find earlier, line 75 for the template and then the calculation of r in line 188

Code: Select all

double r = log&#40;d&#41; * log&#40;mc&#41; / 2;
making r smaller will decrease the selectivity in general, but r is further modified line 195 by looking if the evaluation function is equal or increasing compared to the next previous ply, the first ply upwards that had the same side to move.

Code: Select all

     // Increase reduction for non-PV nodes when eval is not improving
              if (!imp && Reductions&#91;!PV&#93;&#91;imp&#93;&#91;d&#93;&#91;mc&#93; >= 2 * ONE_PLY&#41;
                Reductions&#91;!PV&#93;&#91;imp&#93;&#91;d&#93;&#91;mc&#93; += ONE_PLY;
This reduction you could of course also modify.
Debugging is twice as hard as writing the code in the first
place. Therefore, if you write the code as cleverly as possible, you
are, by definition, not smart enough to debug it.
-- Brian W. Kernighan
User avatar
Ozymandias
Posts: 1529
Joined: Sun Oct 25, 2009 2:30 am

Re: What would be the most direct way to influence SF prunin

Post by Ozymandias »

Ok, thanks, I'll try that. This should be fun.