Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Question: For maximum efficiency, where do you use InCheck() function

Author: José Carlos

Date: 15:53:30 11/25/01

Go up one level in this thread


On November 25, 2001 at 18:12:17, William Bryant wrote:

>I think my program uses InCheck() to often, slowing down the search.
>
>I'm looking for comments and suggestions of different ways to utilize the
>function, and decrease the number of calls.
>
>At present, I call it at the end of each MakeMove() to see if this is an
>illegal position.
>
>Suggestions and discussion appreciated.
>
>William

  I do the same. I recommend you to try to figure out a faster way to do
inCheck(), if it is slow.
  For example, start from the king position and try to find enemy pieces in his
files/rank/diagonals instead of scanning the whole board seeing if every
opponent piece attacks the king.
  I have a more complex implementation. I have special code to handle the
movement of every piece.
  Depending on the moved piece, I only test certain possibilities. For example,
if I move a pawn forward, I can check the opponent king if:
  - the pawn gives check itself
  - the pawn opens a diagonal (I only test this if I have bishop or queens and
the pawn is in the same diagonal as the opponent king)
  - the pawn opens a rank (I only test this if I have rooks or queens and the
pawn is in the same rank as the opponent kinh.

  In the same way, I test if I open a line against my own king.
  So, after MakeMove() I know the position is legal, and I know if the opponent
is in check.

  José C.



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.