Trading penalty with imbalances

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Rebel, chrisw

Lyudmil Tsvetkov
Posts: 6052
Joined: Tue Jun 12, 2012 12:41 pm

Trading penalty with imbalances

Post by Lyudmil Tsvetkov »

Whatever I try to post nowadays, it always has to do with imbalances. I would gladly like to post something more intriguing and fresh, but somehow it always boils down to this...

Probably I could have posted also in the 'Lonely queen' thread, but maybe this way is also not that bad, as there are things that distinguish the 2 topics.

Thomas Petzke did some very nice comparisons of imbalances involving pure setting and additional pieces, please look here: http://macechess.blogspot.de/2013/12/qu ... art-2.html. I think the topic has been discussed elsewhere also, and maybe many programmers use some kind of knowledge based on this (although I am not certain of it), however I did not find a synopsis of the piece of knowledge or a single rule being formulated.

It seems that with imbalances with unequal number of pieces, i.e. one of the sides having a piece or even 2 pieces more, as a rule the side with the bigger number of pieces would often benefit from the presence of additional pieces. For example, you have Q vs 2Ns+B, and the queen performs quite well, you add one rook each side, and already the minors start performing very promisingly. Of course, this could be explained by the presence of piece types, as the rook adds no piece types to the Q+R (only one repetition), but adds one piece type to the 2Ns+B. And indeed, on many occasions piece types and repetitions would successfully explain what happens in different imbalaces. However, I am not certain how easy it is to implement that piece of knowledge in terms of efficiency, and on the other hand just counting pieces seems much easier.

Quite often (although not always), the side with the more pieces would also enjoy advantage in terms of the number of piece types, so that my question is if anyone has provided in his engine for a term assigning penalty (maybe some 10-15cps) for trading down to the side with the more pieces, whenever there is an imbalance with one of the sides having a piece or 2 more? Obviously, with imbalances with equal number of pieces you can not do that, and piece types and repetitions would do fine there, they would also do fine in imbalance situations with one of the sides having just a piece more, but fail to an extent with one of the sides having 2 pieces more. Assigning a penalty for trading down should work quite well in imbalances with one of the sides having 2 pieces more, and still satisfactorily when one of the sides has just a single piece more, although not optimally.

The trick here is that this penalty could be quite useful, as imbalances with one of the sides having a piece more are much more frequent than imbalances with 2 pieces more. For example, here would belong imbalances like:
N vs 3 pawns worse for the knight than N+N vs N+3 pawns;
R vs 5 pawns worse for the rook than R+R vs R+ 5 pawns;
N+B vs R + 2 pawns worse for the minor pieces than N+B+R vs R+R + 2 pawns;
Q vs R+B+ pawn worse for the R+B than Q +N vs R+B+N + pawns, etc.

By using such a simple trading rule, one could simply avoid trading for the side with more pieces, and encourage trading for the side with less pieces. I think also the implementation is very simple: whenever there is unequal number of pieces, you assign 10cps penalty (or something like that) for trading down to the side with more pieces. Other factors might justify trading, but the penalty could be a useful benchmark.

Any thought on that? Anyone doing it already? It should pay off, as those imbalances are quite frequent indeed.
User avatar
hgm
Posts: 27808
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Trading penalty with imbalances

Post by hgm »

Giving bonuses for having more pieces is not much different from increasing all piece values by that bonus. So it does not really go beyond additive piece values.

What helped a lot in Joker was making pawn evaluation dependent on the number of (non-Pawn) pieces: if the opponent has more pieces, joker divides the passer bonuses by 2, as the opponent can prevent their advance quite easily. If the opponent has fewer pieces, the passer bonuses are increased by 50%, because you can quite easily advance them, using your numeric majority to control the square in front of it. I thought about extending this even to the Pawn base value, as Pawns become a liability when the opponent can attack them more than you can protect them. So the more Pawns you have, the worse it is to have the numeric minority in pieces. But I never got to trying that.
Lyudmil Tsvetkov
Posts: 6052
Joined: Tue Jun 12, 2012 12:41 pm

Re: Trading penalty with imbalances

Post by Lyudmil Tsvetkov »

hgm wrote:Giving bonuses for having more pieces is not much different from increasing all piece values by that bonus. So it does not really go beyond additive piece values.

