Author: Dann Corbit
Date: 16:52:02 05/31/02
Go up one level in this thread
On May 31, 2002 at 18:50:18, Omid David wrote:
>I forgot to change "negascout" to "AlphaBeta" in 7th line for better
>illustration. Here is the correction:
>
>int AspWin(int estimate, int delta, int depth)
>{
>int alpha = estimate - delta;
>int beta = estimate + delta;
>int best;
>
>best = AlphaBeta(alpha, beta, depth);
>
>/* re-search */
>if(best <= alpha)
>best = AlphaBeta(-10000, beta, depth);
>else if(best >= beta)
>best = AlphaBeta(alpha, 10000, depth);
>
>/* is there any better way to handle this very rare case? */
>if(best >= beta || best <= alpha)
>best = AlphaBeta(-10000, 10000, depth);
>
>return best;
>}
Ancient SCP program:
/*--> Search: search for a move */
static
void
Search(siT side, siT ply, siT depth, siT alpha, siT beta, usiptrT bstline)
{
/*
Perform the main alpha-beta search. Extensions up to 3 ply
beyond the nominal iterative search depth MAY occur for checks,
check evasions, pawn promotion threats, and threats to multiple
pieces.
*/
siT j;
siT best, tempb, tempc, xside, pnt, pbst, hhh, d;
usiT mv, nxtline[plyL];
leafptrT node;
xside = otherside[side];
if (ply == 1)
InChk = 0;
else
InChk = ChkFlag[ply - 1];
PV = bstline[ply];
if (ply < 3)
Swag1 = Swag2 = 0;
else
{
Swag1 = (Tree[TrPnt[ply - 2]].frsq << byteW) +
Tree[TrPnt[ply - 2]].tosq;
Swag2 = (Tree[TrPnt[ply - 2] + 1].frsq << byteW) +
Tree[TrPnt[ply - 2] + 1].tosq;
};
if (ply > 1)
MoveList(side, ply);
best = -12000;
PPscore[ply] = -PPscore[ply - 1];
pnt = TrPnt[ply];
pbst = pnt;
while ((pnt < TrPnt[ply + 1]) && (best <= beta) && !timeout)
{
node = &Tree[pnt];
NodeCnt++;
nxtline[ply + 1] = 0;
if (ply == 1)
{
d = node->score-best;
if (pnt == TrPnt[ply])
extra_time = 0;
else
if (d < -50)
extra_time = -response_time / 3;
else
if (d < 20)
extra_time = 0;
else
if (d < 60)
extra_time = response_time / 3;
else
if (d < 200)
extra_time = response_time;
else
extra_time = 2 * response_time;
};
if (node->flags & capture)
CptrFlag[ply] = 1;
else
CptrFlag[ply] = 0;
if (node->flags & pwnthrt)
PawnThreat[ply] = 1;
else
PawnThreat[ply] = 0;
if ((ply == 1) && prc_cand)
{
Coordinate(node->frsq, node->tosq);
printf("CM: %s\n", mvstr1);
};
if ((node->flags & exact) == 0)
{
MakeMove(side, node, &tempb, &tempc);
Evaluate(side, node, ply, depth, alpha, beta, nxtline);
if ((hung[xside] > 1) && (ply <= Sdepth))
hhh = 1;
else
hhh = 0;
if (node->flags & check)
ChkFlag[ply] = 1;
else
ChkFlag[ply] = 0;
if ((node->flags & exact) == 0)
{
if (depth > 1)
ExpandNode(side, node, depth, ply, alpha, beta, nxtline);
if ((node->score <= beta) &&
(PawnThreat[ply] ||
((ChkFlag[ply] || hhh) && (depth == 1))))
ExpandNode(side, node, depth + 1, ply,
alpha, beta, nxtline);
else
if ((ChkFlag[ply - 1] || PawnThreat[ply - 1]) &&
(ply <= (Sdepth + 2)) && (Sdepth > 1) &&
((ply > Sdepth) || CptrFlag[ply - 1] ||
((ply > 3) &&
(ChkFlag[ply - 3] || CptrFlag[ply - 3])) ||
(hung[side] > 1)))
ExpandNode(side, node, depth + 1, ply,
alpha, beta, nxtline);
};
UnmakeMove(side, node, &tempb, &tempc);
};
if (node->score > best && !timeout)
{
if ((ply == 1) && (depth > 1) && (node->score > alpha) &&
(node->flags & exact) == 0)
node->score += 5;
best = node->score;
pbst = pnt;
if (best > alpha)
alpha = best;
for (j = ply; j < plyL; j++)
bstline[j] = nxtline[j];
bstline[ply] = (node->frsq << byteW) + node->tosq;
if (ply == 1 && post)
PostVariation(node);
};
if ((pnt & byteM) == 0)
ElapsedTime(0);
pnt++;
if (best > 9000)
beta = 0;
};
if (timeout)
pnt--;
if (ply == 1)
SortSegment(TrPnt[ply], pnt - 1);
else
Tree[TrPnt[ply]] = Tree[pbst];
node = &Tree[TrPnt[ply]];
mv = (node->frsq << byteW) + node->tosq;
if (node->tosq != (GameList[GameCnt] & byteM))
if (best > beta)
killr1[ply] = mv;
else
if (mv != killr2[ply])
{
killr3[ply] = killr2[ply];
killr2[ply] = mv;
};
if (InChk && best > -9000)
Qkillr[ply] = mv;
return;
}
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.