Trying to use ProDeo book in my program

Discussion of chess software programming and technical issues.

Moderators: bob, hgm, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
User avatar
Roland Chastain
Posts: 337
Joined: Sat Jun 08, 2013 8:07 am
Location: France
Full name: Roland Chastain
Contact:

Trying to use ProDeo book in my program

Post by Roland Chastain » Sat Dec 21, 2019 11:40 am

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).

User avatar
pedrox
Posts: 995
Joined: Fri Mar 10, 2006 5:07 am
Location: Basque Country (Spain)
Contact:

Re: Trying to use ProDeo book in my program

Post by pedrox » Sat Dec 21, 2019 2: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.

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: 337
Joined: Sat Jun 08, 2013 8:07 am
Location: France
Full name: Roland Chastain
Contact:

Re: Trying to use ProDeo book in my program

Post by Roland Chastain » Sat Dec 21, 2019 2:57 pm

pedrox wrote:
Sat Dec 21, 2019 2: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

User avatar
phhnguyen
Posts: 614
Joined: Wed Apr 21, 2010 2:58 am
Location: Australia
Full name: Nguyen Hong Pham
Contact:

Re: Trying to use ProDeo book in my program

Post by phhnguyen » Sun Dec 22, 2019 2: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.
https://banksiagui.com
A freeware chess GUI, based on opensource Banksia - the chess tournament manager

User avatar
Roland Chastain
Posts: 337
Joined: Sat Jun 08, 2013 8:07 am
Location: France
Full name: Roland Chastain
Contact:

Re: Trying to use ProDeo book in my program

Post by Roland Chastain » Sun Dec 22, 2019 7:03 am

phhnguyen wrote:
Sun Dec 22, 2019 2: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>
Attachments
bookc-20191221.zip
(6.32 KiB) Downloaded 19 times

User avatar
Rebel
Posts: 5018
Joined: Thu Aug 18, 2011 10:04 am

Re: Trying to use ProDeo book in my program

Post by Rebel » Sun Dec 22, 2019 7:25 am

Roland Chastain wrote:
Sat Dec 21, 2019 11:40 am
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: 337
Joined: Sat Jun 08, 2013 8:07 am
Location: France
Full name: Roland Chastain
Contact:

Re: Trying to use ProDeo book in my program

Post by Roland Chastain » Sun Dec 22, 2019 7:35 am

Rebel wrote:
Sun Dec 22, 2019 7: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.

User avatar
phhnguyen
Posts: 614
Joined: Wed Apr 21, 2010 2:58 am
Location: Australia
Full name: Nguyen Hong Pham
Contact:

Re: Trying to use ProDeo book in my program

Post by phhnguyen » Sun Dec 22, 2019 7:58 am

Roland Chastain wrote:
Sun Dec 22, 2019 7:03 am
phhnguyen wrote:
Sun Dec 22, 2019 2: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
A freeware chess GUI, based on opensource Banksia - the chess tournament manager

User avatar
Roland Chastain
Posts: 337
Joined: Sat Jun 08, 2013 8:07 am
Location: France
Full name: Roland Chastain
Contact:

Re: Trying to use ProDeo book in my program

Post by Roland Chastain » Sun Dec 22, 2019 9:53 am

phhnguyen wrote:
Sun Dec 22, 2019 7: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:

mar
Posts: 2091
Joined: Fri Nov 26, 2010 1:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: Trying to use ProDeo book in my program

Post by mar » Sun Dec 22, 2019 12:44 pm

phhnguyen wrote:
Sun Dec 22, 2019 7: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

Post Reply