What helped a lot in Joker was making pawn evaluation dependent on the number of (non-Pawn) pieces: if the opponent has more pieces, joker divides the passer bonuses by 2, as the opponent can prevent their advance quite easily. If the opponent has fewer pieces, the passer bonuses are increased by 50%, because you can quite easily advance them, using your numeric majority to control the square in front of it. I thought about extending this even to the Pawn base value, as Pawns become a liability when the opponent can attack them more than you can protect them. So the more Pawns you have, the worse it is to have the numeric minority in pieces. But I never got to trying that.
Hi Santa. :)

You traded winboard for Santa...

It should not work only in the case of passers, there is a large variety of positions without passers where this should also be meaningful.
User avatar
hgm
Posts: 27808
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Trading penalty with imbalances

Post by hgm »

But if you define 'meaningful' in a way that could also have been taken care of by altering additive piece values, like giving a bonus proportional to the number of pieces, not much remains.

Best is just to measure all possible material imbalances, and then try to fot those with a sensible theory with only few free parameters.
Lyudmil Tsvetkov
Posts: 6052
Joined: Tue Jun 12, 2012 12:41 pm

Re: Trading penalty with imbalances

Post by Lyudmil Tsvetkov »

hgm wrote:But if you define 'meaningful' in a way that could also have been taken care of by altering additive piece values, like giving a bonus proportional to the number of pieces, not much remains.

Best is just to measure all possible material imbalances, and then try to fot those with a sensible theory with only few free parameters.
Sorry for my ignorance, but how would the theory of additive piece values look like? Whats bonus would you assign to each individual piece? Why is not it working in the Q vs 3 pieces imbalance?

Any idea on how many engines would use additive piece values?
cetormenter
Posts: 170
Joined: Sun Oct 28, 2012 9:46 pm

Re: Trading penalty with imbalances

Post by cetormenter »

hgm wrote: What helped a lot in Joker was making pawn evaluation dependent on the number of (non-Pawn) pieces
I have done something similar in Nirvana only in a slightly different way. I count up the difference in non pawn pieces and then subtract five times this value from each pawn the opponent has. That is,

Code: Select all

value += wcount > bcount ? 5 * (wcount - bcount) * bpawns: 5 * (wcount - bcount) * wpawns;
Amazingly this simple piece of code is worth about 20 elo points. It lead me to believe that perhaps my pawn to minor piece ratio was slightly amiss but any attempts to tune these value proved to be regressions.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Trading penalty with imbalances

Post by Evert »

Lyudmil Tsvetkov wrote: The trick here is that this penalty could be quite useful, as imbalances with one of the sides having a piece more are much more frequent than imbalances with 2 pieces more. For example, here would belong imbalances like:
N vs 3 pawns worse for the knight than N+N vs N+3 pawns;
R vs 5 pawns worse for the rook than R+R vs R+ 5 pawns;
N+B vs R + 2 pawns worse for the minor pieces than N+B+R vs R+R + 2 pawns;
Q vs R+B+ pawn worse for the R+B than Q +N vs R+B+N + pawns, etc.

By using such a simple trading rule, one could simply avoid trading for the side with more pieces, and encourage trading for the side with less pieces. I think also the implementation is very simple: whenever there is unequal number of pieces, you assign 10cps penalty (or something like that) for trading down to the side with more pieces. Other factors might justify trading, but the penalty could be a useful benchmark.

Any thought on that? Anyone doing it already? It should pay off, as those imbalances are quite frequent indeed.
I have a trade-down penalty in Jazz that gives a bonus to the side with a material advantage if there are fewer pieces on the board, and a slight bonus to the side that is behind if there are fewer pawns on the board.

I don't remember off the top of my head what it was worth in elo terms (it's not huge), but removing it was a clear regression last time I tried.
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: Trading penalty with imbalances

Post by lucasart »

cetormenter wrote:
hgm wrote: What helped a lot in Joker was making pawn evaluation dependent on the number of (non-Pawn) pieces
I have done something similar in Nirvana only in a slightly different way. I count up the difference in non pawn pieces and then subtract five times this value from each pawn the opponent has. That is,

Code: Select all

value += wcount > bcount ? 5 * (wcount - bcount) * bpawns: 5 * (wcount - bcount) * wpawns;
Amazingly this simple piece of code is worth about 20 elo points. It lead me to believe that perhaps my pawn to minor piece ratio was slightly amiss but any attempts to tune these value proved to be regressions.
This is very interesting. I've had on my todo list for a while to do an imbalance bonus/penalty based on the difference in piece count. But I never thought of making it depend on the number of pawns of the side with the least pieces.

But 20 elo seems a bit too much. Are you sure it is really worth 20 elo by itself ? Material imbalances are quite rare.

As for piece values, I use the following:

Code: Select all

