king safety

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

CRoberson
Posts: 2056
Joined: Mon Mar 13, 2006 2:31 am
Location: North Carolina, USA

king safety

Post by CRoberson »

While riding back from Alabama with James, we had a discussion about
different concepts in handling king safety. I thought more discussion
here might be interesting. Basically, it comes down to 3 approaches:

Code: Select all

    1) Tropism.
    2) Detailed analysis of attacks and defences around the king.
    3) Some hybrid of 1 & 2.
In Telepath, I use 3 and I use 2 in NoonianChess.

On Tropism:

Code: Select all

     1) it is fast.
     2) (when mutiplying tropism value by pawn wall value), it tells you 
          not to trade pieces and to move piece toward the enemy king.
     3) From the defensive side, it says trading pieces is good and trading
         pieces closer to the king is better. 
On Detailed king zone analysis:

Code: Select all

     1) it is slow.
     2) it can help in deciding to block the attack without trading.
     3) it can help in deciding to protect squares without trading.
     4) it can tell the search to trade pieces involved in the attack.
Both have good points and some of them are exclusive to one or
the other approach, thus I use a hybrid system in Telepath. The
hybrid systems main problem is its computational requirements.

Also, there is a chess axiom that seems to be missed by both -- "the
best way to counter a wing attack is with an attack in the center".

That axiom has proven itself in many of my persoanl matches, but it
isn't really handled by the above approaches. To some degree Tropism
assists the search in handling the axiom -- if your pieces are on the
queenside and your king is in trouble, the pieces will travel past/through
the center to get to the king side.

An important point, one can easily find in chess books on the subject,
is "efficiency of defence". Seems that detailed analysis would be better
at this than tropism.

So, your use of these concepts is likely driven by your engine design
philosophy - speed or accuracy of evaluation.

Any thoughts out there?
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: king safety

Post by bob »

This is a hard problem. We are using a second-order type evaluation. We analyze king shelter (pawns) with respect to open files, weak squares, etc. Then we analyze king tropism with respect to pieces close to or attacking squares close to the king. And then we fold the two together so that one without the other is not as bad as if both parts of the equation are present (wrecked kingside with pieces bearing down).
YL84

Re: king safety

Post by YL84 »

hi,
in the earlier versions of my programme I was using a very simple type 1/ approach (tropism); it was very fast. But it was very accurate, for example due to the long range attack pieces; these pieces do not need to be near the king to create threats. Now I moved to the 2/ approach, but it is not so easy to find what combination of pieces are dangerous and what combinations are genuine. It is related to pattern recognitions or something like that.
yves
CRoberson
Posts: 2056
Joined: Mon Mar 13, 2006 2:31 am
Location: North Carolina, USA

Re: king safety

Post by CRoberson »

You could read Ed's documentation of what he did in Rebel.
http://www.top-5000.nl/authors/rebel/ch ... G%20SAFETY
You can do it without pattern recognition.
Just factor in all the issues:

Code: Select all

    1) Number of pieces attacking
    2) Type of pieces attacking
    3) Number of empty squares in front of king
    4) Number of squares in front of king occupied by enemy pieces.
    5) Number of squares around the king defended by pieces other than
        the king
    6) king position
    7) Number of pawns in front of king
      and much much more
There are several ways to factor all that into an equation.
My methods are similar to Ed's but not the same.
Alessandro Scotti

Re: king safety

Post by Alessandro Scotti »

I have had no luck with tropism, my approach is currently based on 2) but without the "detailed" part! :wink: I did design the data structures so that a more complex analysis of attack and defense is possible, but still haven't implemented it.
YL84

Re: king safety

Post by YL84 »

I think it is on Ed's page that it is said that some piece combinations are more efficient than others. But maybe it was said by Bob somewhere, sorry I can't remember :oops: . If some piece patterns are more efficient than others, you must take it into account (for exemple white Bf6, Qh6, if black has pawn g6 and no bishop it is very dangerous, so that it is part of mate threat pattern). It is just an example, in my programme I have no pattern recognition, it would be better with it. I'm currently counting the pieces which attack cases near the ennemy's king: it is not at all optimized. Lot of work to adjust the king safety, trying to have some 'typical' positions to test the programme against would be great (I suggest to take 18 combinations leading to the 18 most known mate).
Yves