Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: questions?

Author: Robert Hyatt

Date: 09:29:21 04/09/04

Go up one level in this thread


On April 08, 2004 at 08:21:47, Russell Reagan wrote:

>On April 08, 2004 at 07:10:29, Daniel Shawul wrote:
>
>>3.I thought i could get In_Check and Checks for free if I use attack tables.
>>But there is trouble. If i need to know whether a move checks , I need to
>>generate the attack tables which is very costy. Same applies for In_Check.
>>For example I need to know whether a move checks if i am using futility pruning.
>>So i am doing an incrementally updated checks and in_check to facilitate this.
>>Infact it is doing very fine. The in_checks require we are not in check before.
>>So I need to generate completely legal move when i am in check.
>
>If you use a board similar to 0x88 which gives you unique square relationships,
>you can detect if a move is a checking move fairly easily. Using a lookup table
>you can tell if a piece that moves to a square can potentially attack the enemy
>king. Most moves will not be able to attack the enemy king, so there is no
>reason to scan the board.
>
>For example, a white knight on f3 cannot possibly attack the black king on e8,
>so there is no need to scan the board to see if the move Nf3 checks the black
>king. If you move a white bishop to b5 and the black king is on e8, then you
>only have to scan the squares c6 and d7 to see if they are empty. Using this
>approach, you can detect potential checks and pins very efficiently.
>
>There are probably similar tricks if you can do if you use bitboards, but I'll
>let someone who has actually worked out those details talk about that, if anyone
>has done so.

This is not difficult in bitboards.  If you want to check your opponent, you do
a few tests.  Knights are obvious.  AND knight attacks[opponent-king-position]
with your knight bitboard.  A non-zero means you have a knight attacking him.

For sliders it is just as easy.  If you move a diagonal-slider to a diagonal
that intersects the king, then ask "does this slider attack the king" (rotated
bitmaps makes this attack question trivial to answer.  If it is a rank/file
slider do the same for rank/files.

Finally if a diagonal slider vacates a rank/file of the king, or a rank/file
slider (both of these exclude queens for obvious reasons) vacates a diagonal of
the king, you generate attacks of that kind of piece originating from the king
to see if you exposed the king to attack from the right kind of slider (a
discovered check).

Getting out of check is just as easy.  I did this in GenerateCheckEvasions() in
Crafty...



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.