Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Fail soft alpha-beta

Author: Peter McKenzie

Date: 23:43:09 09/07/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;
>}

looks reasonable

>
>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();
         ^^^^^^^^^^   you changed this from MakeNextMove()  :-)

>        val = -AlphaBeta(depth - 1, -beta, -alpha);
>        UndoMove();
>        if (val >= beta)
>            return val;  // <-- Return val instead of beta

yes, that looks correct

>        if (val > alpha)
>            alpha = val;
>    }
>    return val;          // <-- Return val instead of alpha

This is wrong.  In this code, val just holds the value of the last move
searched.  I had a look at my code: I maintain another variable called bestScore
which tracks the best score of the moves searched.  That is what I return from
Search(...).  Not sure if that is classic fail soft, but it seems to work for me
:-)

>}
>
>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 prefer to not think about this stuff too often, it has a tendency to make my
brain implode...




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.