couple of questions regaring king safety ?

Discussion of chess software programming and technical issues.

Moderator: Ras

MahmoudUthman
Posts: 237
Joined: Sat Jan 17, 2015 11:54 pm

couple of questions regaring king safety ?

Post by MahmoudUthman »

1-on the wiki under "Attacking King Zone" , what is the difference between "attack units" and "square control" , they seem similar to me?
2-Is it beneficial to merge different methods mentioned on the wiki , and if so , should I calculate a value of each one and then use it as an index through the attack units variable , or should they be calculated separately and then added to form the final score and if so by what ratios ?
*for example so far I have implemented pawn shield , pawn storm , and attack units , should I expect an Elo increase if I add king tropism ?"I know that a lot of things need testing but I need to know what to expect in case I didn't get any or even lost Elo because of a bug or something"
3-I was checking SF's history to find out why it abandoned the use of KingDanger array , and I came across this :
snicolet wrote:
snicolet commented on Sep 8 2016 • edited snicolet edited this comment 10 months ago



@AlexandreMasta:
Just for reference, here is a comparison between this patch and the
current master during operations done at the end of evaluation_king
for scoring the king danger.

• this patch:

a) ensure that danger is positive
b) multiply by itself
c) shift 12 bits to the right
d) ensure that result is less than two bishops
e) shift 16 bits to the left
f) add to score

• current master:

a) ensure that attack is positive
b) ensure that result is less than 399
c) shift 2 bits to the left
d) add the address of KingDanger[0]
e) read memory
f) add to score

So basically hxim's idea and this patch replaces a memory access
by a multiplication, debunks the idea that the pseudo-sigmoid
is necessary for king danger evaluation (a capped quadratic is
sufficient), avoids a memory access, suppress an array of 400
values and gives a semantics to the order of magnitude of the
king danger score, all this with 24 less lines of code: yes, I
sincerely think this qualifies as a simplification per the guidelines https://github.com/glinscott/fishtest/w ... first-test
, where does the idea that pseudo-sigmoid
is necessary for king danger evaluation comes from and why ?
4-
Patterns
There are positions that tend to be notoriously difficult for the chess programs. One of them is a sacrifice of a minor piece on g5/g4, when it is simultaneously attacked and protected by the "h" pawns. Another one occurs after a standard Bxh7 sacrifice: White knight stands unchallenged on g5, white queen on h5, black King on g8 (positions with Kg6 are best left to the search). Hard-coding such patterns raises program's tactical awareness.
is hard coding such position beneficial Elo wise ?
5-What should the maximum -"if there should be any"- king safety score be relative to other scores for example Pieces Values ?
6-how much contribution of the king safety score should be in the endgame score ? and does it differ according to the methods "mentioned on CPW" used and the tapered evaluation calculation method ?
jdart
Posts: 4428
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: couple of questions regaring king safety ?

Post by jdart »

where does the idea that pseudo-sigmoid is necessary for king danger evaluation comes from and why
This is really encoding a common piece of chess knowledge. Something like a single Knight attacking the King is usually not significant. So "small" attacks get downgraded in value. But as more pieces are added to the attack, it becomes progressively more significant, and that increase is non-linear. But there is a limit. If you have four pieces attacking and add a fifth, you might mate faster but you are not adding so much anymore to the overall attack. The attacks become redundant.

A sigmoid function captures this intuition.

As for practically everything else you are asking: you have to measure, and tune. cpw is not the Bible and it is not going to tell exactly what is optimal, especially given that scoring terms interact and so does search and eval.

--Jon
PK
Posts: 913
Joined: Mon Jan 15, 2007 11:23 am
Location: Warsza

Re: couple of questions regaring king safety ?

Post by PK »

I did some experiments with merging different king safety approaches (Fruit-like, Stockfish-like and simple king tropism). It did not work in Rodent, with the possible exception of king tropism a la GambitFruit. Here small values added on the top of normal king safety were neutral.

As for "king attack units" and square control. King attack units really expand on square control, adding different terms. The trick is then to convert attack units into score.
jdart
Posts: 4428
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: couple of questions regaring king safety ?

Post by jdart »

I auto-tune king safety params. The formula is fairly complex but the last step is to run it through a sigmoid function.

I am sure there is room for improvement but it does seem to work, in the sense that it will attack if given an opening, but not throw away material with unsound sacs that increase the attack score.