Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Fail soft alpha-beta

Author: Russell Reagan

Date: 10:02:22 09/08/03

Go up one level in this thread


On September 08, 2003 at 03:28:16, Koundinya Veluri wrote:

>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
>        }

In the if statement above, is the inner if statement necessary? It seems that if
val is greater than bestscore, val will also be greater than alpha. Would it be
okay to do this instead?

if (val > bestscore) {
    bestscore = val;
    alpha = bestscore;
}


>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.

In the fail hard version, I usually do something like this, instead of just
return alpha at the end of the function:

if (there_are_no_legal_moves) {
    if (side_to_move_is_in_check)
        return -INFINITY + current_depth;
    return STALEMATE;
}
return alpha;



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.