STK for Stockfish

Stockfish Tuning Kit


version 10

92.3 Mb

New STK version for Stockfish 10. If you are new to STK carefully read the below Stockfish 9 documentation. Installation and operation is the same as with Stockfish 9, just go to C:\MinGW\sf10\src folder and double cliick c.bat to compile.

What's worth mentioning?

More 100/100 defines are added present in the following files:

. search.cpp

. evaluate.cpp

. pawns.cpp

. types.h (the piece values)

. psqt.cpp (the piece square tables)

If you already have installed STK for Stockfish 9 you can manually download and install the new files.

. Copy the sf10 folder in C:\MinGW

. Copy bullet.bat | blitz.bat | long.bat | sf10.exe and sf10x.exe in C:\MinGW\cc

Happy ELO hunting.


Stockfish 9 documentation

STK is a simple all-in platform for tuning Stockfish evaluation paramters (tables) without changing any code. Current version is 9.


Example: in evaluate.cpp the original evaluation table for ThreatByMinor/ByRook (line 184) shows:

// ThreatByMinor/ByRook[attacked PieceType] contains bonuses according to

// which piece type attacks which one. Attacks on lesser pieces which are

// pawn-defended are not considered.

   const Score ThreatByMinor[PIECE_TYPE_NB] = {

    S(0, 0), S(0, 33), S(45, 43), S(46, 47), S(72, 107), S(48, 118) };


In STK the following change is made:

#define TBM 100/100               

const Score ThreatByMinor[PIECE_TYPE_NB] = {

S(0*TBM, 0*TBM), S(0*TBM, 33*TBM), S(45*TBM, 43*TBM), S(46*TBM, 47*TBM), S(72*TBM, 107*TBM), S(48*TBM, 118*TBM) };

Which will produce the exact same output. However it's now a lot easier to tune this table, just change the TBM define.

#define TBM 90/100  - to decrease the table values with 10%

#define TBM 120/100  - to increase the table values with 20%

Playing 10,000 bullet (15+0.1) games with TBM=90 gave 50.8% with a LOS=99.2%

Various of such 100/100 defines are present in the following files:

. evaluate.cpp

. pawns.cpp

. types.h (the piece values)

A second example, in types.h we tried to tune the piece values with the same percentage, after some tries we got:

  #define PVM 96/100  // [95/100] - 10,000 | 50.7% | LOS=97.5%

  #define PVE 96/100  // [96/100] - 10,000 | 50.9% | LOS=99.3%

  #define NVM 96/100

  #define NVE 96/100

  #define BVM 96/100

  #define BVE 96/100

  #define RVM 96/100

  #define RVE 96/100

  #define QVM 96/100

  #define QVE 96/100

Which basically means Stockfish 9 becomes less materialistic.


Installation and operation

In a nutshell

. Install the download in the root of the C-drive (mandatory), it will create the folder MinGW which is the compiler.

. Go to the folder C:\MinGW\sf9\src it's where the source files are.

. Make changes.

. Double click c.bat, the changes are compiled and the produced SF9x executable is moved to C:\MinGW\cc folder.

. Go to C:\MinGW\cc folder.

. Double click either bullet.bat | blitz.bat or long.bat, the testing with cutechess starts.

. That's all.

The details

. From the  C:\MinGW\cc folder double click SF9.EXE and type bench, the number of nodes must be 5.023.629.

. bullet.bat will play 10,000 games between (the original) SF9 and (the complied) SF9x at 15+0.1

. blitz.bat will play 10,000 games between (the original) SF9 and (the complied) SF9x at 40/15 (0,3.75 sec average)

. long.bat will play 10,000 games between (the original) SF9 and (the complied) SF9x at 40/40 (1 second average)

. The openings file 25000.pgn contains 25,000 unique openings.

Modifying cutechess batch files, blitz.bat as an example.

cutechess-cli -concurrency 4 -engine name=sf9x cmd=sf9x.exe proto=uci -engine name=sf9 cmd=sf9.exe proto=uci -each restart=on tc=40/15 timemargin=90000 -draw movenumber=160 movecount=3 score=100 -resign movecount=5 score=900 -rounds 10000 -repeat -pgnout all.pgn -openings file=25000.pgn plies=20

-concurrency 4 - cutechess will use 4 threads.

-rounds 10000 - cutechess will play 10,000 games.

timemargin=90000 - set to 90 seconds to avoid any time forfeit either due bugs or a busy PC.

For more info (options) double click the cutechess-cli.6.html documentation if you are not familiar with cutechess.



In pawns.cpp isolated and backward pawns are penalized with a fixed value, indepedent where the pawns are on the board.

  // Isolated pawn penalty

  #define IP 100/100

  const Score Isolated = S(13*IP, 18*IP);

  // Backward pawn penalty

  #define BP 100/100

  const Score Backward = S(24*BP, 12*BP);

For the middlegame it's much better (5-10 elo) to use a piece_square_table, as center pawns are much more vulnerable than flank pawns. And secondly if such weak pawns are on an open file they are even more vulnerable, for this purpose use a second piece_square_table, or doubling the penalty is another option.


Final remark

The purpose of this software is not to create another Stockfish clone but:

1. to create interest in chess programming making things more easy;

2. to contribute found improvements to the Stockfish team;

3. add more #define 100/100 options yourself.



Tord Romstad, Marco Costalba and Joona Kiisk for Stockfish.

Ilari Pihlajisto, Arto Jonsson for cutechess-clil

MinGW, the compiler