Idea for recognizing fortress/encouraging progress

Discussion of chess software programming and technical issues.

Moderators: bob, hgm, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
User avatar
hgm
Posts: 23951
Joined: Fri Mar 10, 2006 9:06 am
Location: Amsterdam
Full name: H G Muller
Contact:

Re: Idea for recognizing fortress/encouraging progress

Post by hgm » Sun May 05, 2013 7:22 pm

I don't know where you get this idea of a 'simple-minded kludge'.

User avatar
Don
Posts: 5106
Joined: Tue Apr 29, 2008 2:27 pm

Re: Idea for recognizing fortress/encouraging progress

Post by Don » Sun May 05, 2013 7:47 pm

hgm wrote:I don't know where you get this idea of a 'simple-minded kludge'.
I was referring to MY simple minded kludge, the one I described doing a few months back, so don't take it personally. I was not referring to anything you said.

Our evaluation function, as well as everyone else's of course is just a collection of simple minded kludges and that idea seemed like a reasonable try to me. Maybe it still is and we never stumbling upon the right implementation details.

Don
Capital punishment would be more effective as a preventive measure if it were administered prior to the crime.

Sven
Posts: 3830
Joined: Thu May 15, 2008 7:57 pm
Location: Berlin, Germany
Full name: Sven Schüle
Contact:

Re: Idea for recognizing fortress/encouraging progress

Post by Sven » Sun May 05, 2013 9:16 pm

Evert wrote:
Sven Schüle wrote: Without the queen the example position would be an exact draw. With the queen it remains draw unless the queen is sacrificed. Evaluating as 0 seems to fit best to this situation in my opinion.
Using that logic, KQK is a draw unless you actually give mate.
No, you fully misunderstood me: I wrote that I want to evaluate 100% useless pieces as 0, like the black bishop or the two rooks. In KQK the queen is clearly not useless. And here we are also talking about positions with 8+8 locked pawns only.
Evert wrote:The position is not a draw because of the presence of the queen, so evaluating it as such isn't correct.
Perhaps you are right: 0 may be too harsh due to the queen which is not "fully useless" due to its sacrifice ability. But would't the following problem remain present: the program sees all non-sacrifice positions as "won" but does not actually play the winning sequence, instead moves around its pieces while maintaining the "win"? I think this is a bit like the question whether we should evaluate the first repetition within the search tree (i.e., below the root node) as draw or not. Today we know that opting for draw is better since we avoid useless search. How is that much different from our case here?
Evert wrote:What is correct is that the position after the queen sacrifice should be evaluated as better than the position before the sacrifice. That is really the most important point.
Yes, I agree, but the position after the sacrifice must get a much better value since it mostly restores the value of the two rooks (but also of the white bishop). How do you match that condition with a smooth scaling approach which also scales down the two rooks significantly, even if the scaling factor is smaller with 7 instead of 8 enemy pawns? Maybe I misunderstood your scaling formula.
Evert wrote:
Scaling down based on the degree of "lockedness" of the position does not appear attractive to me here, it may be very imprecise. In fact it might also apply to a somewhat smaller degree to the position after the queen sac, leading to the wrong decision to prefer the position without sac due to the presence of the queen material.
Depends on how much you scale by - and you can scale it to 0 if you want. What you need is eval(position after sacrifice) > eval(position before sacrifice). The difference in material value between the two is a queen (going the other way), so the scaling has to be large enough to compensate for that.
I understand what you say, but then your scaling must be very clever to match many possible cases.
Evert wrote:
My proposal only works in cases where you can be 100% sure that a piece has zero effect with the current pawn structure. If that does not apply then scaling is of course better.
Ok, if you can proof that the position is a draw, there is of course no problem with returning a draw score. However, there is a cost associated with that and it's for sure faster to simply scale if the position is "drawish or draw" than it is to distinguish between "drawish" and "draw" and it's not obvious (to me) that the program would play differently.
I only want to "prove" for single pieces that they are 100% useless with the current pawn structure. That can really be done piece by piece. If it applies to all pieces then we get a draw. But please don't mix it up: I want to address the scores for pieces, not for the whole position. For instance, after the queen sacrifice the rook evaluation would immediately change.
Evert wrote:
But then I would apply scaling to each single piece (QRBN), not to the whole position value.
I don't understand. The position evaluation is the sum of piece-specific terms. How is scaling each of those independently different from just scaling the whole thing?
The reason is that I would only scale if I am not sure. To stay with our example, I would be 100% sure for both rooks and both bishops but maybe I could scale the queen value down. In another case there could be two or more pieces to be scaled (and not necessarily with the same factor). Also scaling would not be applied to kings and pawns. Therefore you can clearly get a different result this way compared to scaling the whole position uniformly.

Of course your approach is obviously not bad for the given example, and I would not be surprised if it performs well even in many other cases. Still I believe that scaling is not the optimal solution for locked positions in general. I respect all the other opinions which also seem to form the majority here. Nevertheless I see nothing wrong in thinking about a different approach which tries to be more exact than a heuristic like scaling.

