Computer Chess Club Archives


Search

Terms

Messages

Subject: A question about book.c of Crafty

Author: Uri Blass

Date: 15:24:30 09/04/04


I think to have a function to read pgn files.

I already have function to read data that is a move like 1.e4  and translate it
to e2e4

Now I think that I need a function to read the next game from a pgn file

As far as I see Crafty has no function to do it and I do not understand what it
exactly does.

I understand that Crafty's ReadPgn only return 0 in case of a move -1 in case of
end of file and 1 in other cases.

The following code seems to me code to skip moves in the pgn files because it
stops to read when data_read!=0

do {
      data_read=ReadPGN(book_input,0);
      if (data_read == -1) Print(4095,"end-of-file reached\n");
    } while (data_read == 0);

If I understand correctly data_read cannot be 0 when I am out of the loop
but based on my understaind if data_read!=0 I cannot go to the else that come
later in te end of the following code

What I understand wrong?


do {
      if (data_read < 0) {
        Print(4095,"end-of-file reached\n");
        break;
      }
      if (data_read == 1) {
        if (strstr(buffer,"Site")) {
          games_parsed++;
          result=3;
        }
        else if (strstr(buffer,"esult")) {
          if (strstr(buffer,"1-0")) result=2;
          else if (strstr(buffer,"0-1")) result=1;
          else if (strstr(buffer,"1/2-1/2")) result=0;
          else if (strstr(buffer,"*")) result=3;
        }
        data_read=ReadPGN(book_input,0);
      }
      else 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.