Page 1 of 2

Trying to use ProDeo book in my program

Posted: Sat Dec 21, 2019 12:40 pm
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).

Re: Trying to use ProDeo book in my program

Posted: Sat Dec 21, 2019 3:01 pm
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).

Re: Trying to use ProDeo book in my program

Posted: Sat Dec 21, 2019 3:57 pm
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

Re: Trying to use ProDeo book in my program

Posted: Sun Dec 22, 2019 3:15 am
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.

Re: Trying to use ProDeo book in my program

Posted: Sun Dec 22, 2019 8:03 am
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>

Re: Trying to use ProDeo book in my program

Posted: Sun Dec 22, 2019 8:25 am
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.

Re: Trying to use ProDeo book in my program

Posted: Sun Dec 22, 2019 8:35 am
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.

Re: Trying to use ProDeo book in my program

Posted: Sun Dec 22, 2019 8:58 am
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 :)

Re: Trying to use ProDeo book in my program

Posted: Sun Dec 22, 2019 10:53 am
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:

Re: Trying to use ProDeo book in my program

Posted: Sun Dec 22, 2019 1:44 pm
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 :)