compiling stockfish with more options

Discussion of chess software programming and technical issues.

Moderators: hgm, Harvey Williamson, bob

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
majkelnowaq
Posts: 7
Joined: Fri Aug 10, 2018 2:07 pm
Full name: D.S.

compiling stockfish with more options

Post by majkelnowaq » Sat Jan 12, 2019 7:21 pm

Hi, i have some i guess 'beginner' question.
Im not programmer but sometimes i try to change src files and test results.

Here is my problem. I can add new tuning option just visually by adding something like "o["X"] << Option(100, 0, 100);" in ucioption.cpp but i cant actually connect it in proper way to some value. For example i want for "X" to change parameters in types.h file, we can say "QueenValueMg". I tried so many ways to do it as non-programmer could only do by intuitions shots but nothing works. Sometimes it doesnt pass to make exe file, sometimes passed but option in uci menu didnt work.

My questions is where (in which file) and what exactly i should add to connect chosen values with added lines in ucioption.cpp.
English isnt my native but i tried to be understood and i hope i ll, please - if u have some time to share -explain me this topic in simplest possible way.

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

Re: compiling stockfish with more options

Post by Rebel » Sat Jan 12, 2019 8:31 pm

Everybody is unique, except me.

majkelnowaq
Posts: 7
Joined: Fri Aug 10, 2018 2:07 pm
Full name: D.S.

Re: compiling stockfish with more options

Post by majkelnowaq » Sat Jan 12, 2019 9:00 pm

Thanks for reply Rebel.
The funny thing is i already use this excellent tool, without it i would do probably nothing.
I have no problem with changing values by this tool, but its quite time-consuming to make a guess and then make .exe one by one with small fluctuations of values. If i have possibility to change values from uci menu in gui it would be incomparably faster for engine tests (faster like faster is copying engine in gui and change values than searching in files for parameters and make each time new exe with proper description to not forget what parameter was changed).

Anyway i dont ask for miracle. If it's really complicate and hard task to do what i wrote in first post, just say it. In the other hand if it's rather simple to implement and i could easily teach it, please share your thoughts.

syzygy
Posts: 4441
Joined: Tue Feb 28, 2012 10:56 pm

Re: compiling stockfish with more options

Post by syzygy » Sun Jan 13, 2019 2:09 am

majkelnowaq wrote:
Sat Jan 12, 2019 7:21 pm
Here is my problem. I can add new tuning option just visually by adding something like "o["X"] << Option(100, 0, 100);" in ucioption.cpp but i cant actually connect it in proper way to some value. For example i want for "X" to change parameters in types.h file, we can say "QueenValueMg".
QueenValueMg is a compile-time constant. Compile-time constants cannot be changed at runtime.

You would have to turn QueenValueMg into a global variable. This is not trivial, since other places in Stockfish expect its value to be known at compile time. It would also slow Stockfish down a bit.

syzygy
Posts: 4441
Joined: Tue Feb 28, 2012 10:56 pm

Re: compiling stockfish with more options

Post by syzygy » Sun Jan 13, 2019 2:10 am

majkelnowaq wrote:
Sat Jan 12, 2019 9:00 pm
I have no problem with changing values by this tool, but its quite time-consuming to make a guess and then make .exe one by one with small fluctuations of values. If i have possibility to change values from uci menu in gui it would be incomparably faster for engine tests (faster like faster is copying engine in gui and change values than searching in files for parameters and make each time new exe with proper description to not forget what parameter was changed).
It may be easier to not have to recompile the engine, but if you are really trying to find the best values, you will anyway need to play so many games with each value you try that recompilation times are negligible.

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

Re: compiling stockfish with more options

Post by Rebel » Sun Jan 13, 2019 3:57 am

syzygy wrote:
Sun Jan 13, 2019 2:09 am
majkelnowaq wrote:
Sat Jan 12, 2019 7:21 pm
Here is my problem. I can add new tuning option just visually by adding something like "o["X"] << Option(100, 0, 100);" in ucioption.cpp but i cant actually connect it in proper way to some value. For example i want for "X" to change parameters in types.h file, we can say "QueenValueMg".
QueenValueMg is a compile-time constant. Compile-time constants cannot be changed at runtime.

You would have to turn QueenValueMg into a global variable. This is not trivial, since other places in Stockfish expect its value to be known at compile time. It would also slow Stockfish down a bit.
Actually QueenValueMg can be changed without loss of speed and change of code, the piece values (and other constants) are coded like this:

Code: Select all

  #define PVM 1000/1000
  #define PVE 1000/1000
  #define NVM 1000/1000
  #define NVE 1000/1000
  #define BVM 1000/1000
  #define BVE 1000/1000
  #define RVM 1000/1000
  #define RVE 1000/1000
  #define QVM 1000/1000
  #define QVE 1000/1000

  PawnValueMg   = 136*PVM,   PawnValueEg   = 208*PVE,
  KnightValueMg = 782*NVM,   KnightValueEg = 865*NVE,
  BishopValueMg = 830*BVM,   BishopValueEg = 918*BVE,
  RookValueMg   = 1289*RVM,  RookValueEg   = 1378*RVE,
  QueenValueMg  = 2529*QVM,  QueenValueEg  = 2687*QVE,
So if you want to lower QueenValueMg with (say) 0.5% you change the #define QVM 995/1000
Everybody is unique, except me.

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

Re: compiling stockfish with more options

Post by Rebel » Sun Jan 13, 2019 4:19 am

majkelnowaq wrote:
Sat Jan 12, 2019 9:00 pm
Thanks for reply Rebel.
The funny thing is i already use this excellent tool, without it i would do probably nothing.
I have no problem with changing values by this tool, but its quite time-consuming to make a guess and then make .exe one by one with small fluctuations of values. If i have possibility to change values from uci menu in gui it would be incomparably faster for engine tests (faster like faster is copying engine in gui and change values than searching in files for parameters and make each time new exe with proper description to not forget what parameter was changed).

Anyway i dont ask for miracle. If it's really complicate and hard task to do what i wrote in first post, just say it. In the other hand if it's rather simple to implement and i could easily teach it, please share your thoughts.
As syzygy already pointed out translating all the #defines to uci options would slow down the program, make it hard to read too since there are so many and most of it is a lot of work :lol:

Stockfish probably is the most tuned engine on the planet since it is a community project and thus improvements are a) hard to find, b) produce small gains. They are there, waiting to be found, but you need patience, perseverance and determination.
Everybody is unique, except me.

syzygy
Posts: 4441
Joined: Tue Feb 28, 2012 10:56 pm

Re: compiling stockfish with more options

Post by syzygy » Sun Jan 13, 2019 1:03 pm

Rebel wrote:
Sun Jan 13, 2019 3:57 am
syzygy wrote:
Sun Jan 13, 2019 2:09 am
majkelnowaq wrote:
Sat Jan 12, 2019 7:21 pm
Here is my problem. I can add new tuning option just visually by adding something like "o["X"] << Option(100, 0, 100);" in ucioption.cpp but i cant actually connect it in proper way to some value. For example i want for "X" to change parameters in types.h file, we can say "QueenValueMg".
QueenValueMg is a compile-time constant. Compile-time constants cannot be changed at runtime.

You would have to turn QueenValueMg into a global variable. This is not trivial, since other places in Stockfish expect its value to be known at compile time. It would also slow Stockfish down a bit.
Actually QueenValueMg can be changed without loss of speed and change of code,
Not at runtime, as you seem to admit yourself.

majkelnowaq
Posts: 7
Joined: Fri Aug 10, 2018 2:07 pm
Full name: D.S.

Re: compiling stockfish with more options

Post by majkelnowaq » Sun Jan 13, 2019 2:00 pm

Syzygy, Rebel thank you for interest and being helpful. I suspected it wont be trivial as it was said in this topic. Anyway i have some possibilities with stk tool and i ll still use it. Besides i already use stockfish derivatives with many options, i just was curious if i would be able to make one of them on my own, but its not most important.

I mean versions like SugaR.XPrO 220118 (https://mega.nz/#!y8oB0JYJ!NI_dBku8xv8b ... dDlH4obXqs), it has a lot values in uci like mobility, space, passed pawns, threats and many more or MZfish 110119 with ability to set values of all pieces (https://github.com/Zerbinati/MZfish/releases).

From time to time i find fun in testing different parameters in chess engines. One day i noticed for example that if we set material values to zero or value near of zero, then engine ll be genius in solving tactical positions (anyway fatal in real game) as i describe on fishcooking - https://groups.google.com/forum/#!searc ... 8CKRHoCwAJ

So once again thank u guys, if i would have further questions connected with chess engines/programming, i already know where i can find answers.

syzygy
Posts: 4441
Joined: Tue Feb 28, 2012 10:56 pm

Re: compiling stockfish with more options

Post by syzygy » Sun Jan 13, 2019 7:38 pm

majkelnowaq wrote:
Sun Jan 13, 2019 2:00 pm
Besides i already use stockfish derivatives with many options, i just was curious if i would be able to make one of them on my own, but its not most important.
So it is possible and not all too difficult, but it requires a bit of knowledge of C++ and several modifications to the source code. Since it would slow down Stockfish such changes will almost certainly not be made to the official Stockfish, but you or someone else could of course create a fork with such changes.

Post Reply