I also understand Don's argument that dealing with very specific and rare cases may have negative impact on the evaluation of the vast majority of "normal" cases. There is not much to say against it, apart from asking: isn't the vast majority of tree positions that we visit during our search somehow "not normal"? And isn't any kind of specific endgame knowledge we implement in our eval function subject to the same consideration? And isn't it one property of the stronger programs that they are better in evaluating the non-standard cases?

Sven

tano-urayoan
Posts: 638
Joined: Thu Aug 30, 2007 6:23 pm
Location: San Juan, Puerto Rico

Re: Idea for recognizing fortress/encouraging progress

Post by tano-urayoan » Sat May 18, 2013 6:00 pm

Here is another position [d] 8/8/8/1k3p2/p1p1pPp1/PpPpP1Pp/1P1P3P/QNK2NRR w - - 0 1

Sven
Posts: 3830
Joined: Thu May 15, 2008 7:57 pm
Location: Berlin, Germany
Full name: Sven Schüle
Contact:

Re: Idea for recognizing fortress/encouraging progress

Post by Sven » Sun May 19, 2013 12:25 am

Any idea how to reach that position?

User avatar
Evert
Posts: 2924
Joined: Fri Jan 21, 2011 11:42 pm
Location: NL
Contact:

Re: Idea for recognizing fortress/encouraging progress

Post by Evert » Sun May 19, 2013 8:44 am

Sven Schüle wrote:Any idea how to reach that position?
Don't think that's the biggest problem. I mean, it requires a very deliberate and implausible sequence of moves, but it doesn't look impossible to me (it'd be a different story if there were a white dark-squared bishop around somewhere).

My main problem with this one is that I'm not convinced that the position is actually won for white after breaking it open. That is to say, if black is given the opportunity to create an unstoppable passer (and there is no way for white to open the position without doing that) I'm more inclined to think that the position will be won for black than for white.

Ultimately this sort of position isn't very interesting though. There's a very simple and quick way to push the engine to make "progress" (open the position), as already discussed. This doesn't help with the more general problem of fortress positions though and will do nothing in terms of actual playing strength/analysis abilities.

User avatar
Desperado
Posts: 638
Joined: Mon Dec 15, 2008 10:45 am

Re: Idea for recognizing fortress/encouraging progress

Post by Desperado » Sun May 19, 2013 9:54 am

Sven Schüle wrote:Any idea how to reach that position?
:lol:

[pgn]
[Event "?"]
[Site "?"]
[Date "2013.05.19"]
[Round "?"]
[White "Mission"]
[Black "Impossible"]
[Result "*"]
[ECO "A05"]
[PlyCount "126"]

1. Nf3 Nf6 2. Ne5 Ng8 3. Ng6 Nf6 4. Nxh8 Ng8 5. Ng6 Nf6 6. Nxf8 Ng8 7. Ne6 Nf6
8. Nxd8 Ng8 9. Nc6 Nf6 10. Nxb8 Ng8 11. Nc6 Nf6 12. Na5 Ng8 13. Nc4 Nf6 14. Nb6
Ng8 15. Nxa8 Nf6 16. Nb6 Ng8 17. Nxc8 Nf6 18. Nb6 Ne4 19. Nd5 Nc5 20. Ne3 Nb3
21. Nf5 Nxc1 22. Ne3 Nb3 23. Nd5 Nc5 24. e3 Kd8 25. Ba6 Nxa6 26. Nbc3 Nb8 27.
Rc1 Na6 28. Nb1 Kc8 29. c3 Kd8 30. a3 Kc8 31. Qb3 Kd8 32. Qa2 Kc8 33. Qa1 Kd8
34. Ke2 Kc8 35. Rcg1 Kd8 36. Kd1 Kc8 37. Kc1 Kd8 38. Nf4 Kc8 39. Nh5 Kd8 40.
Ng3 Kc8 41. Nf1 Nb4 42. g3 Na2+ 43. Qxa2 a5 44. Qa1 a4 45. f4 b5 46. Rg2 b4 47.
Rgg1 b3 48. Rg2 c5 49. Rgg1 c4 50. Rg2 d5 51. Rgg1 d4 52. Rg2 d3 53. Rgg1 e5
54. Rg2 e4 55. Rgg1 f5 56. Rg2 g5 57. Rgg1 g4 58. Rg2 h5 59. Rgg1 h4 60. Rg2 h3
61. Rgg1 Kb7 62. Kd1 Kb6 63. Kc1 Kb5 * [/pgn]

User avatar
Don
Posts: 5106
Joined: Tue Apr 29, 2008 2:27 pm

Re: Idea for recognizing fortress/encouraging progress

Post by Don » Sun May 19, 2013 12:28 pm

