Trying to use ProDeo book in my program

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
Roland Chastain
Posts: 640
Joined: Sat Jun 08, 2013 10:07 am
Location: France
Full name: Roland Chastain

Trying to use ProDeo book in my program

Post by Roland Chastain »

Hello everybody!

I would like to use ProDeo book in my Pascal program. So I started to translate book.c in Pascal.

@Ed Schröder
I allowed myself to give a link to my Google Drive because it seems that the page where I had downloaded the files no longer exists. I hope you don't mind.

My Pascal translation is unfinished and doesn't work. But, which is even more annoying, I discover that I cannot compile the C code. I am under Linux and try to compile with GCC. Here is my attempt:

Code: Select all

[roland@localhost prodeobook]$ gcc book.c -o book
book.c: Dans la fonction « FIND_OPENING »:
book.c:258:31: warning: déclaration implicite de la fonction « randomize »; vouliez-vous utiliser « random_r » ? [-Wimplicit-function-declaration]
         clock_t a; a=clock(); randomize();
                               ^~~~~~~~~
                               random_r
book.c:259:11: error: trop d'arguments pour la fonction « random »
         x=random(9999); rnd=RND+x;
           ^~~~~~
In file included from book.c:123:
/usr/include/stdlib.h:401:17: note: déclaré ici
 extern long int random (void) __THROW;
                 ^~~~~~
[roland@localhost prodeobook]$ 
I guess that the code was written for another compiler.

Could you help me to "fix" the C code, so that it compiles and works?

And after that, could you help me to understand how the code works?

Thank you.

P.-S. I know that there is a rebelbook.dll, with Pascal usage example. I successfully used it in the past. But for now I would like to use ProDeo book under Windows and under Linux. That's why I imagined to do that translation (and also because I am interested in understanding how the book is made).
Qui trop embrasse mal étreint.
User avatar
pedrox
Posts: 1056
Joined: Fri Mar 10, 2006 6:07 am
Location: Basque Country (Spain)

Re: Trying to use ProDeo book in my program

Post by pedrox »

I have used the book of rebel in DanaSah. Like you, I started using the dll and finally integrated the code. Like you, I had some problem compiling, so I made some small change until I got it. At first I used the microsoft compiler and later gcc. With some tool like winmerge you could see the changes made.

The code of the book is:
https://github.com/pmcastro/danasah-500 ... er/libro.c

The book is initialized in the function Carga_libro() in the call to the xboard protocol:
https://github.com/pmcastro/danasah-500 ... r/xboard.c

And it is used in the MotorPiensa function, which is what calls the search:
https://github.com/pmcastro/danasah-500 ... busqueda.c

You can skip the code part used in UNDER_CE (for pocketpc). The code compiled and worked under Windows and Linux (in Linux64 I did not get the book to work even though it did not give any error, in the rest of the platforms it worked).
User avatar
Roland Chastain
Posts: 640
Joined: Sat Jun 08, 2013 10:07 am
Location: France
Full name: Roland Chastain

Re: Trying to use ProDeo book in my program

Post by Roland Chastain »

pedrox wrote: Sat Dec 21, 2019 3:01 pm I have used the book of rebel in DanaSah. Like you, I started using the dll and finally integrated the code. Like you, I had some problem compiling, so I made some small change until I got it. At first I used the microsoft compiler and later gcc. With some tool like winmerge you could see the changes made.
Thank you very much. I will study your code.

Regards.

Roland
Qui trop embrasse mal étreint.
User avatar
phhnguyen
Posts: 1434
Joined: Wed Apr 21, 2010 4:58 am
Location: Australia
Full name: Nguyen Hong Pham

Re: Trying to use ProDeo book in my program

Post by phhnguyen »

Just curious question: Why do you want to support that book format?

As I have understood, ProDeo books are not so popular. The author has converted his important books into Polyglot format already. If you supported Polyglot one, it is more than enough and ProDeo becomes redundant.
https://banksiagui.com
The most features chess GUI, based on opensource Banksia - the chess tournament manager
User avatar
Roland Chastain
Posts: 640
Joined: Sat Jun 08, 2013 10:07 am
Location: France
Full name: Roland Chastain

Re: Trying to use ProDeo book in my program

Post by Roland Chastain »

