Author: Russell Reagan
Date: 18:19:20 04/28/02
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
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.