large king safety scores

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

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

Re: large king safety scores

Post by Don »

Adam Hair wrote:Don, I hope you don't mind this inane and off-topic response:

"Your superior intellect is no match for our puny weapons." - Kang and Kudos
Is that reference correct? Good, I will fix my signature to give proper credit!

Don
Capital punishment would be more effective as a preventive measure if it were administered prior to the crime.
zamar
Posts: 613
Joined: Sun Jan 18, 2009 7:03 am

Re: large king safety scores

Post by zamar »

diep wrote:
zamar wrote:If white's king is on the fifth rank in a middlegame positions and queens are still on board, I'd say that >99% of cases the game is lost. So penalty of one rook seems fully justified for me. Search should be able to handle the rest <1% of cases.
We already realized you never built your own program.
So? You think that if one doesn't build his own house from scratch, he is not supposed to talk about it?

Let's check what Stockfish has to say about the position:

position fen r3k1nr/pppb1ppp/8/4p1K1/8/8/P1P2PPP/q1BQ1BNR w kq - 0 1
eval
Eval term | White | Black | Total
| MG EG | MG EG | MG EG
---------------------+-------------+-------------+---------------
Material, PST, Tempo | --- --- | --- --- | -4.87 -4.42
Material imbalance | --- --- | --- --- | 0.71 0.71
Pawns | --- --- | --- --- | -0.56 -0.41
Knights | 0.00 0.00 | 0.00 0.00 | +0.00 +0.00
Bishops | 0.00 0.00 | 0.00 0.00 | +0.00 +0.00
Rooks | 0.00 0.00 | -0.45 0.00 | +0.45 +0.00
Queens | 0.00 0.00 | 0.00 0.00 | +0.00 +0.00
Mobility | 0.26 0.27 | 0.23 0.32 | +0.03 -0.05
King safety | -5.44 -0.24 | 1.33 -0.08 | -6.77 -0.16
Threats | 0.08 0.20 | 0.15 0.39 | -0.08 -0.20
Passed pawns | 0.00 0.00 | 0.00 0.00 | +0.00 +0.00
Unstoppable pawns | --- --- | --- --- | +0.00 +0.00
Space | 0.16 0.00 | 0.22 0.00 | -0.07 +0.00
---------------------+-------------+-------------+---------------
Total | --- --- | --- --- | -11.03 -4.47
Joona Kiiski
diep
Posts: 1822
Joined: Thu Mar 09, 2006 11:54 pm
Location: The Netherlands

Re: large king safety scores

Post by diep »

jdart wrote:I currently only use PSQ for the King in the endgame, so that doesn't apply here.

--Jon
Ah then it's even closer than i thought.

1.085 from Diep + 0.65 == 1.735 pawn penalty versus 1.38 for Arasan.
Just 0.35 pawn difference.
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: large king safety scores

Post by lucasart »

diep wrote:
jdart wrote:I currently only use PSQ for the King in the endgame, so that doesn't apply here.

--Jon
Ah then it's even closer than i thought.

1.085 from Diep + 0.65 == 1.735 pawn penalty versus 1.38 for Arasan.
Just 0.35 pawn difference.
Just to clarify I was talking only about the king safety of white. Black also has a penalty for king safety, as the king is in the center and has a damaged pawn shield,, and the white queen is eyeing the d7 square (this is static of couse black plays OOO and all is gone).
So the real total is going to be
[KingSafety(White)-KingSafety(Black) + KingPST(Opening,White)-KingPST(Opening,Black)] * (1-game_phase)
where game_phase is a float between 0 and 1 (0=opening 1=endgame)
Whitch means the scores I annouced is comparable to Stockfish's 5.44
yl84
Posts: 21
Joined: Tue Sep 07, 2010 6:37 pm

Re: large king safety scores

Post by yl84 »

After Kh4, my king safety seems to be near 2 pawns at depth 1. But with increasing search depths, the total eval seems to be around 8 pawns. Black may convert their attack on the king into a material gain, in some lines. So that around 4 pawns for king safety seem to be very nice in this particular position;White are lost.
The side to move can have a large effect in king safety; if it was Black's turn to move in the initial position, my programme gives 10 pawns for Black. So the side to move is around 2 pawns here. It is not so large since Black's pieces are not really ready to attack White's king.
Yves
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: large king safety scores

Post by lucasart »

yl84 wrote: The side to move can have a large effect in king safety; if it was Black's turn to move in the initial position, my programme gives 10 pawns for Black.
Indeed. I tried several ways of modifying my king safety eval to account for side to move. But no success so far (testing in 1000 games and looking for an improvement over 1 stdev at least).
There must be a way of doing this right, but so far, I haven't found it.
yl84
Posts: 21
Joined: Tue Sep 07, 2010 6:37 pm

Re: large king safety scores

Post by yl84 »

I think that side to move bonus should be related to the number of pieces which can be added quickly to the attack. But how to measure it? Is it worth coding?
Yves
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: large king safety scores

Post by lucasart »

yl84 wrote:I think that side to move bonus should be related to the number of pieces which can be added quickly to the attack.
Yes, my king safety in a nutshell is count * sum(weight). so if it's our turn to play decrement count by 1 (if not already null): that was my first attempt. it failed!
Then I tried another condition: my turn to move + my king can retreat => decrement count. Also failed!
But how to measure it?
By playing lots of games at super fast time control, with a nice parralelized command line tool, like cutechess-cli. *and* to avoid hasty conclusions if the score is within the error bar (this is so tempting and so dangerous).
Is it worth coding?
The coding part is quite trivial and takes less than a minute to write, and perhaps another 2 minutes to debug in a few positions to make sure it works. Then the real pain begins: hours and hours of testing...
yl84
Posts: 21
Joined: Tue Sep 07, 2010 6:37 pm

Re: large king safety scores

Post by yl84 »

I can't say is my king safety is efficient. The parameters are not tuned. Maybe it make the programme weaker presently. I should put parameter tuning on my to-do list.
Yves