On Tempo

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
Rebel
Posts: 6991
Joined: Thu Aug 18, 2011 12:04 pm

On Tempo

Post by Rebel »

I guess everybody has some sort of code dealing with the tempo penalty in eval. Basically I subtract 0.04 for pawn, knight, bishop and rook moves and 0.06 for queen and king moves in the middle game and no penalty at all in the endgame. I don't know why this difference between the mid and end game, it just scores better, that is, for my engine.

I never was satisfied with the concept, there must be more to it. I recently found something simple that gives some extra elo (currently 5) and even makes sense :D At the end of eval subtract the the material score from the evaluation score, what is left is the pure evaluation score. An (extra) tempo penalty is applied with 5% from this evaluation score. So:

score -= (score-material) * 0.05

It makes sense, in a balanced position, say (score-material) is 0.20 the correction is only 0.01, thus 0.19, in case of big evaluation scores over 1 or more pawns the correction becomes bigger (1.00 becomes 0.95, 2.00 becomes 1.90) and why not, since in certain situations the advantage can evaporate the next move.

I am currently trying 6% (so far even better) and later (based on my experiences) should create a second parameter for the endgame.
90% of coding is debugging, the other 10% is writing bugs.
Ras
Posts: 2487
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: On Tempo

Post by Ras »

Rebel wrote: Wed Aug 15, 2018 6:24 pm score -= (score-material) * 0.05
If that works out, it just means that the positional scoring is overdone by 5%. It has nothing to do with tempo.
Rasmus Althoff
https://www.ct800.net
User avatar
Rebel
Posts: 6991
Joined: Thu Aug 18, 2011 12:04 pm

Re: On Tempo

Post by Rebel »

Ras wrote: Wed Aug 15, 2018 9:38 pm
Rebel wrote: Wed Aug 15, 2018 6:24 pm score -= (score-material) * 0.05
If that works out, it just means that the positional scoring is overdone by 5%. It has nothing to do with tempo.
If that is true it would mean 2 things:

#1. Decreasing every eval ingrediënt with 5% should give the same improvement, I somehow doubt that.
#2. That every programmer should tune his eval this way, meaning:

score += (score-material) * percentage

Where percentage can be positive or negative.
90% of coding is debugging, the other 10% is writing bugs.
User avatar
hgm
Posts: 27788
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: On Tempo

Post by hgm »

Rebel wrote: Wed Aug 15, 2018 6:24 pm I guess everybody has some sort of code dealing with the tempo penalty in eval. Basically I subtract 0.04 for pawn, knight, bishop and rook moves and 0.06 for queen and king moves in the middle game and no penalty at all in the endgame.
I don't get this. Eval scores positions, not moves. do you mean you do this in the incrementally upated part of the eval? That would not really be consistent, right? If you move back an forth a Rook you would end in the same position as when you moved back an forth a Queen, but with a better eval.

In CrazyWa (which is specifically designed for variants with piece drops) I use a side-to-move bonus which is calculate from the King safety of the opponent. This works amazigly well (given that it is the major King-Safety term).
User avatar
Rebel
Posts: 6991
Joined: Thu Aug 18, 2011 12:04 pm

Re: On Tempo

Post by Rebel »

hgm wrote: Thu Aug 16, 2018 10:58 am
Rebel wrote: Wed Aug 15, 2018 6:24 pm I guess everybody has some sort of code dealing with the tempo penalty in eval. Basically I subtract 0.04 for pawn, knight, bishop and rook moves and 0.06 for queen and king moves in the middle game and no penalty at all in the endgame.
I don't get this. Eval scores positions, not moves. do you mean you do this in the incrementally upated part of the eval? That would not really be consistent, right? If you move back an forth a Rook you would end in the same position as when you moved back an forth a Queen, but with a better eval.

