Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Fail soft alpha-beta

Author: Koundinya Veluri

Date: 00:28:16 09/08/03

Go up one level in this thread


On September 08, 2003 at 01:55:14, Russell Reagan wrote:

>I think I understand the differences and between fail hard alpha-beta and fail
>soft alpha-beta when described in higher level language (like English), but I'm
>a bit shaky on the implementation differences between the two.
>
>As I understand it, this is fail hard alpha-beta (from Bruce's site):
>
>int AlphaBeta(int depth, int alpha, int beta)
>{
>    int val;
>    if (depth == 0)
>        return Evaluate();
>    GenerateLegalMoves();
>    while (MovesLeft()) {
>        MakeNextMove();
>        val = -AlphaBeta(depth - 1, -beta, -alpha);
>        UnmakeMove();
>        if (val >= beta)
>            return beta;
>        if (val > alpha)
>            alpha = val;
>    }
>    return alpha;
>}
>
>How would this function be rewritten to perform fail soft alpha-beta? My best
>guess is this (changes commented):
>
>int AlphaBeta (int depth, int alpha, int beta) {
>    int val;
>    if (depth == 0)
>        return Evaluate();
>    GenerateLegalMoves();
>    while (MovesLeft()) {
>        MakeMove();
>        val = -AlphaBeta(depth - 1, -beta, -alpha);
>        UndoMove();
>        if (val >= beta)
>            return val;  // <-- Return val instead of beta
>        if (val > alpha)
>            alpha = val;
>    }
>    return val;          // <-- Return val instead of alpha
>}
>

I have something like this:

int AlphaBeta (int depth, int alpha, int beta) {
    int bestscore = -(CHECKMATE_VALUE - ply);             // changed
    if (depth == 0)
        return Evaluate();
    GenerateLegalMoves();
    while (MovesLeft()) {
        MakeMove();
        int val = -AlphaBeta(depth - 1, -beta, -alpha);   // slightly changed
        UndoMove();
        if (val >= beta)
            return val;
        if (val > bestscore) {                            // changed
            bestscore = val;                              // changed
            if (val > alpha)                              // added
                alpha = val;                              // added
        }
    }
    return bestscore;                                     // changed
}

>Also, when called with an infinite window (ex. AlphaBeta(depth, -INFINITY,
>INFINITY)), both the fail soft and fail hard versions should give the same
>score, correct?

I thought yes, but now that I think about it again, in a checkmated position,
fail-soft would return the correct checkmate score but fail-hard would return
alpha which would be -INFINITY :/... There might be something wrong in my
thinking here. Or, perhaps fail-hard should be tweaked to handle mate scores
when there are no legal moves.



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.