hgm wrote:Usually it is bad to evaluate drawn positions as exactly zero, as there are nearly won draw positions as well as nearly lost draw positions. And it pays to be able to distinguish the two.
I believe Komodo does a good job at that. Yes, probably it could do better but where other programs score exactly zero Komodo tries to distinguish an easy draw from a difficult draw.

Assuming that the positions in question really are draws however you can get yourself in trouble though because you could go from a position that really does have at least a slight chance of being won (even with best play) to a true dead draw.

It comes down to what a score like 0.10 really means and how it's compared to other scores in the tree. Chess evaluation functions are one dimensional unfortunately, they don't express two dimensional concepts very well. For example a score of 0.50 might come from a highly risky position or it might be a permanent but not overwhelming advantage that gives you reasonable winning chances.

I don't understand your argument. It is scores that are exactly zero that lead to endless shuffling, as the pieces will diffuse randomly over the board. And the whole point is to have the leading engine avoid that the position can be closed, not what happens after it is closed. This is why using the 50-move counter to detect it is pointless.

I expect Evert's suggestion to work very well. The drawishness correction is probably only needed with >=6 bloacked Pawns. This need not be very expensive. The Pawn hash can contain a 2-bit field to signal <6, 6, 7 or 8 blocked Pawns. In most positions it would be set to <6, and the overhead remains limited to testing the field. Only when it specifies >= 6 you would call an extra evaluation routine to determine the scaling, based on present piece types.

And if you start in a locked position, and are enough ahead to 'sacrifice yourself out of the cage', the search will find that, and the evaluation will jump up by the sacrifice because the discount is no longer applied, or strongly reduced. Sacrificing Q in the position of the OP will raise the score from +5+5+9 = +19 discounted by a factor 16 (say) for 8 blocked Pawns (so +1.2) to +5+5+1 = +11 discounted by only a factor 1.5 (because only 6 blocked Pawns, an open file, and a strong Rook majority), i.e. +7. A huge incentive for the Q sac.
Capital punishment would be more effective as a preventive measure if it were administered prior to the crime.

User avatar
Don
Posts: 5106
Joined: Tue Apr 29, 2008 2:27 pm

Re: Idea for recognizing fortress/encouraging progress

Post by Don » Sun May 19, 2013 12:35 pm

hgm wrote:I don't think it is bad if this requires a complex algorithm. As long as it is not invoked needlessly. In my proposal the simplistic head-to-head counting would only be used only as a filter, to cheaply exclude positions where no subtlety is called for. As this goes through Pawns structure, the cost of deciding in a more precise way which structures can be opened easily (by Pawn moves alone) will be negligible anyway, because it is hashed in the Pawn hash with a large hit rate. Only positions with Pawn structures flagged there as 'dangerous' would invoke the complex algorithm. But for such positions that is really worthwhile, because otherwise they would be completely mis-evaluated.
I would also like to say that a completely locked pawn structure does not define what a closed position is. I would agree that it is a minor subset.

A very simple algorithm is to count 8 rams as 100% closed, 7 rams as 90% closed and so on. Then you multiply the final score by some coefficient to reflect drawishness. For example in the 8 ram case you could multiply the score by 0.5 to reflect a much larger like-hood of a draw. It seems to make a lot of sense but that did not seem to be effective for us. It also doesn't address the issue of technique except to avoid such positions when you have the advantage but in closed positions there is much more to it. You also want to play them well if you are in those positions.
Capital punishment would be more effective as a preventive measure if it were administered prior to the crime.

User avatar
Don
Posts: 5106
Joined: Tue Apr 29, 2008 2:27 pm

Re: Idea for recognizing fortress/encouraging progress

Post by Don » Sun May 19, 2013 12:47 pm

Don wrote:
hgm wrote:I don't think it is bad if this requires a complex algorithm. As long as it is not invoked needlessly. In my proposal the simplistic head-to-head counting would only be used only as a filter, to cheaply exclude positions where no subtlety is called for. As this goes through Pawns structure, the cost of deciding in a more precise way which structures can be opened easily (by Pawn moves alone) will be negligible anyway, because it is hashed in the Pawn hash with a large hit rate. Only positions with Pawn structures flagged there as 'dangerous' would invoke the complex algorithm. But for such positions that is really worthwhile, because otherwise they would be completely mis-evaluated.
I would also like to say that a completely locked pawn structure does not define what a closed position is. I would agree that it is a minor subset.

A very simple algorithm is to count 8 rams as 100% closed, 7 rams as 90% closed and so on. Then you multiply the final score by some coefficient to reflect drawishness. For example in the 8 ram case you could multiply the score by 0.5 to reflect a much larger like-hood of a draw. It seems to make a lot of sense but that did not seem to be effective for us. It also doesn't address the issue of technique except to avoid such positions when you have the advantage but in closed positions there is much more to it. You also want to play them well if you are in those positions.
P.S. It is clear that this definition is rather simplistic because pawns do not have to be locked together in the so called "ram" formation to have most of the characteristics of a closed position.
Capital punishment would be more effective as a preventive measure if it were administered prior to the crime.

Post Reply