Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Question regarding: Aspiraton Window Search (a correction)

Author: Dann Corbit

Date: 16:36:39 05/31/02

Go up one level in this thread


On May 31, 2002 at 18:50:18, Omid David wrote:

>I forgot to change "negascout" to "AlphaBeta" in 7th line for better
>illustration. Here is the correction:
>
>int AspWin(int estimate, int delta, int depth)
>{
>int alpha = estimate - delta;
>int beta = estimate + delta;
>int best;
>
>best = AlphaBeta(alpha, beta, depth);
>
>/* re-search */
>if(best <= alpha)
>best = AlphaBeta(-10000, beta, depth);
>else if(best >= beta)
>best = AlphaBeta(alpha, 10000, depth);
>
>/* is there any better way to handle this very rare case? */
>if(best >= beta || best <= alpha)
>best = AlphaBeta(-10000, 10000, depth);
>
>return best;
>}

Here is what Beowulf does:

    /* ----===   Begin Iterative Deepening Loop   ===----   */
    do {
        /* break out if we're in analysis mode and this position is * either
         * checkmate or stalemate.  Go straight into a loop * waiting for
         * input instead */
        if (bBreakout)
            break;

        GlobalDepth = depth;

        /* --==   Do Search Recursion Here   ==--   */

        /* Use the recursive negascout algorithm to find the score.  If we
         * already have an estimate of the true score then use this and
         * search only in a window around it. */
        if (!USE_WINDOW || depth == 2)
            score = Search(B, -CMSCORE, CMSCORE, depth * ONEPLY, 0, inchk,
InitFifty, TRUE, NO_MOVE);

        else {
            RootAlpha = PreviousScore - WINDOW;
            RootBeta = PreviousScore + WINDOW;
            score = Search(B, RootAlpha, RootBeta, depth * ONEPLY, 0, inchk,
InitFifty, TRUE, NO_MOVE);
            if (!AbortFlag) {
                /* If this aspiration search fails low or high then search it
                 * properly with safer bounds instead.  Also increase the
                 * window size.  */
                if (score <= RootAlpha || score >= RootBeta) {
                    if (score >= RootBeta && Post)
                        PrintThinking(score, B);
                    if (score <= RootAlpha) {
                        RootAlpha = -CMSCORE;
                        RootBeta = score + 1;
                    }
                    if (score >= RootBeta) {
                        RootBeta = CMSCORE;
                        RootAlpha = score - 1;
                    }
                    score = Search(B, RootAlpha, RootBeta, depth * ONEPLY, 0,
inchk, InitFifty, TRUE, NO_MOVE);
                    /* If the second search also fails with a cutoff
                     * (strangely) then we must do a full re-search with
                     * infinite bounds.  The expectation is that this happens
                     * extremely rarely.  Of course, it shouldn't happen at
                     * all, ideally. The fact that it sometimes does is due
                     * to a phenomenon called "search instability", and it's
                     * a complete pain!  At least we'll have a full hash
                     * table! */
                    if (!AbortFlag && (score <= RootAlpha || score >= RootBeta))
{
                        RootBeta = CMSCORE;
                        RootAlpha = -CMSCORE;
                        score = Search(B, RootAlpha, RootBeta, depth * ONEPLY,
0, inchk, InitFifty, TRUE, NO_MOVE);
                    }
                }
            }
        }

        /* --==  Search Finished ==--  */

        /* Probe the hashtable for the suggested best move */
        Entry = HashProbe(B);
        if (Entry) {
            BestMove = Entry->move;
            score = (int) Entry->score;
        } else {
            BestMove = NO_MOVE;
            fprintf(stdout, "Could Not Find First Ply Hash Entry!\n");
        }

        /* If we aborted the search before any score was returned, then reset
         * to the previous ply's move score */
        if (AbortFlag && BestMove == NO_MOVE)
            score = PreviousScore;
        /* Otherwise store what we've found */
        else {
            PreviousScore = score;
            Previous = BestMove;
        }

        /* Go to the next depth in our iterative deepening loop */
        depth++;

        /* Check to see if we should continue the search */
        if (AnalyseMode)
            Continue = Not(AbortFlag);
        else
            Continue = ContinueSearch(score, depth);

    } while (!IsCM(score) && (TopPlyNMoves > 1 || AnalyseMode) && Continue &&
!TBHit);

    /* --==  End Iterative Deepening Loop  ==--   */



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.