Author: Robert Hyatt
Date: 08:18:52 04/29/02
Go up one level in this thread
On April 28, 2002 at 21:19:20, Russell Reagan wrote: >Here is the code in question. It's from his webpage "Collecting the Principle >Variation" at http://www.seanet.com/~brucemo/topics/pv.htm > >typedef struct tagLINE { > int cmove; // Number of moves in the line. > MOVE argmove[moveMAX]; // The line. >} LINE; >int AlphaBeta(int depth, int alpha, int beta, LINE * pline) >{ > LINE line; > if (depth == 0) { > pline->cmove = 0; > return Evaluate(); > } > GenerateLegalMoves(); > while (MovesLeft()) { > MakeNextMove(); > val = -AlphaBeta(depth - 1, -beta, -alpha, &line); > UnmakeMove(); > if (val >= beta) > return beta; > if (val > alpha) { > alpha = val; > pline->argmove[0] = ThisMove(); > memcpy(pline->argmove + 1, line.argmove, > line.cmove * sizeof(MOVE)); > pline->cmove = line.cmove + 1; > } > } > return alpha; >} > >My question is if this will always give you a principle variation. For one >example, if you searched to a depth of 1 and the first move created a beta >cutoff, you would return beta and the principle variation data would never be >touched. I've never seen a chess program give a score with no principle >variation. There's always at least one move in the principle variation, so am I >missing something, or does this code not produce a principle variation in this >case? > >Thanks, >Russell Think carefully. If the first move is a "beta cutoff" this means that _all_ moves at ply=2 were searched and none could lower that score enough to get it below beta. We have _no_ idea which of the ply-2 moves was the best one. Therefore there _is_ no PV here. Ditto for beta cutoffs deep in the tree. You only know that this move is good enough to refute the move at the previous ply. You do _not_ know that this move is the "best" move in this position. Hence no PV there either... The only time you can possibly have a PV is when alpha < score < beta...
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.