Author: Frank Schneider
Date: 21:48:56 06/05/03
Go up one level in this thread
<big snip>
>/****************************************************************************/
>/* */
>/* Function: think */
>/* */
>/* Description: This function */
>/* */
>/* Author: G.Westwood 14/04/2003 */
>/* */
>/* Inputs: */
>/* U32 output */
>/* */
>/* Outputs: */
>/* NONE */
>/* */
>/* */
>/****************************************************************************/
>
>#define EPSILON 50
>
>void think(void)
>{
>U32 j, k;
>S32 x, depth;
>double timeDiff, nodesPerSec;
>U32 startMeasureTime, stopMeasureTime;
>S32 alpha = -INFINITY;
>S32 beta = INFINITY;
>U32 failedLastTime = FALSE;
>
>
> /* try the opening book first */
> if (enableOpeningBook)
> {
> pv[0][0].u = bookMove();
> if (pv[0][0].u != -1)
> return;
> }
>
> nullMovesMade = 0;
>
> /* some code that lets us longjmp back here and return
> from think() when our time is up */
> stopSearch = FALSE;
> setjmp(env);
>
> if (stopSearch)
> {
> /* make sure to take back the entire line we were searching */
> while (ply)
> takeBack();
> return;
> }
>
> startTime = get_ms();
> stopTime = startTime + maxTime;
>
> startMeasureTime = get_ms();
>
> ply = 0;
> nodes = 0;
>
> memset(pv, 0, sizeof(pv)); /* clear down the PV arrray */
>
> memset(history, 0, sizeof(history)); /* clear down the history arrray */
>
> depth = 1;
>
> while (depth <= maxDepth)
> {
> followPV = TRUE;
>
> x = search(alpha, beta, depth, TRUE);
Hi,
I'm not sure if I'm right, but it seems this should be
x = search(alpha, beta, depth, FALSE);
otherwise you do a nullmove in the root position.
Frank
>
> if (depth > 2)
> {
> if (x <= alpha)
> {
> alpha = -INFINITY;
>
> if (failedLastTime)
> beta = INFINITY;
> else
> beta = x + 1;
>
> failedLastTime = TRUE;
>
> continue;
> }
> else
> failedLastTime = FALSE;
>
> if (x >= beta)
> {
> beta = INFINITY;
>
> if (failedLastTime)
> alpha = -INFINITY;
> else
> alpha = x - 1;
>
> failedLastTime = TRUE;
>
> continue;
> }
> else
> failedLastTime = FALSE;
>
> alpha = x - EPSILON;
> beta = x + EPSILON;
> }
>
> stopMeasureTime = get_ms();
>
> if (outputMode & SPEED_DEBUG_OUTPUT)
> printf("Nodes = %d Alpha Beta return a score of %d for move %s depth = %d
>\r\n",
> nodes, x, moveString(pv[0][0].b), depth);
>
> /* output some timing debug */
> timeDiff = (((double)(stopMeasureTime - startMeasureTime))/1000);
> nodesPerSec = (double)(nodes+500) / (timeDiff*1000);
>
> if (outputMode & SPEED_DEBUG_OUTPUT)
> printfDebug("Time elapsed = %0.2f Secs for %d nodes Nodes/Sec = %1.0f\r\n",
> timeDiff, nodes, nodesPerSec);
>
> if (!(outputMode & XBOARD_OUTPUT) && !(outputMode & SEARCH_DEBUG_OUTPUT))
> {
> /* print out the principal variation */
>
>
> if (npsMode)
> {
> if (depth == 1)
> /* show Nodes per sec */
> printfDebug("Ply Eval Time kNode/s Principle Variation\r\n");
>
> printfDebug("%2d: %6d %5d %4.0f ", depth, x, (get_ms() -
>startTime)/10, nodesPerSec);
> }
> else
> {
> if (depth == 1)
> /* show Total Nodes*/
> printfDebug("Ply Eval Time Nodes Principle Variation\r\n");
>
> printfDebug("%2d: %6d %5d %10u ", depth, x, (get_ms() - startTime) / 10,
>nodes);
> }
>
> for (k = 0; k < pv_length[0]; k++)
> printfDebug("%s ", moveString(pv[0][k].b));
>
> printfDebug("\r\n");
>
> }
> else if (outputMode & XBOARD_OUTPUT)
> {
>
> printfDebug("%d %d %d %d",
> depth, x, (get_ms() - startTime) / 10, nodes);
>
> for (j = 0; j < pv_length[0]; j++)
> printfDebug(" %s", moveString(pv[0][j].b));
>
> printfDebug("\r\n");
>
> fflush(stdout);
> }
>
> /* if we have got a no moves condition */
> if (x > 9000 || x < -9000)
> break;
>
> depth++; /* increase search depth */
>
> }
>}
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.