discovered check definition

Discussion of chess software programming and technical issues.

Moderator: Ras

tvrzsky
Posts: 128
Joined: Sat Sep 23, 2006 7:10 pm
Location: Prague

Re: discovered check definition

Post by tvrzsky »

No need for diagram
The idea is
Rd1 attacks king at d8 and King at c1 attacks rook at b2 at the same time.
Uri
Hmmm, I am afraid I do not see anything relative to discovered check here ... :(
Uri Blass
Posts: 10800
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: discovered check definition

Post by Uri Blass »

tvrzsky wrote:
No need for diagram
The idea is
Rd1 attacks king at d8 and King at c1 attacks rook at b2 at the same time.
Uri
Hmmm, I am afraid I do not see anything relative to discovered check here ... :(
The rook move from a1 to d1 when white castles when the king that is the moving piece in castling attack the rook at b2.

8 
7 
6 
5 
4 
3 
2 
1 
abcdefgh

3k4/8/8/8/8/8/1r6/R3K3 w Q - 0 1

It can be considered as discovered check because the moving piece(considered to be the king) is not the piece that threats the check.

Uri
User avatar
hgm
Posts: 28354
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: discovered check definition

Post by hgm »

Yes, this would be effectively the same, and actually more likely to occur in a game than what I had in mind:

8 
7 
6 
5 
4 
3 
2 
1 
abcdefgh

8/8/8/8/8/8/1r6/R3K1k1 w Q -

What it has in common with a discovered check is that the white Rook, which was formerly blocked by its own King, now has unhindred passage to the enemy King, and that this was achieved by moving the blocking piece out of the way, and attacking something else with that piece (namely the black Rook).

Interesting thing is that this can only happen to a Rook, and only in this particular position. Every other piece a King might attack after castling (and did not attack before) would actually make the castling illegal by either checking the king before or after it, or attacking the square the King has to pass. And of course the King can also not capture something during castling.

The double discovered check is:

8 
7 
6 
5 
4 
3 
2 
1 
abcdefgh

8/8/5k2/4pP2/8/2B2R2/8/3K4 w - e6
1. Pxe6++
Uri Blass
Posts: 10800
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: discovered check definition

Post by Uri Blass »

hgm wrote:Yes, this would be effectively the same, and actually more likely to occur in a game than what I had in mind:

8 
7 
6 
5 
4 
3 
2 
1 
abcdefgh

8/8/8/8/8/8/1r6/R3K1k1 w Q -

What it has in common with a discovered check is that the white Rook, which was formerly blocked by its own King, now has unhindred passage to the enemy King, and that this was achieved by moving the blocking piece out of the way, and attacking something else with that piece (namely the black Rook).

Interesting thing is that this can only happen to a Rook, and only in this particular position. Every other piece a King might attack after castling (and did not attack before) would actually make the castling illegal by either checking the king before or after it, or attacking the square the King has to pass. And of course the King can also not capture something during castling.
This is not exactly that it can only happen in the particular position

It can happen also in the following position(of course capturing the rook immediatly instead of castling is simpler.

Uri

8 
7 
6 
5 
4 
3 
2 
1 
abcdefgh

8/8/8/8/8/8/7r/k3K2R w K - 0 1
User avatar
hgm
Posts: 28354
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: discovered check definition

Post by hgm »

Uri Blass wrote:... of course capturing the rook immediatly instead of castling is simpler.
This is why I did not count it. The danger of a discovered check is determined by if you can threaten something that could not be captured before.

E.g., the following is rather harmless:

8 
7 
6 
5 
4 
3 
2 
1 
abcdefgh

8/8/8/8/8/7b/8/k5KR w

Although 1. Kh2+ is undeniably a discovered check, there is no need to treat it much different from an ordinary check. (A King cannot be x-rayed, so the number of attacks on the Bishop does not increase.) With black to move it would still be special in the sense that it would be unwise to venture with anything onto e2, e3, f3, g3.

Of course there are plenty other check threats putting a second piece under attack with a direct check (e.g. forks). But these still fall in an on the average less dangerous class: against them the evasion mode 'capturing the attacker' is available, (and thus pre-emptively defending the square from which the fork can be given). When two different pieces attack two different victims, neither pure withdrawal nor capturing the attacker can save you.

I guess one should take all this into account when deciding how to handle being in check in a horizon node. If it is a bare check, you might not want to waste time on extending it, and just stand pat, as having the move should solve it in the vast majority of cases. (It would be nice to statically recognize checkmate, though, as this would not require an extension and thus be comparatively cheap.) Only if it is a check+threat it might pay off to reverse the burdon of proof, and give the extension to see if any check evasions exist that solve the threat as well. (And if not, how bad the threat really is.)
User avatar
hgm
Posts: 28354
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

King-'poof' pruning

Post by hgm »

One more thought:

Perhaps a good way to treat d=0 in-check positions is a trick similar to null move:

Rather than trying every evasion, make the King do a 'disappearance act'. Just remove it from the board, and give the move to the opponent. If this fails high, classify the check as harmless and stand pat, assuming that having the move will allow you to find an evasion that does not make you end up worse than the current evaluation.

You might only want to do this where you don't have a good/equal capture on the checker; if you have one, you might simply ignore the check and stand pat. Or, if stand pat is not enough, try the good capture first.

If you are in check in a fail-low horizon node (CurEval <= Alpha) you don't want to do anything special. If you were not in check (and have no captures that save the day) you would gracefully accept the fail low. As being in check doesn't make the situation any better, there is no reason to handle it differently here. So this 'King-poof pruning' only makes sense if CurEval >= Beta.
Uri Blass
Posts: 10800
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: King-'poof' pruning

Post by Uri Blass »

hgm wrote:One more thought:

Perhaps a good way to treat d=0 in-check positions is a trick similar to null move:

Rather than trying every evasion, make the King do a 'disappearance act'. Just remove it from the board, and give the move to the opponent. If this fails high, classify the check as harmless and stand pat, assuming that having the move will allow you to find an evasion that does not make you end up worse than the current evaluation.

You might only want to do this where you don't have a good/equal capture on the checker; if you have one, you might simply ignore the check and stand pat. Or, if stand pat is not enough, try the good capture first.

If you are in check in a fail-low horizon node (CurEval <= Alpha) you don't want to do anything special. If you were not in check (and have no captures that save the day) you would gracefully accept the fail low. As being in check doesn't make the situation any better, there is no reason to handle it differently here. So this 'King-poof pruning' only makes sense if CurEval >= Beta.
I cannot evaluate positions with no king and my evaluation function assume that there is a king in the board(how do you evaluate king safety without having king square when no pawns near the king or pieces that attack squares near the king mean that the king is not safe?).

Maybe you mean calculate the material gain by captures after removing the king and in case that the opponent have not something strong assume that the opponent does not win but it seems to me too dangerous and there are checks that you method may not detect as checks with threat

Here is one example(afrer removing the king white has no capture but the check is decisive):

8 
7 
6 
5 
4 
3 
2 
1 
abcdefgh

rnbqkbnr/ppppp1p1/7p/7B/4p3/7N/PPPP1PPP/RNBQK2R b KQkq -
Uri Blass
Posts: 10800
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: discovered check definition

Post by Uri Blass »

hgm wrote:
Uri Blass wrote:... of course capturing the rook immediatly instead of castling is simpler.
This is why I did not count it. The danger of a discovered check is determined by if you can threaten something that could not be captured before.

E.g., the following is rather harmless:

8 
7 
6 
5 
4 
3 
2 
1 
abcdefgh

8/8/8/8/8/7b/8/k5KR w

Although 1. Kh2+ is undeniably a discovered check, there is no need to treat it much different from an ordinary check. (A King cannot be x-rayed, so the number of attacks on the Bishop does not increase.) With black to move it would still be special in the sense that it would be unwise to venture with anything onto e2, e3, f3, g3.

Of course there are plenty other check threats putting a second piece under attack with a direct check (e.g. forks). But these still fall in an on the average less dangerous class: against them the evasion mode 'capturing the attacker' is available, (and thus pre-emptively defending the square from which the fork can be given). When two different pieces attack two different victims, neither pure withdrawal nor capturing the attacker can save you.

I guess one should take all this into account when deciding how to handle being in check in a horizon node. If it is a bare check, you might not want to waste time on extending it, and just stand pat, as having the move should solve it in the vast majority of cases. (It would be nice to statically recognize checkmate, though, as this would not require an extension and thus be comparatively cheap.) Only if it is a check+threat it might pay off to reverse the burdon of proof, and give the extension to see if any check evasions exist that solve the threat as well. (And if not, how bad the threat really is.)
Movei statically recognize checkmates for a long time.
It is obvious for me that when there is a checkmate I am interested to know if it is a mateinside the evaluation function.

Uri
User avatar
hgm
Posts: 28354
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: King-'poof' pruning

Post by hgm »

Good point. But also in this respect it is similar to null-move pruning. The latter fails if there is ZugZwang, i.e. all moves are worse than doing nothing. The usual fix is not to do NMP if the number of moves is too low, usually estimated by looking at the number of pieces available to do these moves. So you refrain from NMP if you do not at least have one slider. (An Joker lost a game in OW2 because even that was not enough, when it had a single Bishop that had to defend two key squares not on the same diagonal. :cry: )

With King-poof pruning the King disappearance symbolizes a withdrawal. With not enough safe squares around the King it can no longer be taken for granted that there is a good withdrawal, and you would refrain from KPP. You somehow would have to count withdrawal possibilities anyway, in the static determination if this is a checkmate or not. With zero evasions, it is a mate. With one evasion, nothing can be gained by KPP, as you might as well play that evasion. That covers this case.

Note that interposing is a kind of suspect evasion mode, as the interposed piece is in the line of capture. So I would be inclined also not to trust two ways of interposing. With one interposing possibility, and one withdrawal (or one withdrawal and a bad capture on the checker) I would be inclined to do the KPP in stead. And of course with two withdrawals.
Uri Blass
Posts: 10800
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: discovered check definition

Post by Uri Blass »

hgm wrote:
Uri Blass wrote:... of course capturing the rook immediatly instead of castling is simpler.
This is why I did not count it. The danger of a discovered check is determined by if you can threaten something that could not be captured before.

E.g., the following is rather harmless:

8 
7 
6 
5 
4 
3 
2 
1 
abcdefgh

8/8/8/8/8/7b/8/k5KR w

Although 1. Kh2+ is undeniably a discovered check, there is no need to treat it much different from an ordinary check. (A King cannot be x-rayed, so the number of attacks on the Bishop does not increase.) With black to move it would still be special in the sense that it would be unwise to venture with anything onto e2, e3, f3, g3.

Of course there are plenty other check threats putting a second piece under attack with a direct check (e.g. forks). But these still fall in an on the average less dangerous class: against them the evasion mode 'capturing the attacker' is available, (and thus pre-emptively defending the square from which the fork can be given). When two different pieces attack two different victims, neither pure withdrawal nor capturing the attacker can save you.

I guess one should take all this into account when deciding how to handle being in check in a horizon node. If it is a bare check, you might not want to waste time on extending it, and just stand pat, as having the move should solve it in the vast majority of cases. (It would be nice to statically recognize checkmate, though, as this would not require an extension and thus be comparatively cheap.) Only if it is a check+threat it might pay off to reverse the burdon of proof, and give the extension to see if any check evasions exist that solve the threat as well. (And if not, how bad the threat really is.)
I found a better example

8 
7 
6 
5 
4 
3 
2 
1 
abcdefgh

5r2/8/3n4/8/8/8/5n2/k3K2R w K - 0 1

castling with discovered check is the only way to draw.

Uri