stand pat or side to move bonus

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
rvida
Posts: 481
Joined: Thu Apr 16, 2009 12:00 pm
Location: Slovakia, EU

Re: stand pat or side to move bonus

Post by rvida »

lkaufman wrote:
rvida wrote:
lkaufman wrote:
rvida wrote:
lkaufman wrote: So the question can be re-phrased, do you believe that the decision to stand pat in quies should be based on a different score than is used for various pruning decisions in the main search? Using methods (B) or (C) would imply this. If so, why?
You use the same score everywhere with both methods (A) and (B), you just have to adjust margins. If you include tempo bonus in evaluate(), all your margins (used for 'various' pruning decisions in the main search) are offset by that value.
I notice that Critter evaluates symmetrical positions near the opening as +.05. If you don't give a bonus in evaluate but only use the bonus for stand pat decisions, what accounts for the displayed .05 score? Is it purely something added for display purposes only?
Please give a specific example. Without knowing the position I can only say that most probably it is exactly because of the reason you stated. (Tempo bonus is added to the stand pat score).
I tried symmetrical openings like c4 c5 or d4 d5 Nf3 Nf6 or f4 f5 Nf3 Nf6 on 2 and 3 ply searches. Since you include positional moves in quiesce it's not so simple to get a symmetric pv, but whenever the displayed pv resulted in a symmetrical position, the score was always .05. Now unless you've changed things since you sent me code, your stand pat offset in the qsearch was 26 points out of 256, which is 0.10. It is of course quite logical that the displayed score should be half of the value of a full tempo, but what causes this to happen? What code results in all symmetric positions on a full board showing as +.05?
Mystery solved. You are probably looking at the wrong piece of code. Tempo is defined in eval.h as 13 points out of 256, which is 0.05 :)

The constant 26 you are reffering to is in qevasions(), and is used as a margin for pruning quiet evasions. Not related to tempo nor standpat.
lkaufman
Posts: 5960
Joined: Sun Jan 10, 2010 6:15 am
Location: Maryland USA

Re: stand pat or side to move bonus

Post by lkaufman »

rvida wrote:
lkaufman wrote:
rvida wrote:
lkaufman wrote:
rvida wrote:
lkaufman wrote: So the question can be re-phrased, do you believe that the decision to stand pat in quies should be based on a different score than is used for various pruning decisions in the main search? Using methods (B) or (C) would imply this. If so, why?
You use the same score everywhere with both methods (A) and (B), you just have to adjust margins. If you include tempo bonus in evaluate(), all your margins (used for 'various' pruning decisions in the main search) are offset by that value.
I notice that Critter evaluates symmetrical positions near the opening as +.05. If you don't give a bonus in evaluate but only use the bonus for stand pat decisions, what accounts for the displayed .05 score? Is it purely something added for display purposes only?
Please give a specific example. Without knowing the position I can only say that most probably it is exactly because of the reason you stated. (Tempo bonus is added to the stand pat score).
I tried symmetrical openings like c4 c5 or d4 d5 Nf3 Nf6 or f4 f5 Nf3 Nf6 on 2 and 3 ply searches. Since you include positional moves in quiesce it's not so simple to get a symmetric pv, but whenever the displayed pv resulted in a symmetrical position, the score was always .05. Now unless you've changed things since you sent me code, your stand pat offset in the qsearch was 26 points out of 256, which is 0.10. It is of course quite logical that the displayed score should be half of the value of a full tempo, but what causes this to happen? What code results in all symmetric positions on a full board showing as +.05?
Mystery solved. You are probably looking at the wrong piece of code. Tempo is defined in eval.h as 13 points out of 256, which is 0.05 :)

The constant 26 you are reffering to is in qevasions(), and is used as a margin for pruning quiet evasions. Not related to tempo nor standpat.

OK, thanks. I thought you said you did not use the bonus in eval, but based on this I suppose you do, which means we are all doing the same thing after all, except that SF and Komodo don't use a constant, while Ivanhoe and Critter do. Perhaps I misunderstood you.
lkaufman
Posts: 5960
Joined: Sun Jan 10, 2010 6:15 am
Location: Maryland USA

Re: stand pat or side to move bonus

Post by lkaufman »

diep wrote:
lkaufman wrote:In at least 99% of chess positions, it's better to be on move than not. Therefore all strong programs take this into consideration when evaluating positions or making decisions. There appear to be three possibilities:

