Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Check evasion : what's the point anyway?

Author: Lance Perkins

Date: 10:31:10 08/24/04

Go up one level in this thread


Even without a special check-evasion code, most programs have something like
this:

    generate all moves
    for all moves
        make move
        if not in check
           do more
        endif
        undo move
    endfor

You can avoid the "if not in check" test if you just generate valid moves all
the time.

It would be somethigg like this:

    // generate all valid moves
    If in check
        Generate king moves to all safe squares (note that the king can't
            simply move away from the direction of the attacker/s)
        If there is only one attacker
            Generate king move to capture the attacker (assuming that
                the attacker is undefended)
            Generate all non-pinned Q,R,B,N,P moves to capture the attacker
               and to block the attacker
        Endif
    Else
        Generate king moves to all safe squares
        Generate all non-pinned Q,R,B,N,P moves to empty squares and to
            opponent-occupied squres
    Endif

I might have missed a few details there, but you get the picture. You only do
the "is in check" test once instead of each time you do a 'make move'.



On August 24, 2004 at 06:17:50, martin fierz wrote:

>as a related question to mridul's post: i don't have a special check evasion
>generator. i just have a single normal move generator and if it's a check, i
>will have to execute all the normal moves, and undo them again after seeing that
>it's still a check.
>
>does anyone have an estimate on how much a specialized check-evasion move
>generator would speed up a program?
>is it really worth it?
>
>cheers
>  martin



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.