Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: What do you put in the opening book?

Author: Alessandro Scotti

Date: 15:21:21 10/02/04

Go up one level in this thread


On October 02, 2004 at 17:46:26, Uri Blass wrote:

>Does it mean that you have a function to read pgn?

Yes, and it's a full object-oriented design. To read a database you have to
write something like this:

    PGNGame g;

    while( true ) {
        if( g.loadFromFile( &lex ) != 0 ) {
            break;
        }

        ...do something with the game...
    }

The PGNGame class has methods to get and set the tags, the moves, the result and
so on. Code is quite simple at present but it can read gm2600.pgn without
problems. The book code itself is also quite straightforward (currently less
than 300 lines for creation and lookup). At first I designed a solution that
used a data structure similar to a B-Tree but then with a book so small it's
much better to load everything in memory and use a binary search.
I have no problem sharing the PGN parsing code if there's interest in it. I
think probably 95% or more can be used in a C++ engine without any modifications
(the rest relates to parsing and checking the input moves, which I use some
engine code to do).



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.