A. Simply give the side to move a bonus when doing an evaluation, which can either be a constant or may depend on something else.
B. When reaching quies, if you are below beta but within for example 10 centipawns of beta allow the cutoff.
C. Do both of the above.

What are the pros and cons of the three methods? We currently use method A, but I notice that some strong programs appear to use B or C. Are there any other possibilities in use for handling this issue?
D) Do not give the bonus at all
In Diep i'm not giving a bonus at all. Some 10+ years ago i tested many games with and without, and it didn't help at all, also to my surprise.

Sometimes it takes a year or 10 to understand something. Claim i heard that understanding the years 30 financial crisis took a year or 60.

In 90s there was many programs giving a bonus for having the side to move. Not surprisingly i also extensively experimented with it at different occasions.

In principle you can see having many chess patterns also as a temporarily pattern, as you can escape from this pattern or several patterns. Having the move you're allowed to maximize your position already, trying to get above alpha; not having the move you're not. So implicitly you already give a lot of bonus for having the move by means of how the search tree gets built up.

So whether such bonus for side to move works might depend upon how extensively a programs evaluation function is.

In fact i'm not even gonna experiment with a bonus for side to move anymore - it's been kicked out :)

Now if we assume a program has a decent evaluation function with more than just beancounter patterns, we can also reverse the question;
if in search we already struggle to get to a quiet position to evaluate, doesn't the side to move bonus basically contradict this strategy?

As it basically gives a bonus for having the side to move, you automatically create a random noise of the size of your bonus around the current quietness that might be there in the position;

So from that viewpoint a STM bonus doesn't work at all.

But now the lesson after 10 years:

Note that a STM bonus is a very weak form of a pattern.
If we have a white pawn on d2 and a white bishop on d3, we have a pattern and give a penalty for that.

To get the STM bonus you have a far weaker pattern which requires having the move as only condition. So it's at most a weak heuristic.

Vincent
First, I can tell you that there are few things more certain in computer chess than the fact that having some side to move or stand pat bonus helps the elo in both Rybka and Komodo. Of course this may not be true for your program.
It is also obvious that if the search is comparing two identical positions, one with itself to move and the other not, it should prefer the one with self to move 99% of the time. I can't see any argument against having SOME side to move bonus in a program. Of course it can easily be set too high.
Probably as I think Uri pointed out the key factor may be whether a program's eval includes tactical scoring of threats. Did (does) Diep penalize attacked pawns/pieces in the eval? If not then a smaller side to move bonus is probably appropriate.
The most interesting question on this topic is what factors should influence the size of the bonus. Currently SF, Rybka, and Komodo only consider game phase.
diep
Posts: 1822
Joined: Thu Mar 09, 2006 11:54 pm
Location: The Netherlands

Re: stand pat or side to move bonus

Post by diep »

lkaufman wrote:
diep wrote:
lkaufman wrote:In at least 99% of chess positions, it's better to be on move than not. Therefore all strong programs take this into consideration when evaluating positions or making decisions. There appear to be three possibilities:

A. Simply give the side to move a bonus when doing an evaluation, which can either be a constant or may depend on something else.
B. When reaching quies, if you are below beta but within for example 10 centipawns of beta allow the cutoff.
C. Do both of the above.

What are the pros and cons of the three methods? We currently use method A, but I notice that some strong programs appear to use B or C. Are there any other possibilities in use for handling this issue?
D) Do not give the bonus at all
In Diep i'm not giving a bonus at all. Some 10+ years ago i tested many games with and without, and it didn't help at all, also to my surprise.

Sometimes it takes a year or 10 to understand something. Claim i heard that understanding the years 30 financial crisis took a year or 60.

In 90s there was many programs giving a bonus for having the side to move. Not surprisingly i also extensively experimented with it at different occasions.

In principle you can see having many chess patterns also as a temporarily pattern, as you can escape from this pattern or several patterns. Having the move you're allowed to maximize your position already, trying to get above alpha; not having the move you're not. So implicitly you already give a lot of bonus for having the move by means of how the search tree gets built up.

So whether such bonus for side to move works might depend upon how extensively a programs evaluation function is.

In fact i'm not even gonna experiment with a bonus for side to move anymore - it's been kicked out :)

Now if we assume a program has a decent evaluation function with more than just beancounter patterns, we can also reverse the question;
if in search we already struggle to get to a quiet position to evaluate, doesn't the side to move bonus basically contradict this strategy?

As it basically gives a bonus for having the side to move, you automatically create a random noise of the size of your bonus around the current quietness that might be there in the position;

