#include #include #include "eval.h" /* ugly fixes */ char *aszRNG[]; char *aszSkillType[ 1 ]; int exsExport; int ap; /* end ugly fixes */ static float test( int anBoard[ 2 ][ 25 ] ) { const cubeinfo ci = { 1, -1, 0, 0, { 0, 0 }, 0, 0, 0, { 1.0, 1.0, 1.0, 1.0 }, VARIATION_STANDARD }; /* money game without Jacoby */ const evalcontext ec = { FALSE, 0, 0, 0, 0 }; /* cubeless 0-ply */ float arOutput[ NUM_OUTPUTS ]; EvaluatePosition( anBoard, arOutput, &ci, &ec ); return Utility( arOutput, &ci ); } extern int main( void ) { int anBoard[ 2 ][ 25 ]; int n; movelist ml; int i; /* initialise evaluator */ if ( EvalInitialise( "gnubg.weights", "gnubg.wd", FALSE, NULL, FALSE, NULL ) < 0 ) { printf( "EvalInitialise failed!\n" ); exit(1); } /* test: return cubeless equity of position */ memset( anBoard, 0, sizeof anBoard ); anBoard[ 0 ][ 5 ] = anBoard[ 1 ][ 5 ] = anBoard[ 0 ][ 12 ] = anBoard[ 1 ][ 12 ] = 5; anBoard[ 0 ][ 7 ] = anBoard[ 1 ][ 7 ] = 3; anBoard[ 0 ][ 23 ] = anBoard[ 1 ][ 23 ] = 2; printf( "cubeless equity: %f\n", test( anBoard ) ); /* test2: return list of all legal moves */ n = GenerateMoves( &ml, anBoard, 3, 1, FALSE ); printf( "%d legal moves for opening 31\n", n ); /* remember to memcpy( myMoves, ml.amMoves, n * sizeof( move ) ) since GenerateMoves/EvaluatePosition overwrite return ml.amMoves */ /* test3: calculate equity of all possible moves */ for ( i = 0; i < n; ++i ) { int an[ 2 ][ 25 ]; char sz[ 33 ]; /* restore board after move */ PositionFromKey( an, ml.amMoves[ i ].auch ); /* alternative code is: memcpy( an, anBoard, sizeof an ); ApplyMove( an, ml.amMoves[ i ].anMove, FALSE ); */ /* swap board to set opponent on roll */ SwapSides( an ); /* calculate equity */ printf( "Equity for '%-32s': %+.3f\n", FormatMove( sz, anBoard, ml.amMoves[ i ].anMove ), -test( an ) ); } EvalShutdown(); }