So same, so different

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

So same, so different

Post by Lyudmil Tsvetkov »

One more message for people to read and possibly discuss during the weekend.

I know that engines assign equal bonus points for all files for a rook on an open file, no matter where the file lies.

Do you think this is really the case?

If you ask me, I would say that values for a rook on an open file differ sharply in relation to the particular placement of the rook.

I would assess the following order of importance to be true, from most to least important: h file is the most important one, followed by e file, d file, c file, a file, b file, g file, with f file closing the ranks.

So the h file is the most important one, while the f file usually the least important one.

If you have a standard rook on open file bonus of say, 20cps, you could easily break it down into the following values:

- 35cps for rook on an open h file
- 28cps for rook on an open e file
- 26 for d file
- 24 for c file
- 20 for a file
- 16 for b and g files
- and 10 for f file

No matter how the above values might be interpreted, there is absolutely no doubt that the h file deserves the largest value, really much higher than that for the second-placed e file.
Similarly, it is beyond doubt that the f file deserves the lowest values.

Well, I know that engine authors introduce granularity with the aim of achieving a more precise eval, but why do not they introduce granularity for such a term, what better form of granularity than to have precise values for each specific file, rather than simply assigning a blanket, and rather inaccurate, value?

[d]br1rq1k1/2pn1pb1/4pnp1/3pN3/p2P1P2/B1P1PBP1/P2NQ2R/R5K1 w - - 0 1
Do you think the white h2 rook on the h file and the black b8 rook on the b file deserve equal values?
Definitely not. And this has nothing to do with the fact that the white rook attacks the enemy king: that is another term, that is complementary, and not redundant, with the rook on an open file term. It is simply that the location of the white rook on the h open file is objectively much more forceful.

For once, it is an edge file, making defence more difficult, and secondly, this would allow to build advantageous batteries of heavy pieces.

And indeed, chances are that on the above diagram white will build a powerful attack with mating threats precisely along the open h file.

Any thoughts on that?

I really think assigning equal values for all files for a rook on an open file is a wrong approach.
Lyudmil Tsvetkov
Posts: 6052
Joined: Tue Jun 12, 2012 12:41 pm

Re: So same, so different

Post by Lyudmil Tsvetkov »

One small clarification is that the different values might apply only to the middlegame, as in the endgame many factors influencing the abovementioned specific values disappear, making the standard approach preferable there.

Also, I have not thought about values for a rook on a semiopen file, a closely related term; it is possible that you should not make distinctions there, or they should be less pronounced, or following a different order.
royb
Posts: 536
Joined: Thu Mar 09, 2006 12:53 am

Re: So same, so different

Post by royb »

Lyudmil Tsvetkov wrote:One small clarification is that the different values might apply only to the middlegame, as in the endgame many factors influencing the abovementioned specific values disappear, making the standard approach preferable there.

Also, I have not thought about values for a rook on a semiopen file, a closely related term; it is possible that you should not make distinctions there, or they should be less pronounced, or following a different order.
Would it also be beneficial to have the bonus value be different depending on where the enemy king is located? For instance, if the Black King castled queenside (O-O-O), the king is not near the h file and might it be better in that case to slightly lower the bonus for the rook on the open h file?
Lyudmil Tsvetkov
Posts: 6052
Joined: Tue Jun 12, 2012 12:41 pm

Re: So same, so different

Post by Lyudmil Tsvetkov »

royb wrote:
Lyudmil Tsvetkov wrote:One small clarification is that the different values might apply only to the middlegame, as in the endgame many factors influencing the abovementioned specific values disappear, making the standard approach preferable there.

Also, I have not thought about values for a rook on a semiopen file, a closely related term; it is possible that you should not make distinctions there, or they should be less pronounced, or following a different order.
Would it also be beneficial to have the bonus value be different depending on where the enemy king is located? For instance, if the Black King castled queenside (O-O-O), the king is not near the h file and might it be better in that case to slightly lower the bonus for the rook on the open h file?
Hi Roy.

Programmers want as few terms as possible, and as few function calls as possible, as I understand.

As in 95% of all cases the kings castle short, it might be wise to just assign an asymmetric mg bonus, instead of creating a separate function that will look for where the kings are placed.

At least that is my understanding.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: So same, so different

Post by Evert »

Lyudmil Tsvetkov wrote: Programmers want as few terms as possible, and as few function calls as possible, as I understand.

As in 95% of all cases the kings castle short, it might be wise to just assign an asymmetric mg bonus, instead of creating a separate function that will look for where the kings are placed.

At least that is my understanding.
I would definitely not implement something that depends on the location of the enemy king without taking the location of the king into account. That's a disaster waiting to happen.

So yes, it absolutely should include the location of the enemy king.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: So same, so different

Post by Evert »

Lyudmil Tsvetkov wrote: I know that engines assign equal bonus points for all files for a rook on an open file, no matter where the file lies.

Do you think this is really the case?
The answer is not a straightforward one. Certainly not all open files are equal, but one should assign the value for them based on positional considerations relevant to the present position.

And herein also lies the subtlety: it may well be true that the open file bonus itself is flat, but that does not mean that all open files end up being evaluated equal because open files are not the only evaluation term affecting rooks.
If you ask me, I would say that values for a rook on an open file differ sharply in relation to the particular placement of the rook.
It does, of course.
For one thing there is the piece square table, which probably favours central files over edge ones. On top of that there is the king safety evaluation, which will put (considerably) higher value on an open file near the enemy king.
I would assess the following order of importance to be true, from most to least important: h file is the most important one, followed by e file, d file, c file, a file, b file, g file, with f file closing the ranks.

So the h file is the most important one, while the f file usually the least important one.
This is assuming that the (black) king is on g8 and white has an open file, correct?
I can understand the h-file being important, and I can understand the e and d files also being important. What I do not understand is why the f and g files would be considered to be so unimportant. Can you explain this?
[d]br1rq1k1/2pn1pb1/4pnp1/3pN3/p2P1P2/B1P1PBP1/P2NQ2R/R5K1 w - - 0 1
Do you think the white h2 rook on the h file and the black b8 rook on the b file deserve equal values?
Definitely not. And this has nothing to do with the fact that the white rook attacks the enemy king: that is another term, that is complementary, and not redundant, with the rook on an open file term. It is simply that the location of the white rook on the h open file is objectively much more forceful.
Well,
For once, it is an edge file, making defence more difficult, and secondly, this would allow to build advantageous batteries of heavy pieces.
This I can understand, and it goes for the a-file as well as the h file. However,
And indeed, chances are that on the above diagram white will build a powerful attack with mating threats precisely along the open h file.
This has more to do with king-safety than with the location of the open file, and would already be reflected in the evaluation.
I really think assigning equal values for all files for a rook on an open file is a wrong approach.
Probably, but I suspect you underestimate the interaction of other evaluation terms with the open file bonus.
Lyudmil Tsvetkov
Posts: 6052
Joined: Tue Jun 12, 2012 12:41 pm

Re: So same, so different

Post by Lyudmil Tsvetkov »

Evert wrote:For one thing there is the piece square table, which probably favours central files over edge ones. On top of that there is the king safety evaluation, which will put (considerably) higher value on an open file near the enemy king.
The rook psqt will favour central files over edge ones, but in which situations?
When the files is open, when it is half-open, or when it is closed? As you see, there is a difference.

Considering king safety putting higher value on an open file near the enemy king, I would again ask: On which open file near the enemy king, if the king is on g8, on the h or on the f file?
Because, according to my calculations, the h file is practically the most useful file, while the f open file the least useful. So if you give equal values here, you might have it plain wrong.
Evert wrote: I can understand the h-file being important, and I can understand the e and d files also being important. What I do not understand is why the f and g files would be considered to be so unimportant. Can you explain this?
Very difficult to explain. Based on my observations from multiple games against engines. Has to do with the usual location of the kings on the g file or nearby, as well as the usual piece placement conditional upon the kings residing on this file.

With g open file, it is very difficult to open, as the g2 and g7 pawns sheltering the kings are usually the last to move forward.
The f file is due the smallest bonus, because, even if it is easy to open, with f pawns advancing frequently, there is almost no added value to open it in the usual case, as an f1 white rook on an open file will be met by an f8 black rook, the kingside rooks usually residing on f1 and f8, and exchanged. So no real added value here.

An h file, on the other hand, while difficult to open, is so forceful, that every bit of the bonus is well deserved. And in the case of an h-file rook, quite often the rook is unopposed by an enemy one.

It simply happens that way; that are board-specific observations. For example, I observe that the top attacking engine, Stockfish, very frequently underestimates the power of a rook on an open h file.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: So same, so different

Post by Evert »

Lyudmil Tsvetkov wrote: The rook psqt will favour central files over edge ones, but in which situations?
When the files is open, when it is half-open, or when it is closed? As you see, there is a difference.
The PST is independent of considerations of whether a file is open or not. That doesn't really matter though, since the total evaluation is PST+(half)open bonus. You can shift that bonus to the PST and use a different PST n that situation, or you can keep it separate. The final evaluation is the same, but it is generally preferable to do the split as I mentioned.
Considering king safety putting higher value on an open file near the enemy king, I would again ask: On which open file near the enemy king, if the king is on g8, on the h or on the f file?
Because, according to my calculations, the h file is practically the most useful file, while the f open file the least useful. So if you give equal values here, you might have it plain wrong.
I would award them the same, on the ground that it doesn't matter if you're mated from the left or from the right. That's not to say there aren't other considerations that break the symmetry. For instance: in the middle-game, it may be advantageous to drive the enemy king to the centre, which means you should put the rook on the h-file (in the end game you of course want to drive the king to the edge, but there king safety is generally suppressed anyway).
Evert wrote: I can understand the h-file being important, and I can understand the e and d files also being important. What I do not understand is why the f and g files would be considered to be so unimportant. Can you explain this?
Very difficult to explain. Based on my observations from multiple games against engines. Has to do with the usual location of the kings on the g file or nearby, as well as the usual piece placement conditional upon the kings residing on this file.
Ok, so can we generalise to say that for the files that make up the king's position, the one that is closest to the edge of the board is most valuable (because the king needs to flee to the centre) and such that it is more valuable than the centre files?

Files on the other side of the board probably derive their value from creating a second weakness, or undermining the defensive position of the king.
With g open file, it is very difficult to open, as the g2 and g7 pawns sheltering the kings are usually the last to move forward.
Sure. But that surely doesn't affect the value of the file once it's opened?
The f file is due the smallest bonus, because, even if it is easy to open, with f pawns advancing frequently, there is almost no added value to open it in the usual case, as an f1 white rook on an open file will be met by an f8 black rook, the kingside rooks usually residing on f1 and f8, and exchanged. So no real added value here.
Ok, so having an enemy rook on the same file negates (reduces) the open-file bonus. This actually happens automatically because both sides will get the bonus, so they cancel. If there are considerations that make the open file more desirable for one side than for the other, they need to be specified (and awarded) separately.
An h file, on the other hand, while difficult to open, is so forceful, that every bit of the bonus is well deserved. And in the case of an h-file rook, quite often the rook is unopposed by an enemy one.

It simply happens that way; that are board-specific observations. For example, I observe that the top attacking engine, Stockfish, very frequently underestimates the power of a rook on an open h file.
Sure. The thing is, adding simple ad-hoc evaluation terms like this, while good for a quick gain in strength, doesn't scale well, because the bonus may get applied to situations where it shouldn't be.

How about the following generalisation:
1. The central files get a particular bonus (say 26cp, you d-file value)
2. Files next to the central files drop off in value (24 for the c/f-files, 16 for the b/g files, 8 for the a/h files)
3. The edge files get an extra bonus (+12, bringing the a-file up to your 20)
4. Files near the king structure get an extra bonus: the central file on the same side of the board gets an extra +2 (bringing the e-file up to your 28), the edge file gets a whopping +15 (bringing the h-file up to 35), the king's file itself is not touched (seems odd, but ok) while the file next to the king file that is furthest away from the edge gets penalised by -14, dropping the f-file to 10.

This reproduces the numbers you gave (if I didn't mess up the calculation) but it generalises the structure behind them into something I might actually try to implement. Does it look like a reasonable line of reasoning to you?

Personally I would probably not penalise the f-file quite so dramatically. You're right that it's probably defended much more easily than the h-file, and if you try to exploit it your pieces may end up blocking eachother, but these considerations should already be encoded separately. However, if the engine has a choice between opening the f-file and opening the h-file, it should open the h-file, which it already would given the h-file bonus.
mvk
Posts: 589
Joined: Tue Jun 04, 2013 10:15 pm

Re: So same, so different

Post by mvk »

Lyudmil Tsvetkov wrote:I know that engines assign equal bonus points for all files for a rook on an open file, no matter where the file lies.
Not here. It depends on the king locations also.
[Account deleted]
Joerg Oster
Posts: 937
Joined: Fri Mar 10, 2006 4:29 pm
Location: Germany

Re: So same, so different

Post by Joerg Oster »

Hi Lyudmil,

I think I already tried something similar (local test) in the past, but I pushed a test anyways.
Jörg Oster