Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Principal variation search question.

Author: Matthias Gemuh

Date: 06:59:40 05/10/05

Go up one level in this thread


On May 10, 2005 at 03:33:36, Kevin K wrote:

>int AlphaBeta(int depth, int alpha, int beta)
>{
>    BOOL fFoundPv = FALSE;
>    if (depth == 0)
>        return Evaluate();
>    GenerateLegalMoves();
>    while (MovesLeft()) {
>        MakeNextMove();
>        if (fFoundPv) {
>            val = -AlphaBeta(depth - 1, -alpha - 1, -alpha);
>            if ((val > alpha) && (val < beta)) // Check for failure.
>                val = -AlphaBeta(depth - 1, -beta, -alpha);
>        } else
>            val = -AlphaBeta(depth - 1, -beta, -alpha);
>        UnmakeMove();
>        if (val >= beta)
>            return beta;
>        if (val > alpha) {
>            alpha = val;
>            fFoundPv = TRUE;
>        }
>    }
>    return alpha;
>}
>Above code came from http://www.seanet.com/~brucemo/chess.htm.
>I thought PVS searches the first move with alpha, beta and the others with
>alpha, alpha+1 like below code.
>But Bruce did differently. Wye did he do that?
>Which one is more efficient?
>
>int AlphaBeta(int depth, int alpha, int beta)
>{
>    if (depth == 0)
>        return Evaluate();
>    GenerateLegalMoves();
>    while (MovesLeft()) {
>        MakeNextMove();
>        if (this is the first move) {
>            val = -AlphaBeta(depth - 1, -beta, -alpha);
>        } else
>            val = -AlphaBeta(depth - 1, -alpha - 1, -alpha);
>            if ((val > alpha) && (val < beta)) // Check for failure.
>                val = -AlphaBeta(depth - 1, -beta, -alpha);
>        UnmakeMove();
>        if (val >= beta)
>            return beta;
>        if (val > alpha) {
>            alpha = val;
>            fFoundPv = TRUE;
>        }
>    }
>    return alpha;
>}




(this is the first move) is faster but risky.
I recommend (fFoundPv) because you then have a move above alpha with certainty.

Matthias.



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.