So from that viewpoint a STM bonus doesn't work at all.

But now the lesson after 10 years:

Note that a STM bonus is a very weak form of a pattern.
If we have a white pawn on d2 and a white bishop on d3, we have a pattern and give a penalty for that.

To get the STM bonus you have a far weaker pattern which requires having the move as only condition. So it's at most a weak heuristic.

Vincent
First, I can tell you that there are few things more certain in computer chess than the fact that having some side to move or stand pat bonus helps the elo in both Rybka and Komodo. Of course this may not be true for your program.
It is also obvious that if the search is comparing two identical positions, one with itself to move and the other not, it should prefer the one with self to move 99% of the time. I can't see any argument against having SOME side to move bonus in a program. Of course it can easily be set too high.
Probably as I think Uri pointed out the key factor may be whether a program's eval includes tactical scoring of threats. Did (does) Diep penalize attacked pawns/pieces in the eval? If not then a smaller side to move bonus is probably appropriate.
The most interesting question on this topic is what factors should influence the size of the bonus. Currently SF, Rybka, and Komodo only consider game phase.
The big difference in thinking is you consider 1 unique position and take a look at it. The chessprograms are first doing a 30 ply search line.

You still guess that after 30 plies there is a 0.1 pawn advantage to get?

Adding the bonus means there is a difference between your search getting 29 or 30 ply.

I'm aware some programs are using this bonus with succes; it wasn't different in the 90s.

Diep has worlds largest evaluation function chessknowledge wise. Considering attacks in patterns is something that trivially gets done a lot.

Not just the number of attacks or what sort of piece of attacks, also derived functions from it.

Basically anything you could come up with your entire life as a chessplayer as being 'chessknowledge', consider it being in Diep. Just strategy sometimes is really hard to make binary code for, yet i have experimented extensively there as well. *some* strategical factors are getting done inside diep's evaluation, yet majority of strategy isn't possible to put in patterns very well.

A good example is the minority attack after 1.d4,d5 2.c4,e6 3.cxd5 exd5 4. Nc3,Nf6 5.Bg5,Be7 6.e3

Now white has 2 plans. The classical plan is to go for the minority attack.

Many fruitless attempts have been done by me to get that to work.

Usually the positional factors then overrule the strategical factors; for example diep values the d3 bishop very high whereas blacks c8 bishop is a bad bishop. So diep doesn't want to exchange its d3 bishop for the c8 bishop.

Yet if black manages to develop its rooks to e8,f8 and then play its bishop back to c8, with white having its b2 pawn capture towards c5, then suddenly b7 is ideally covered. Only exchanging the bishop, or a very selden f3 knight transfer over d2 to b3 to a5, is gonna be helpful then.

So a minority attack is one of the big failures in my evaluations code.

Anything else i have. Diep has more types of bishops than any literature you have ever seen :)

On its way it seems one of my definitions also made it nowadays into the mainstream chess literature.

One bishop i defined is a positions bishop. That didn't exist prior to me calling it like that, somewhere mid 90s for Diep.

Chess literature is very limited here. Only a tad more modern literature is doing better there.

Usually titled players are very bad in factoring their knowledge into what really matters for this specific position.

For example well known is Capablanca's statement on that a queen+knight is stronger than a queen+bishop.

I challenge that - usually it's just the knight having a very strong spot, that takes care for this - or more important the huge preference of titled players to play with a bishop rather than a knight.

Actually i lost a game against an old player some weeks ago - where i took the bishop. With 1 small move i missed suddenly the bishop was weak and then i lost bigtime against a senior player.

Bishops are just tough to evaluate, that's why one of the automatic tunings features in Rybka had put knights at being default 0.6 pawns better than a bishop and in far endgame it still is 0.3 pawns better.

Of course on top of that comes the bonus for the position hwere the bishop andk night is located, which might change it.

Side to move is a much tougher to define pattern there, as it isn't a pattern. It's dependant upon the SEARCH.

So in itself it's not a chess technical pattern. It's in the grey area between search and giving a score. Strictly spoken it's a search bonus, not a positions bonus from my viewpoint seen.

As a result from that i find it a very weak heuristic, and it took me 10 years to realize that, meanwhile i had kicked it out after extensive experimentation and testing with it some 10-12 years ago. I had it retested somewhere start this century after initial games played by it by Jan Louwman at his 36 computers.

That was slow games.

Also back then nearly every line resulted in endgame and this search bonus gets applied at the end of a search line.

So it isn't getting applied at the root of a position without searching, it's intended as a correctional search bonus.

