--- eval.c Fri Jun 28 20:29:37 2002 +++ eval.c.cvs Fri Jun 28 20:49:37 2002 @@ -22,7 +22,6 @@ #include "config.h" -#include "pthread.h" #if HAVE_ALLOCA_H #include #endif @@ -2612,59 +2611,13 @@ int anBoard[ 2 ][ 25 ], cubeinfo *pci, evalcontext *pec, int nPlies ); -typedef struct threaddata_ { - int anBoard[ 2 ][ 25 ]; - int n0, n1; - float arOutput[ NUM_OUTPUTS ]; - cubeinfo *pci; - evalcontext *pec; -} threaddata; - -static void EvaluateThread(void *ptr) { - - threaddata *ptd; - int i, nPlies; - float ar[ NUM_OUTPUTS ]; - cubeinfo *pci, ciOpp; - evalcontext *pec; - - ptd = (threaddata *) ptr; - pec = ptd->pec; - pci = ptd->pci; - - nPlies = pec->nPlies; - - FindBestMovePlied( 0, ptd->n0, ptd->n1, ptd->anBoard, pci, pec, 0 ); - - printf("%d:%d:%d:%d\n", ptd->anBoard[1][23], ptd->anBoard[1][5], - ptd->anBoard[1][12], ptd->anBoard[1][7]); - SwapSides( ptd->anBoard ); -// - SetCubeInfo ( &ciOpp, pci->nCube, pci->fCubeOwner, ! pci->fMove, - pci->nMatchTo, pci->anScore, pci->fCrawford, pci->fJacoby, - pci->fBeavers ); - EvaluatePositionCache( ptd->anBoard, ar, &ciOpp, pec, 0, // nPlies - 1, - ClassifyPosition( ptd->anBoard ) ); - - if( ptd->n0 == ptd->n1 ) - for( i = 0; i < NUM_OUTPUTS; i++ ) - ptd->arOutput[ i ] += ar[ i ]; - else - for( i = 0; i < NUM_OUTPUTS; i++ ) - ptd->arOutput[ i ] += ar[ i ] * 2.0; - - printf ("Dice: %d%d\n", ptd->n0, ptd->n1); - pthread_exit(0); -} static int EvaluatePositionFull( int anBoard[ 2 ][ 25 ], float arOutput[], cubeinfo *pci, evalcontext *pec, int nPlies, positionclass pc ) { - int i, j = 0, n0, n1, rc, status; - pthread_t threadid[21]; - threaddata td[21]; + int i, n0, n1; int bUsingReduction; if( pc > CLASS_PERFECT && nPlies > 0 ) { @@ -2684,41 +2637,42 @@ /* full search */ for( n0 = 1; n0 <= 6; n0++ ) for( n1 = 1; n1 <= n0; n1++ ) { - /* Set up threaddata */ - td[j].n0 = n0; - td[j].n1 = n1; for( i = 0; i < 25; i++ ) { - td[j].anBoard[ 0 ][ i ] = anBoard[ 0 ][ i ]; - td[j].anBoard[ 1 ][ i ] = anBoard[ 1 ][ i ]; - } - td[j].pci = pci; - td[j].pec = pec; - /* Make a thread */ - printf("Creating thread %d\n", j); - rc = pthread_create( &threadid[j], NULL, - (void*)&EvaluateThread, (void*) &td[j]); - if (rc) - { - printf("ERROR; return code from pthread_create() is %d\n", rc); - exit(-1); - } - sleep(200); - j++; + anBoardNew[ 0 ][ i ] = anBoard[ 0 ][ i ]; + anBoardNew[ 1 ][ i ] = anBoard[ 1 ][ i ]; } - /* Join the threads */ - printf("Joining threads\n"); - for( j = 0; j < 21; j++){ + if( fAction ) + fnAction(); - rc = pthread_join(threadid[j], (void **)&status); - if (rc) - { - printf("ERROR; return code from pthread_join() is %d\n", rc); - exit(-1); + if( fInterrupt ) { + errno = EINTR; + return -1; } - printf("Completed join with thread %d status= %d\n",j, status); + + FindBestMovePlied( 0, n0, n1, anBoardNew, pci, pec, 0 ); + + SwapSides( anBoardNew ); + + SetCubeInfo ( &ciOpp, pci->nCube, pci->fCubeOwner, ! pci->fMove, + pci->nMatchTo, pci->anScore, pci->fCrawford, pci->fJacoby, + pci->fBeavers ); + + bRecursingFor2ply = (nPlies == 2); + + if( EvaluatePositionCache( anBoardNew, ar, &ciOpp, pec, nPlies - 1, + ClassifyPosition( anBoardNew ) ) ) + return -1; + + bRecursingFor2ply = FALSE; /* note, didn't restore it on error */ + + if( n0 == n1 ) + for( i = 0; i < NUM_OUTPUTS; i++ ) + arOutput[ i ] += ar[ i ]; + else + for( i = 0; i < NUM_OUTPUTS; i++ ) + arOutput[ i ] += ar[ i ] * 2.0; } - printf("Threads joined\n"); arOutput[ OUTPUT_WIN ] = 1.0 - arOutput[ OUTPUT_WIN ] / 36.0; @@ -3423,7 +3377,6 @@ /* start move count */ moveNumber = -1; } - printf("pml->cMoves: %d", pml->cMoves); for( i = 0; i < pml->cMoves; i++ ) { if( ScoreMove( pml->amMoves + i, pci, pec, nPlies ) < 0 ) {