User Tools

Site Tools


public:gtql:gt-log_library

This is an old revision of the document!


GT-Log Library

The Log library can be used in game-playing programs and other search programs to log search trees to file.

Download the GT-Log Library here: loglibrary.rar

Below is an example to show how to use the game-tree log interface in a game program. We use here a simple iterative deepening and minimax procedure for demonstration purposes (and omit various details that are not relevant for our demonstration purposes). Essentially, one must create a handle in the beginning (and delete in the end), open a new file for each search iteration, and call special functions when entering/exiting a node. The user collects the information he or she want to log in the structure data. #include “gt_log.h” … GTDataDescript gtDataDescr = { “TicTacToe”, sizeof(Data_t), 0, {}, 5, { … { “depth”, offsetof(Data_t,depth), sizeof(int) }, { “best” , offsetof(Data_t,best), sizeof(int) }, { “type” , offsetof(Data_t,type), sizeof(int) } } }; GTLogHdl hGTL; Value Minimax( Position_t *pos, int depth, Move_t move_last ) { Data_t data; … data.depth = depth; gtl_enterNode( hGTL, move_last ); … n = generateMoves(pos, moves); for ( i=0 ; i<n ; i++ ) { makeMove( pos, moves[i] ); value = -Minimax( pos, depth-1, moves[i] ); … retractMove( pos, moves[i] ); } … data.best = best; gtl_exitNode( hGTL, &data ); 49 return best; } Value IterativeDeepening( … ) { … for ( iter=1 ; iter⇐maxIter ; ++iter ) { … gtl_startTree( hGTL, filename, strFEN ); … value = Minimax( &pos, iter, NULL_MOVE ); … gtl_stopTree( hGTL ); } … } int main() { … hGTL = gtl_newHdl( “TicTacToe”, &gtDataDescr ); if ( hGTL == NULL ) exit(EXIT_FAILURE); … gtl_deleteHdl( &hGTL ); … }

/var/www/cadia.ru.is/wiki/data/attic/public/gtql/gt-log_library.1197840207.txt.gz · Last modified: 2024/04/29 13:32 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki