hanging pieces

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

brtzsnr
Posts: 433
Joined: Fri Jan 16, 2015 4:02 pm

hanging pieces

Post by brtzsnr »

Hi!

How do you evaluate hanging pieces?

I have a list of positions on which my evaluation functions does very bad due to standing pad when when there are hanging pieces. See a sample of positions below. I tried to handle many variants, and all of them were 10-20 Elo regression:

* Current side's hanging pieces
* Both sides' hanging pieces
* Ignore pawn
* Per figure score
* Only the smallest hanging piece


I'm running out of ideas. What am I missing?



[d] 3r4/p7/1p1P1k1p/1Pp5/2n5/P4N1P/3K4/1R6 w - - 0 1


[d] 8/8/1K3Q2/5bk1/8/8/8/8 b - - 0 1


[d] rnQ5/p2p1pkp/2pPp1r1/q7/3P3P/8/Pp3PPN/R3KB1R w KQ - 0 1


[d] 5r1k/pp2ppR1/7p/2Pr4/5N1P/8/PP3P2/R3K3 b Q - 0 1


[d] r1bqk2r/3p1ppp/1pp5/3Q4/8/2b5/PP2KPPP/R1B3NR w kq - 0 1


[d] 8/6k1/1Q3p2/8/4q2P/8/4B3/7K w - - 0 1
User avatar
Rebel
Posts: 6997
Joined: Thu Aug 18, 2011 12:04 pm
Full name: Ed Schröder

Re: hanging pieces

Post by Rebel »

brtzsnr wrote:Hi!

How do you evaluate hanging pieces?
Not needed, QS will figure it out.

Another story is if the side to move forces a double attack such as (for instance) a fork. You can give a bonus for that. Works well for mine.
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: hanging pieces

Post by Sven »

In your examples 1, 3 and 6 the moving side is in check. I would not bother with these cases since you will usually extend check evasions. In examples 2 and 4 qsearch will immediately solve it. In example 5 qsearch including check at ply 0 of qsearch will solve it as well (Qe4+ followed by PxB, possibly with an intermediate queen exchange on e7). So the examples you gave are not optimal for the topic of evaluating hanging pieces in my opinion.

Nevertheless the topic exists. In my experience it is mainly the presence of two or more hanging pieces that will usually lead to misevaluations. A possible approach could be to assume that both sides will be able to save the most-valued hanging piece they currently have but might lose the second-most-valued one. However, counting this as a material loss would be quite dangerous since you do not know anything about the value of other pieces that would get captured in that context. And extending one ply if the moving side has at least two hanging pieces might lead to a tree explosion. So the only thing that seems to be acceptable would be a positional penalty for hanging pieces. That would correctly express that it is often a disadvantage to have hanging pieces while you are unable to give a serious statement about the expected loss.

In my engines so far I never cared about hanging pieces. Whenever I tried I did not get satisfying results.
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: hanging pieces

Post by Ferdy »

brtzsnr wrote:Hi!

How do you evaluate hanging pieces?
Try to define it this way. A hanging piece is a piece of the "side not to move" that is not protected and is attacked by the "side to move".

Qf6 is hanging.
[d]8/8/1K3Q2/5bk1/8/8/8/8 b - - 0 1
User avatar
Rebel
Posts: 6997
Joined: Thu Aug 18, 2011 12:04 pm
Full name: Ed Schröder

Re: hanging pieces

Post by Rebel »

Sven Schüle wrote: In my engines so far I never cared about hanging pieces. Whenever I tried I did not get satisfying results.
Same here.

However you can use it (in a careful way) in case of a static reduction.

Main thought is to lower the score with the second highest piece that hangs divided by two and if it's below ALPHA grant a reduction. The idea behind the reduction is that if 2 pieces are hanging you (in most cases) will lose at least one.

I can provide the pseudo code, it is still good for some 20-30 elo, that is, in mine.
brtzsnr
Posts: 433
Joined: Fri Jan 16, 2015 4:02 pm

Re: hanging pieces

Post by brtzsnr »

Ferdy wrote:
brtzsnr wrote:Hi!

How do you evaluate hanging pieces?
Try to define it this way. A hanging piece is a piece of the "side not to move" that is not protected and is attacked by the "side to move".

Qf6 is hanging.
[d]8/8/1K3Q2/5bk1/8/8/8/8 b - - 0 1

Hi, Fernando!

This particular position is bad because, as others pointed out, it's handled by QS. Somehow, it passed my filters (maybe I forgot to run QS).
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: hanging pieces

Post by Ferdy »

brtzsnr wrote:
Ferdy wrote:
brtzsnr wrote:Hi!

How do you evaluate hanging pieces?
Try to define it this way. A hanging piece is a piece of the "side not to move" that is not protected and is attacked by the "side to move".

Qf6 is hanging.
[d]8/8/1K3Q2/5bk1/8/8/8/8 b - - 0 1

Hi, Fernando!

This particular position is bad because, as others pointed out, it's handled by QS. Somehow, it passed my filters (maybe I forgot to run QS).
It is just an example to illustrate my point. My name is Ferdinand not Fernando :).