Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: check detection

Author: Scott Gasch

Date: 18:47:01 08/20/99

Go up one level in this thread


>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.

I have thought about this in the past.  I am concerned with the added overhead
of updating the attack tables every time you move a piece.  Though these tables
would certainly help improve the eval function, I think.

>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.

Yes.  However if I could remove the call to InCheck for the side who just moved
(i.e. the call that validates the move as legal in that it does not leave your
king in check) and just rely on the capture of a king to weed these illegal
positions I would be saving 1/2 of the calls to InCheck.  Even with the
remaining call (to see if a move checks the opponent's king and extend) I think
this would be an improvement.

>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.

That is a pretty interesting idea.

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

I thought about this but I don't know.  I have no numbers to back this up,
though.  Here's my thought -- usually we should be looking at normal positions
where the king is tucked away safely in the corner and not in the middle of the
board.  In such positions the InCheck routine that shoots rays out from the
king's position to look for threats run quickly.  Since to two sides are the
board edges and hopefully we have some blocking pawns in front the code can come
back after just checking a few places.  I.e. optimally 8 squares plus 2 for
knights attacking = 10.  If I were to run down the piece list for all 16
(possible) opponent pieces and compare square relationships to my king and look
for blockers... well, I think this would be more work.  What do others think?


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.