Pawn = 80 (opening) 100 (endgame)
Knight = Bishop = 330
Rook = 545
Queen = 1000
But yes, it's important to be sure the first order (piece values) is well tuned before adding a second order (imbalance). Otherwise, you end up adding code you think is useful but is just bloat and is only useful because of its orthogonal projection on the first order.
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
User avatar
hgm
Posts: 27808
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Trading penalty with imbalances

Post by hgm »

Lyudmil Tsvetkov wrote:Sorry for my ignorance, but how would the theory of additive piece values look like?
You assign values to each piece, like P=100, N=325, B=325, R=500, Q=950, and then add all the values of the pieces for each side, and subtract them from each other.

A commonly used refinement (that already goes a bit beyond additivity) is to define two values for each piece, an opening value and an end-game value, and do the calculation for each of those, and finally take a weighted average, the weights depending on the 'game phase' (which again is some weigthed count of total board material).
Whats bonus would you assign to each individual piece? Why is not it working in the Q vs 3 pieces imbalance?
Not sure what was not working. 3*325 - 950 = 25, very close to what was observed. Without Rooks you are closer to the end-game. and perhaps the end-game piece values are different.
Any idea on how many engines would use additive piece values?
Almost all of them. Only the few strong ones go beyond that. Since Fruit defining separate end-game and opening values, and Rybka was known to include a huge table of eval corrections for specefic imbalances.
Lyudmil Tsvetkov
Posts: 6052
Joined: Tue Jun 12, 2012 12:41 pm

Re: Trading penalty with imbalances

Post by Lyudmil Tsvetkov »

hgm wrote:
Lyudmil Tsvetkov wrote:Sorry for my ignorance, but how would the theory of additive piece values look like?
You assign values to each piece, like P=100, N=325, B=325, R=500, Q=950, and then add all the values of the pieces for each side, and subtract them from each other.

A commonly used refinement (that already goes a bit beyond additivity) is to define two values for each piece, an opening value and an end-game value, and do the calculation for each of those, and finally take a weighted average, the weights depending on the 'game phase' (which again is some weigthed count of total board material).
Whats bonus would you assign to each individual piece? Why is not it working in the Q vs 3 pieces imbalance?
Not sure what was not working. 3*325 - 950 = 25, very close to what was observed. Without Rooks you are closer to the end-game. and perhaps the end-game piece values are different.
Any idea on how many engines would use additive piece values?
Almost all of them. Only the few strong ones go beyond that. Since Fruit defining separate end-game and opening values, and Rybka was known to include a huge table of eval corrections for specefic imbalances.
So, basically, additive piece values in your view, means basic piece values. That is the same as doing nothing at all, while an imbalance would mean that pieces deserve a bonus/penalty over and above their basic values. Of course, you can tune piece values so that they fit into a range of imbalances, but you can not do 2 things at least:

- do the Q vs 3 pieces imbalance, where adding brings nothing (again, the tests Mr. Petzke run showed 3Ns in a pure setting are weaker by far than a queen, but additional pieces change the balance)
- explain that same thing, why additional pieces change the balance, and that is why a trading down penalty for the side with more pieces would be very opportune
- explain the behaviour in composite imbalances with many pieces, where piece types and repetitions already matter, i.e. the interaction of the pieces in a specific environment viewed as a group

Very simple example: you have an imbalance of B+N+R vs 2Rs+ 2 pawns. How do you know that the side with the 3 pieces should avoid exchanging rooks, if you do not assign trading penalty for the side with the bigger number of pieces, provided that after exchanging additive piece values would amount to the same score as without exchanging?

The main theory of the trading penalty for the side with bigger number of pieces would be that it would be better to have 7 pieces vs 6 than 6 pieces vs 5, which in turn would be better than having 5 pieces vs 4, etc. So that in the particular case, because having 3 pieces vs 2 is better than having 2 pieces vs 1, the trading penalty should prevent that an unwelcome exchange happens. Retaining bigger number of pieces for the side with more pieces reflects the fact that with time those pieces would have good chances to increase further their score. If you exchange them early, you miss a precious opportunity to improve your position. How do you avoid unwelcome exchanges with imbalances with unequal number of pieces, if you do not introduce a trading penalty?

Well, maybe close to the endgame, as pawns get higher values, an engine would avoid trading N+N vs N+3 pawns to N vs 3 pawns; however, if there are a significant number of pieces, for example R+B+pawn+2Ns+2Rs vs Q+2Ns+2Rs, i.e. 6 vs 5, how do you see that the side with more pieces should in general avoid any exchanges if possible?