In 90s there was some programs it worked for and some where it didn't work for.

If you go play some slower time controls with some modern beancounter i'd be amazed if the bonus still works for todays huge search depths.

What i would like to know for those programs using it, is whether they on average search deeper when using this bonus.

Vincent
lkaufman
Posts: 5960
Joined: Sun Jan 10, 2010 6:15 am
Location: Maryland USA

Re: stand pat or side to move bonus

Post by lkaufman »

diep wrote: One bishop i defined is a positions bishop. That didn't exist prior to me calling it like that, somewhere mid 90s for Diep.


What is a "positions bishop"? I never heard the term.

For example well known is Capablanca's statement on that a queen+knight is stronger than a queen+bishop.

I challenge that - usually it's just the knight having a very strong spot, that takes care for this - or more important the huge preference of titled players to play with a bishop rather than a knight.

My research concluded that there is no statistical evidence for this Capablanca statement, so for once we agree.


Bishops are just tough to evaluate, that's why one of the automatic tunings features in Rybka had put knights at being default 0.6 pawns better than a bishop and in far endgame it still is 0.3 pawns better.

You must be talking about Rybka 1 or some version before I got involved; in all the versions I did (i.e. Rybka 3) the difference was much smaller than this, something like 0.1 pawn.

If you go play some slower time controls with some modern beancounter i'd be amazed if the bonus still works for todays huge search depths.

What i would like to know for those programs using it, is whether they on average search deeper when using this bonus.

Definitely so, as long as you don't go too high with the bonus. It amounts to cheating on taking stand-pat cutoffs, so it is to be expected that it would prune more and allow higher depths to be reached. As long as the values are not too high, there is no cost for this gain.

Vincent
Larry
lkaufman
Posts: 5960
Joined: Sun Jan 10, 2010 6:15 am
Location: Maryland USA

Re: stand pat or side to move bonus

Post by lkaufman »

Rebel wrote:
diep wrote: D) Do not give the bonus at all
In Diep i'm not giving a bonus at all. Some 10+ years ago i tested many games with and without, and it didn't help at all, also to my surprise.
I have the same experience.

From my (old) to-do-list:

1. King-safety and passed pawn: subtract 10-15-20-25% from the score, often the next ply the opponent can flatten the score.

2. In a quiet position after a series of captures add a penalty. Not seldom trouble starts afterwards.
Are you saying that the side wishing to stand pat after a series of captures should take a penalty for doing so? It's easy enough to test this, but it's hard for me to see why a capture series should favor the side making the last capture.
lkaufman
Posts: 5960
Joined: Sun Jan 10, 2010 6:15 am
Location: Maryland USA

Re: stand pat or side to move bonus

Post by lkaufman »

bob wrote:
lkaufman wrote:
bob wrote:
lkaufman wrote:In at least 99% of chess positions, it's better to be on move than not. Therefore all strong programs take this into consideration when evaluating positions or making decisions. There appear to be three possibilities:

A. Simply give the side to move a bonus when doing an evaluation, which can either be a constant or may depend on something else.
B. When reaching quies, if you are below beta but within for example 10 centipawns of beta allow the cutoff.
C. Do both of the above.

What are the pros and cons of the three methods? We currently use method A, but I notice that some strong programs appear to use B or C. Are there any other possibilities in use for handling this issue?
I've done this for a long time in Crafty. Current values are 5 and 8 for middle-game and endgame. I tested a bunch of different combinations, but those were best at the time. Not a huge gain anyway, but still, every Elo point counts...

I don't particularly see any difference in any of the above. If you add in the bonus, you may well cause a cutoff anyway. If you just check for the cutoff, you might save a little time.

Doing both seems redundant...
It's odd that you found that the value should go UP in the endgame, while both SF and Komodo found the opposite! I wonder why?
The difference between A and B is in whether the bonus affects only quies decisions (B) or all decisions thruout the search (A), for examply futility.
I don't think 5 centipawns is going to affect futility in any measurable way. As far as the difference, it makes sense to me actually. Where is the side to move more important, in the middlegame or when there are just kings on and a single tempo is often critical? I started with just one, and tuned it, then tried MG/EG and tuned each independently. 5/8 was best, but we are not talking 3-4-5 Elo here. This is very small.
I have been thinking about this wrongly. Forget about futility and other pruning. Here is the issue as I see it now. Since sometimes one must compare identical positions with opposite side-to-move in the search, there exists some stand pat value (or set of values) that when given to the side to move makes the two cases equally promising on average. Call this margin A. Now assume we don't do that. When reaching quiesce, we can accept the score or try for more with captures or checks. Let's assume there are no good captures or checks. Should we use the exact score, or the score plus some margin, B? Using a margin will give more cutoffs but may hurt quality if too high.
We have all been using just one margin for both purposes. But is there any particular reason to think that the optimum margin for purpose A is the same as the optimum one for purpose B? If not, which should be larger, A or B, and why?
User avatar
Rebel
Posts: 6991
Joined: Thu Aug 18, 2011 12:04 pm

