Side to Move Bonus---does it help?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

mjlef
Posts: 1494
Joined: Thu Mar 30, 2006 2:08 pm

Re: Side to Move Bonus---does it help?

Post by mjlef »

bob wrote:
mjlef wrote:Has anyone done testing on the Side to Move bonus, and if so, how much does it help (if anything)? It would seem simple enough to test some public source programs with and without the bonus to see if it helps. Mayve Bob can use his amazing cluster to see the effect...it might be small and require a lot of games.
It is _very_ small. I have one in Crafty. +5 for side on move in middlegame, +8 in the endgame. Worth a couple of Elo. And we spent a good bit of time testing different values to reach those as optimal [for crafty of course, YMMV].
Thanks.

I wonder if a different STM bonus for very small material makes sense. Something else to test...
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Side to Move Bonus---does it help?

Post by bob »

mjlef wrote:
bob wrote:
mjlef wrote:Has anyone done testing on the Side to Move bonus, and if so, how much does it help (if anything)? It would seem simple enough to test some public source programs with and without the bonus to see if it helps. Mayve Bob can use his amazing cluster to see the effect...it might be small and require a lot of games.
It is _very_ small. I have one in Crafty. +5 for side on move in middlegame, +8 in the endgame. Worth a couple of Elo. And we spent a good bit of time testing different values to reach those as optimal [for crafty of course, YMMV].
Thanks.

I wonder if a different STM bonus for very small material makes sense. Something else to test...
we use 5 for middlegame, 8 for endgame, interpolate (ala fruit) between the two scores depending on material.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Side to Move Bonus---does it help?

Post by bob »

Ryan Benitez wrote:
bob wrote:
Jan Brouwer wrote:
mjlef wrote:Has anyone done testing on the Side to Move bonus, and if so, how much does it help (if anything)? It would seem simple enough to test some public source programs with and without the bonus to see if it helps. Mayve Bob can use his amazing cluster to see the effect...it might be small and require a lot of games.
Rotor uses a bonus of 5 cp, this was roughly the optimum when minimizing tree search sizes for the LCT II set of positions.
Not sure how minimizing search space infers anything at all about an optimal value for any scoring term...
Fewer nodes searched the less time taken. One would hope that is best solution sooner.
However this has _nothing_ to do with the evaluation numbers. Often a good evaluation term makes the tree significantly larger...
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Side to Move Bonus---does it help?

Post by bob »

Jan Brouwer wrote:
bob wrote:
Jan Brouwer wrote:
mjlef wrote:Has anyone done testing on the Side to Move bonus, and if so, how much does it help (if anything)? It would seem simple enough to test some public source programs with and without the bonus to see if it helps. Mayve Bob can use his amazing cluster to see the effect...it might be small and require a lot of games.
Rotor uses a bonus of 5 cp, this was roughly the optimum when minimizing tree search sizes for the LCT II set of positions.
Not sure how minimizing search space infers anything at all about an optimal value for any scoring term...
It is a bit indirect, smaller search trees imply stronger play.
I see this bonus more as a smoothing factor, to make the score of a PV less dependent from whether the PV length is odd or even.
Here's what's wrong with the idea. If you infer that smaller trees are better, get rid of all extensions. And any eval term that produces really large positional score bonuses. The tree size will go down. In fact, if you get rid of your evaluation completely, you will search really compact trees. And for tactical positions, this will do better in terms of faster solutions and smaller trees, but the program won't exactly play very well...

I have seen literally hundreds of cases where an eval change makes the tree larger, about as many as I have seen where an eval change makes the tree smaller. I don't think this is a good way to choose eval parameters. At least IMHO.

Tree search space is a function of several variables. If your eval change can somehow eliminate some searching, you might get good results for tuning a value. But many terms do not make the tree smaller, but do make the program stronger.
User avatar
Zach Wegner
Posts: 1922
Joined: Thu Mar 09, 2006 12:51 am
Location: Earth

Re: Side to Move Bonus---does it help?

Post by Zach Wegner »

Obviously tree size doesn't work for every eval parameter, otherwise we'd all be just returning 0 for eval.

I think it is valid for the STM bonus though. You can never permanently lose the STM, you just don't have it for one move. The only difference it can really make is differentiating which side to move the path ended on.

Of course, this doesn't hold for more complicated STM bonuses based on available moves or anything like that, or even for one based on the game stage. I think the game-stage case is close enough though that a difference based on tree size would be a useful measurement.
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: Side to Move Bonus---does it help?

Post by sje »

