Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: check detection

Author: Bas Hamstra

Date: 17:29:40 08/20/99

Go up one level in this thread


Hello Scott,

I have two versions of programs which I both work on. One maintains incremental
attacks. That way you can see for every square by which pieces (of both colors)
it is attacked, at any time. So checks are practically free.

Now I am working on a bitboard version, and thinking about this problem too.
Right now I don't do any checking. I just return Mate if the king is captured.
However as soon as you want to do check extensions, you at least have to know if
the king of the side to move is in check. You want that, sooner or later.

One idea to do that would be to determine this when you generate captures. This
I do in my bitboard version. I not only determine the attacked pieces of the
opponent, but also by which opponent pieces the attacked pieces are defended, in
one run. To include your "own" king in this scheme isn't much extra work. The
disadvantage is that for killers and hashmoves you still don't know if you're in
check, because you did no move/capture generation.

I am thinking about this: at make/unmake time, you can check if the moved piece
directly attacks the king. If not: look if it uncovers an attack. For that the
moved piece had to be on the same rank/file/diagonal as the king. If so you only
have to check that file/rank/diagonal. If not: no checking needed.

BTW wouldn't square-relationship testing be faster than scanning the board?


Regards,
Bas Hamstra.



On August 20, 1999 at 19:26:30, Scott Gasch wrote:

>
>Hi,
>
>I've been profiling my program and it looks like the InCheck routine is taking
>up most of the processor cycles.  The way I currently do InCheck is by examining
>possible threats to a square -- i.e. shoot out vertically and look for
>rooks/queens or until I hit a blocking piece/go off the board.  Diagonal for
>bishops... pawns, knight and other king... etc.  Of course I stop as soon as any
>check is found.
>
>I run InCheck at the end of MakeMove to make sure the side to move didn't expose
>himself to check by moving.  I run it again after MakeMove to see if the move
>checked the opponent.  These are the only times it ever gets called.
>
>I thought about not checking it at all and just seeing if any move generated
>captured a king.  If so then we know the node above us in the tree is illegal
>and we are in a non-existent position.  In this case I guess I could just return
>beta and get out?
>
>Does anyone have any other ways of handling this?  Is there any faster way to
>calculate or deal with check?
>
>Thanks again,
>Scott



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.