Special cases
Moderators: hgm, Rebel, chrisw
-
- Posts: 7220
- Joined: Mon May 27, 2013 10:31 am
Special cases
What is the fastest way to detect if a piece on a1, h1, a8 or h8 is pinned ?
-
- Posts: 718
- Joined: Fri Mar 20, 2009 8:59 pm
Re: Special cases
Am I missing something?
return(false); ?
return(false); ?
-
- Posts: 27809
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: Special cases
Depends on the game.
In (Maka) Dai Dai Shogi there appears a piece called Hook Mover, which moves like a Rook that can turn one corner. So with a black Hook Mover on a8, a white Knight on a1 would be pinned against the white King on e1, there are no pieces between the latter and the rest of the a-file is empty. (And the white King is safely tucked away behind Pawns, so that the othe possible path from a8 to e4 is also blocked.)
[d]r5k1/1ppppppp/8/8/8/1PB5/2PPPPPP/N3K3 w
The Rook represents a Hook Mover, pinning Na1
In (Maka) Dai Dai Shogi there appears a piece called Hook Mover, which moves like a Rook that can turn one corner. So with a black Hook Mover on a8, a white Knight on a1 would be pinned against the white King on e1, there are no pieces between the latter and the rest of the a-file is empty. (And the white King is safely tucked away behind Pawns, so that the othe possible path from a8 to e4 is also blocked.)
[d]r5k1/1ppppppp/8/8/8/1PB5/2PPPPPP/N3K3 w
The Rook represents a Hook Mover, pinning Na1
Last edited by hgm on Fri Dec 18, 2015 10:21 pm, edited 4 times in total.
-
- Posts: 20943
- Joined: Mon Feb 27, 2006 7:30 pm
- Location: Birmingham, AL
Re: Special cases
just use this procedure:Henk wrote:What is the fastest way to detect if a piece on a1, h1, a8 or h8 is pinned ?
return 0;
a piece on a corner can not possibly be pinned on anything. There is no square behind it along any direction for it to be pinned to anything at all. Are you sure this is what you intended to ask???
-
- Posts: 718
- Joined: Fri Mar 20, 2009 8:59 pm
Re: Special cases
> Depends on the game.
Haha very clever.
In the absence of a variant command, I was assuming chess
Haha very clever.
In the absence of a variant command, I was assuming chess
-
- Posts: 7220
- Joined: Mon May 27, 2013 10:31 am
Re: Special cases
Just a bad joke. And to be sure I was not overlooking something.
-
- Posts: 2929
- Joined: Sat Jan 22, 2011 12:42 am
- Location: NL
Re: Special cases
This is actually very tricky, but fortunately you can skip the test in many cases.
First of all, you need to know whether a piece that can do the pinning has been captured. You know this just by inspecting the board. Another precondition is that the king needs to be on a ray with the candidate pinnee (as per usual). Then you need to know where the player placed his captured pieces. If they're beside the board and on the ray with no other obstacles in between (clock, coffee-cup, other pieces), then you can mark the corner piece as "pinned", but if they're not on the ray (or the player placed the captured pieces back in the box), then clearly the piece is not pinned.
As I said though, this is rather difficult to work out for a computer.
First of all, you need to know whether a piece that can do the pinning has been captured. You know this just by inspecting the board. Another precondition is that the king needs to be on a ray with the candidate pinnee (as per usual). Then you need to know where the player placed his captured pieces. If they're beside the board and on the ray with no other obstacles in between (clock, coffee-cup, other pieces), then you can mark the corner piece as "pinned", but if they're not on the ray (or the player placed the captured pieces back in the box), then clearly the piece is not pinned.
As I said though, this is rather difficult to work out for a computer.
-
- Posts: 879
- Joined: Mon Dec 15, 2008 11:45 am
Re: Special cases
First check if the piece in the corner is a pawn, everything else is easyHenk wrote:What is the fastest way to detect if a piece on a1, h1, a8 or h8 is pinned ?
-
- Posts: 4833
- Joined: Sun Aug 10, 2008 3:15 pm
- Location: Philippines
Re: Special cases
First you need to check if the king is not missing . Second check if there are h1, a8 and h8 squares on the board .Henk wrote:What is the fastest way to detect if a piece on a1, h1, a8 or h8 is pinned ?
-
- Posts: 879
- Joined: Mon Dec 15, 2008 11:45 am
Re: Special cases
Hi,Ferdy wrote:First you need to check if the king is not missing . Second check if there are h1, a8 and h8 squares on the board .Henk wrote:What is the fastest way to detect if a piece on a1, h1, a8 or h8 is pinned ?
i guess your approach is much more safe. I realized that my test has a lack if it is done while promoting.
But don't forget that performance might be an issue too, so maybe we should do a speed check first. Maybe my hack pays off .