Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: about in_check()

Author: Bo Persson

Date: 06:26:35 06/15/03

Go up one level in this thread


On June 15, 2003 at 04:29:19, Sune Fischer wrote:

>On June 14, 2003 at 23:52:36, Russell Reagan wrote:
>
>>On June 14, 2003 at 18:59:16, Sune Fischer wrote:
>>
>>>Goes without saying if you only use it for incheck.
>>>Incheck can be done by incrementally checking only for the moving piece and the
>>>piece it may uncover (x-ray). No attack table can beat that.
>>
>>I never thought of this. How would you do that? Use either a 64 x 64 array, or
>>the 256 element array (like the 0x88 attack array) to determine if a piece that
>>moved from a square could have exposed the king to check? Makes sense.
>
>Well it can be optimized a lot for 0x88, I suspect so much that it hardly shows
>up on the profile.
>Consider for instance a black move from c8 to d8 with the white king on g2, from
>those squares no checks are possible.
>
>>I wonder
>>how this would compare to the illegal move detection of allowing the king to be
>>captured and taking back the moves.
>
>I don't like this method at all. There are two (big) problems with it.
>
>First of all you need to do an expensive gen_captures() before you can tell if
>the position is legal. If only a very very small amount of the moves were
>illegal then it might still be faster than incheck(), but the problem is that a
>big percentage of the moves will in fact be illegal, maybe 80% of the moves do
>not evade a check. So everytime you are checked and your movelist contains 50
>moves, of which only 5-7 are legal as check evaders, you need to gen_captures()
>on 40+ moves just to find they are illegal! That is unless you just get lucky
>and quickly fail high on one of the legal ones, but still you see why it
>painfully expensive.

OK, so YMMV.  :-)

I guess the programs that use this method, like Crafty, also have a special
get_out_of_check() move generator. When in check the possible moves are very
limited:

- capture the checking piece (if it is only one)
- put another piece between the king and the checker (if it is a slider)
- move the king away from the attacked ray
- now you are really desperate - try an en passant capture!

Most of these will not move you into (another) check, so it will reduce the
cost.


>
>Secondly you need to know you are in check so you can _extend_.
>

or you can extend on moving out of check. You know you are there because you use
the special get_out_of_check routine.  :-)



Bo Persson
bop2@telia.com



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.