In CrazyWa (which is specifically designed for variants with piece drops) I use a side-to-move bonus which is calculate from the King safety of the opponent. This works amazigly well (given that it is the major King-Safety term).
Yeah, via the incrementally updated material score. I said basically in the OP to avoid that particular part to become the center of the discussion. But now that you mentioned it :D the effect is if a king moves twice in the mid game tree the penalty is also twice. Same for her majesty, if she wants to move 4 times she must have a good reason.
90% of coding is debugging, the other 10% is writing bugs.
User avatar
hgm
Posts: 27788
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: On Tempo

Post by hgm »

OK, so this is equivalent to a consistent stm bonus of 2 cP, plus a kludgy way to discourage moving Q and K. I must admit I have a move penalty for Kings too in microMax (20 cP even), as a cheap kludge for King safety: because of it it tries to protect its King from checks that would force teh King to move. That it is inconsistent because it cannot distinguish back-and-forth moving from not moving at all is not very damaging, because it is bad anyway, and it doesn't matter much how bad, as there is almost always something better.

I am not sure that it should be used on the Queen, though. My guess is that it would only be helpful if something else is fundamentally wrong. Wasting tempos is not bad per se; in fact the value of a tempo can be negative (zugzwang). It is bad in the opening, because in the opening position almost every piece is in a poor place, and moves you waste by multiple moving with one piece cannot be used to improve the location of another piece. But that should really punish itself, because branches that contain multiple moves with the same piece should, at the same depth, leave more pieces in poor places than branches that move all different pieces. If that is not the case, it suggests that the PST overestimate the value of pieces in their original location, so that you can gain more by making a second move with an already developed piece than by developing a virgin piece.

In Joker I used a penalty on a virgin Bishop, which increased with move number. The advantage of that is that it doesn't disturb later play, where all pieces have moved.
Ras
Posts: 2487
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: On Tempo

Post by Ras »

Rebel wrote: Thu Aug 16, 2018 8:43 am#1. Decreasing every eval ingrediënt with 5% should give the same improvement, I somehow doubt that.
Aside from integer arithmetics issues, I really don't doubt that (a + b) * c == a*c + b*c.
Rasmus Althoff
https://www.ct800.net
User avatar
Rebel
Posts: 6991
Joined: Thu Aug 18, 2011 12:04 pm

Re: On Tempo

Post by Rebel »

hgm wrote: Thu Aug 16, 2018 3:18 pm OK, so this is equivalent to a consistent stm bonus of 2 cP, plus a kludgy way to discourage moving Q and K. I must admit I have a move penalty for Kings too in microMax (20 cP even), as a cheap kludge for King safety: because of it it tries to protect its King from checks that would force teh King to move. That it is inconsistent because it cannot distinguish back-and-forth moving from not moving at all is not very damaging, because it is bad anyway, and it doesn't matter much how bad, as there is almost always something better.

I am not sure that it should be used on the Queen, though. My guess is that it would only be helpful if something else is fundamentally wrong. Wasting tempos is not bad per se; in fact the value of a tempo can be negative (zugzwang). It is bad in the opening, because in the opening position almost every piece is in a poor place, and moves you waste by multiple moving with one piece cannot be used to improve the location of another piece. But that should really punish itself, because branches that contain multiple moves with the same piece should, at the same depth, leave more pieces in poor places than branches that move all different pieces. If that is not the case, it suggests that the PST overestimate the value of pieces in their original location, so that you can gain more by making a second move with an already developed piece than by developing a virgin piece.

In Joker I used a penalty on a virgin Bishop, which increased with move number. The advantage of that is that it doesn't disturb later play, where all pieces have moved.
Yep, it's a known rule in the opening, don't move your light pieces twice. As for the Q having a higher penalty, an eng-eng match did the job.
90% of coding is debugging, the other 10% is writing bugs.
User avatar
hgm
Posts: 27788
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: On Tempo

Post by hgm »

What job? Patching one error with another?
User avatar
Rebel
Posts: 6991
Joined: Thu Aug 18, 2011 12:04 pm

Re: On Tempo

Post by Rebel »

hgm wrote: Fri Aug 17, 2018 11:10 am What job? Patching one error with another?
What ?!

Maybe that's your expertise, not mine :D
90% of coding is debugging, the other 10% is writing bugs.