Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Movegenerator and prevent check

Author: KarinsDad

Date: 13:49:26 06/13/99

Go up one level in this thread


On June 13, 1999 at 13:16:37, Francis Monkman wrote:

>
>On June 13, 1999 at 12:05:27, KarinsDad wrote:
>
>
>>Then, when I am generating moves, I check the pin byte of each piece for
>>non-zero. If it is non-zero, then the piece is pinned and has limited movement,
>>based on the value of the pin byte.
>>
>>However, the way I do it seems like it may take a slightly shorter amount of
>>time on average since not every piece or move is checked anyway either (just a
>>few near the king), so the cutoff would have to be one or two moves for this
>>system to be slower. On average, I think it is somewhat faster (but I have not
>>done any tests to prove it).
>>
>>KarinsDad :)
>
>I used a similar pin scheme in my 68000-assembler code. What I don't get is when
>you
>say "just a few near the king" -- surely a king on say, h1, can have a piece on
>say, b7
>pinned against it by a queen/bishop on a8?
>
>All best
>Francis

By that statement "a few near the king", I meant that you have to only make "a
few comparisons near the king", i.e. at most 8 comparisons and at least 3
comparisons, all of them based on where the king is located (i.e. you only have
to check ranks, files, and diagonals from the king).

So, say I have the following position (which corresponds to your example):

q......k
.N......
........
..N....n
........
........
.......n
b.....RK

Due to the location of the white king, I know exactly how many comparisons (3)
to make and in which directions (west, northwest, north).

So, I take the bitboards for the king in those three directions (I do not need
the one diagonal direction set of bitboards because my king is in the corner)
and calculate the next closest piece.

I do this by pretending with the bitboards that the king is a queen and it can
actually travel to the edge of the board unless something is in the way (i.e. I
use my queen macros to access bitboard information as opposed to my king
macros).

So, in the case of the diagonal comparison, I get a bitboard back of 00111110 as
the set of locations that the "long ranging" king can move to. That means that
either there is a same colored piece on b7, or a different colored piece on c6.
I check c6 and if there is a piece there, then there is no pin. If not, then I
was stopped by one of my own pieces on b7.

I then pretend that piece is not there (by removing it from a copy of the
original bitboard) and check again. This time, I get a result back of 11111110.
This means that either there is a different colored piece on a8 or there is no
pin. I check a8, find out it’s a different colored queen, and voila, a pin. If
the queen was not there, I would have still gotten a 11111110 result, however,
no piece on the square would have meant no pin.

I do the same thing with the other two directions and find out that even though
there are multiple pieces in those directions (in the example above), that
either the colors are incorrect, or the pieces are not long range attackers in
the proper direction.

KarinsDad :)



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.