Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Delaying the KingInCheck - pros and cons?

Author: Dezhi Zhao

Date: 07:05:48 10/28/98

Go up one level in this thread



On October 28, 1998 at 08:50:06, Peter Fendrich wrote:

>In the Search, when a move is generated and made, I always call the KingInCheck
>routine to find out if the side who moved is in check. If so the position is
>illegal and a new move is generated.
>
>Sometimes it is proposed to skip the KingInCheck test and let the move
>generator, in the next ply, capture the king. In that case stop that node and
>return error. The idea is to gain performance by not calling the KnigInCheck at
>all and that the illegal positions are so uncommon that it's worth the extra
>overhead the few times it happens.
>
>I never liked that idea but started to think about it anyway...
>I think it's somewhat unnatural to have possibly illegal positions around and it
>makes the program more complex. Some thoughts:
>
>1)
>When the NullMove starts at next ply, I certainly don't want to have illegal
>positions around.
>By making a call to KingInCheck before the NullMove the whole idea with delaying
>the check is spoiled so that's not a solution.
>Another way is to generate the first move in order to see if the position is
>legal, before the NullMove is started. A capture of the King is supposed to be
>the first thing to find and in that case return error, never letting the
>NullMove start.
>

Null move is a real problem for delaying legality check, because null
move does not belong to move class and needs not to be generated.
The other way you mentioned is in fact to do  legality check before
null move search and after transposition lookup. And it is nearly  the same
as your original method, with a litte wastes of lookups and alphabeta call
overhead for illegal positions.


>2)
>There ar other things that is done before the 'real' search is started, like
>hash table look up, repetition check, end game tables and more. What are the
>side effects?
>

I have tried both ways and found no side effects.
I think legal check is a must. You may decide where to put it.
It's only a matter of  speed and code size.  If legality is checked in
the next ply,  the search code is smaller than otherwise in this ply,
but the search is slightly slow down (<1%  for my program).

>3)
>What will happen in the Quiescence when the Evaluate is called in the beginning?
>There might be an illegal position to Evaluate. Maybe not so dangerous but you
>have to think about it when you do your evaluate coding.
>

This is not related to legality check, and  could  be easily avoided if you do
check-extesion.

>In short it's too complex for my taste (I don't have to invent bugs - I 'm happy
>with the ones I have!) and I don't see any real performance gains. At least not
>for my program. At least not in theory.
>
>Have you measured it and how do you handle situations like those above?
>
>//Peter

I think the best way is to reduce the complexity of legality check code and
make it inline (bitboard method has an excellent application here),
and  do the legality checks before going to next ply.


Dezhi Zhao




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.