Re: stand pat or side to move bonus

Post by Rebel »

lkaufman wrote:
Rebel wrote:
diep wrote: D) Do not give the bonus at all
In Diep i'm not giving a bonus at all. Some 10+ years ago i tested many games with and without, and it didn't help at all, also to my surprise.
I have the same experience.

From my (old) to-do-list:

1. King-safety and passed pawn: subtract 10-15-20-25% from the score, often the next ply the opponent can flatten the score.

2. In a quiet position after a series of captures add a penalty. Not seldom trouble starts afterwards.
Are you saying that the side wishing to stand pat after a series of captures should take a penalty for doing so? It's easy enough to test this, but it's hard for me to see why a capture series should favor the side making the last capture.
I meant the other way around. The one doing the last capture and entering a quiet position (assuming you have this kind of information at your disposal) could be given a penalty. I am thinking of positions the search delays a loss by captures.
lkaufman
Posts: 5960
Joined: Sun Jan 10, 2010 6:15 am
Location: Maryland USA

Re: stand pat or side to move bonus

Post by lkaufman »

Rebel wrote:
lkaufman wrote:
Rebel wrote:
diep wrote: D) Do not give the bonus at all
In Diep i'm not giving a bonus at all. Some 10+ years ago i tested many games with and without, and it didn't help at all, also to my surprise.
I have the same experience.

From my (old) to-do-list:

1. King-safety and passed pawn: subtract 10-15-20-25% from the score, often the next ply the opponent can flatten the score.

2. In a quiet position after a series of captures add a penalty. Not seldom trouble starts afterwards.
Are you saying that the side wishing to stand pat after a series of captures should take a penalty for doing so? It's easy enough to test this, but it's hard for me to see why a capture series should favor the side making the last capture.
I meant the other way around. The one doing the last capture and entering a quiet position (assuming you have this kind of information at your disposal) could be given a penalty. I am thinking of positions the search delays a loss by captures.
That seems backwards to me. A typical situation is that I fork or pin you, you make a capture which forces a recapture, and now you have reached the depth where you can stand pat, although in reality you are losing. So the side making the last capture should get a bonus in this case, not a penalty as you suggest. So I actually now like the idea as I originally interpreted it, not as you explained above. Am I wrong, or did you mean to give a penalty to the side on-move, which is the opposite of the side who made the last capture?
User avatar
rvida
Posts: 481
Joined: Thu Apr 16, 2009 12:00 pm
Location: Slovakia, EU

Re: stand pat or side to move bonus

Post by rvida »

lkaufman wrote:
Rebel wrote:
lkaufman wrote:
Rebel wrote:
diep wrote: D) Do not give the bonus at all
In Diep i'm not giving a bonus at all. Some 10+ years ago i tested many games with and without, and it didn't help at all, also to my surprise.
I have the same experience.

From my (old) to-do-list:

1. King-safety and passed pawn: subtract 10-15-20-25% from the score, often the next ply the opponent can flatten the score.

2. In a quiet position after a series of captures add a penalty. Not seldom trouble starts afterwards.
Are you saying that the side wishing to stand pat after a series of captures should take a penalty for doing so? It's easy enough to test this, but it's hard for me to see why a capture series should favor the side making the last capture.
I meant the other way around. The one doing the last capture and entering a quiet position (assuming you have this kind of information at your disposal) could be given a penalty. I am thinking of positions the search delays a loss by captures.
That seems backwards to me. A typical situation is that I fork or pin you, you make a capture which forces a recapture, and now you have reached the depth where you can stand pat, although in reality you are losing. So the side making the last capture should get a bonus in this case, not a penalty as you suggest. So I actually now like the idea as I originally interpreted it, not as you explained above. Am I wrong, or did you mean to give a penalty to the side on-move, which is the opposite of the side who made the last capture?
If I understand correctly, Komodo already does something similar. In qsearch it gives a small bonus when the last move was not a capture.