I've used a side-to-move bonus of 1/10th pawn with good effect. On average, it does tend to reduce the time-to-depth metric by reducing the number of flip-flops between two nearly equal valued predicted variations.

The value should probably be higher in the very early opening and lower in the late middlegame.
Osipov Jury
Posts: 186
Joined: Mon Jan 21, 2008 2:07 pm
Location: Russia

Re: Side to Move Bonus---does it help?

Post by Osipov Jury »

Perhaps the best realization of this issue (from one very strong engine):

stage = majors * 2 + minors;
phase = ((double)stage) / 24.0;
SideToMoveBonus = (int)((1.0 - phase) * 0.0 + phase * 9.0);
Dann Corbit
Posts: 12540
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Side to Move Bonus---does it help?

Post by Dann Corbit »

Osipov Jury wrote:Perhaps the best realization of this issue (from one very strong engine):

stage = majors * 2 + minors;
phase = ((double)stage) / 24.0;
SideToMoveBonus = (int)((1.0 - phase) * 0.0 + phase * 9.0);
seems to me that this part:
(int)((1.0 - phase) * 0.0
is always going to equal zero. So why bother with that part of the calculation?
User avatar
Eelco de Groot
Posts: 4565
Joined: Sun Mar 12, 2006 2:40 am
Full name:   

Re: Side to Move Bonus---does it help?

Post by Eelco de Groot »

Osipov Jury wrote:Perhaps the best realization of this issue (from one very strong engine):

stage = majors * 2 + minors;
phase = ((double)stage) / 24.0;
SideToMoveBonus = (int)((1.0 - phase) * 0.0 + phase * 9.0);
I leave it to the moderators if this can be discussed.

My attempt at a contribution:

♦ First, if this is from Rybka, apparently if I read this code right, for Rybka the SideToMoveBonus goes down towards the endgame, not up. In Crafty it is the opposite?

♦ Second, it is strange to see such a coarse resolution of phase in Rybka. Maybe this is only done for the SideToMoveBonus? I don't see why Vas would have to do that, unless it is done to smoothen the bonus over the phase of the game and this is somehow important. But at an exchange of pieces you have a major discontinuity anyhow, there is nothing you can do about it, I don't see a jump in the side to move bonus is going to make that any worse and why you would not use a more detailed calculation of phase.

♦ Mr. Rajlich, once more you seem to be underestimating the potential material value of the Bishop Pair. Of course this is never going to work :) Now I know that for Rybka that involves at least three additions, the dark-squared bishop, the light squared bishop and the bishop pair material values but this is critical stuff Mr. Rajlich :)

In Ancalagon I don't have different material values for the dark squared bishop and the light squared bishop, but I have tried to include the value of the Bishop Pair in Tord's calculation of the game phase. It is not perfect because there can be potential conflicts in other places where it is assumed the phase only calculates the midgame material values. But so far I did not spot a major conflict in the rest of Glaurung's code or that of Stockfish when I do this. I don't think Glaurung or Stockfish scale their SideToMoveBonus yet.

This is new Ancalagon code with 'minor' changes from Glaurung:

Code: Select all

/// Position::compute_non_pawn_material() computes the total non-pawn middle
/// game material score for the given side. Material scores are updated
/// incrementally during the search, this function is only used while
/// initializing a new Position object.

Value Position::compute_non_pawn_material(Color c) const {

  Value result = Value(0);

  for &#40;PieceType pt = KNIGHT; pt <= QUEEN; pt++)
  &#123;
      Bitboard b = pieces_of_color_and_type&#40;c, pt&#41;;
      int Bishopcount = 0;
      while &#40;b&#41;
      &#123;
          assert&#40;piece_on&#40;first_1&#40;b&#41;) == piece_of_color_and_type&#40;c, pt&#41;);
          pop_1st_bit&#40;&b&#41;;
          result += piece_value_midgame&#40;pt&#41;;
          if &#40;pt == BISHOP&#41; Bishopcount++;
      &#125;
      if &#40;Bishopcount >= 2&#41; result += Value&#40;100&#41;;
  &#125;
  return result;
&#125;
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
Osipov Jury
Posts: 186
Joined: Mon Jan 21, 2008 2:07 pm
Location: Russia

Re: Side to Move Bonus---does it help?

Post by Osipov Jury »

Dann Corbit wrote:seems to me that this part:
(int)((1.0 - phase) * 0.0
is always going to equal zero. So why bother with that part of the calculation?
I think that this for one purpose: you can change STM_Endgame from 0.0 to another value.