phhnguyen wrote: Sun Dec 22, 2019 3:15 am Just curious question: Why do you want to support that book format?

As I have understood, ProDeo books are not so popular. The author has converted his important books into Polyglot format already. If you supported Polyglot one, it is more than enough and ProDeo becomes redundant.
Thank you for your answer. Yes, you are probably right. If I find a simple code example showing how to read a polyglot book, I could try to translate it.

With the help of Pedro, I have now a C code which compiles and works under Windows but (as Pedro said) it compiles but doesn't work under Linux 64. I attach the code here, in case someone would take a look at it. (For the *.bin files you have to use the link in my first post.)

To compile under Linux, I just added this:

Code: Select all

#include <errno.h>
Qui trop embrasse mal étreint.
User avatar
Rebel
Posts: 6991
Joined: Thu Aug 18, 2011 12:04 pm

Re: Trying to use ProDeo book in my program

Post by Rebel »

Roland Chastain wrote: Sat Dec 21, 2019 12:40 pm Hello everybody!

I would like to use ProDeo book in my Pascal program. So I started to translate book.c in Pascal.

@Ed Schröder
I allowed myself to give a link to my Google Drive because it seems that the page where I had downloaded the files no longer exists. I hope you don't mind.
I don't mind, it's freeware. It was popular at release time in 2007, nowadys it's outdated. As others already said, use Polyglot, it's faster, supported by many engines and many free books are available.
90% of coding is debugging, the other 10% is writing bugs.
User avatar
Roland Chastain
Posts: 640
Joined: Sat Jun 08, 2013 10:07 am
Location: France
Full name: Roland Chastain

Re: Trying to use ProDeo book in my program

Post by Roland Chastain »

Rebel wrote: Sun Dec 22, 2019 8:25 am I don't mind, it's freeware. It was popular at release time in 2007, nowadys it's outdated. As others already said, use Polyglot, it's faster, supported by many engines and many free books are available.
Thank you. I will follow your advice.
Qui trop embrasse mal étreint.
User avatar
phhnguyen
Posts: 1434
Joined: Wed Apr 21, 2010 4:58 am
Location: Australia
Full name: Nguyen Hong Pham

Re: Trying to use ProDeo book in my program

Post by phhnguyen »

Roland Chastain wrote: Sun Dec 22, 2019 8:03 am
phhnguyen wrote: Sun Dec 22, 2019 3:15 am Just curious question: Why do you want to support that book format?

As I have understood, ProDeo books are not so popular. The author has converted his important books into Polyglot format already. If you supported Polyglot one, it is more than enough and ProDeo becomes redundant.
Thank you for your answer. Yes, you are probably right. If I find a simple code example showing how to read a polyglot book, I could try to translate it.
I suggest you get hurt one to solve the opening book issue ;)

It is easy to find some code working with Polyglot somewhere on the Internet. If you want "almost original" one:

http://hardy.uhasselt.be/Toga/book_format.html

or

http://hgm.nubati.net/book_format.html

From my experience, there are two important points you must have:
- Calculate hash key for a given chess position as Polyglot hash key value
- The encoding (Little Endian) of integers from book data is not in the right order of typical OSs => you need to convert

If you want a simple-ready-runnable code, the bellow code is mine, C++11, compilable by almost all C++ compilers.

https://github.com/nguyenpham/Banksia/b ... e/book.cpp

Happy coding

@Ed: I have been using your opening books (in Polyglot format), love them and thanks :)
https://banksiagui.com
The most features chess GUI, based on opensource Banksia - the chess tournament manager
User avatar
Roland Chastain
Posts: 640
Joined: Sat Jun 08, 2013 10:07 am
Location: France
Full name: Roland Chastain

Re: Trying to use ProDeo book in my program

Post by Roland Chastain »

phhnguyen wrote: Sun Dec 22, 2019 8:58 am Happy coding
Thank you for the links and for the tips. OK, in 2020 I will try to learn how to read a polyglot book. :wink:
Qui trop embrasse mal étreint.
mar
Posts: 2554
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: Trying to use ProDeo book in my program

Post by mar »

phhnguyen wrote: Sun Dec 22, 2019 8:58 am - The encoding (Little Endian) of integers from book data is not in the right order of typical OSs => you need to convert
You mean big endian :)
Martin Sedlak