Piece/square table challenge

Discussion of chess software programming and technical issues.

Moderator: Ras

Tennison
Posts: 183
Joined: Sat Nov 26, 2011 2:02 pm

Re: Piece/square table challenge

Post by Tennison »

A Gift for the TalkChess Members :

Toga Michniewski 1.0

Binary file : Toga with Tomasz Michniewski's PST values.

Complete pack

Toga Braesch 1.0

Binary file : Toga with Lucas Braesch's PST values.

Complete pack

Toga Hair 1.0

Binary file : Toga with Adam Hair's PST values.

Complete pack
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Piece/square table challenge

Post by Evert »

I've finally taken a moment to extract Leonidas' piece square tables. With some modifications, they are as follows:

Code: Select all

#define PAWN_VAL 100 
#define KNIGHT_VAL 300 
#define BISHOP_VAL 325 
#define ROOK_VAL 500 
#define ROOK_VAL 950 

const int pstKingMg[64] =  
{ 
 32,  29,  26,  26,  26,  26,  29,  32, 
 28,   5,  -1,  -1,  -1,  -1,   5,  28, 
 24,  -2, -28, -28, -28, -28,  -2,  24, 
 23,  -3, -29, -49, -49, -29,  -3,  23, 
 22,  -4, -30, -50, -50, -30,  -4,  22, 
 21,  -5, -31, -31, -31, -31,  -5,  21, 
 13, -10, -16, -16, -16, -16, -10,  13, 
 25,  22,  19,  19,  19,  19,  22,  25, 
};

const int pstKnightMg[64] = 
{ 
-10,  -7,  -4,  -4,  -4,  -4,  -7, -10, 
 -7,  -4,   2,   2,   2,   2,  -4,  -7, 
 -4,   2,   8,   8,   8,   8,   2,  -4, 
 -4,   2,   8,   8,   8,   8,   2,  -4, 
 -4,   2,   8,   8,   8,   8,   2,  -4, 
 -4,   2,   8,   8,   8,   8,   2,  -4, 
 -7,  -4,   2,   2,   2,   2,  -4,  -7, 
-10,  -7,  -4,  -4,  -4,  -4,  -7, -10, 
};

const int pstBishopMg[64] =  
{ 
 -2,  -2,  -2,  -2,  -2,  -2,  -2,  -2, 
 -2,   2,   2,   2,   2,   2,   2,  -2, 
 -2,   2,   6,   6,   6,   6,   2,  -2, 
 -2,   2,   6,  10,  10,   6,   2,  -2, 
 -2,   2,   6,  10,  10,   6,   2,  -2, 
 -2,   2,   6,   6,   6,   6,   2,  -2, 
 -2,   2,   2,   2,   2,   2,   2,  -2, 
 -2,  -2,  -2,  -2,  -2,  -2,  -2,  -2, 
};

const int pstRookMg[64] =  
{ 
  0,   0,   0,   0,   0,   0,   0,   0, 
  0,   0,   0,   0,   0,   0,   0,   0, 
  0,   0,   0,   0,   0,   0,   0,   0, 
  0,   0,   0,   0,   0,   0,   0,   0, 
  0,   0,   0,   0,   0,   0,   0,   0, 
  0,   0,   0,   0,   0,   0,   0,   0, 
  5,   5,   5,   5,   5,   5,   5,   5, 
  0,   0,   0,   0,   0,   0,   0,   0, 
};

const int pstQueenMg[64] =  
{ 
 -2,  -2,  -2,  -2,  -2,  -2,  -2,  -2, 
 -2,   2,   2,   2,   2,   2,   2,  -2, 
 -2,   2,   6,   6,   6,   6,   2,  -2, 
 -2,   2,   6,  10,  10,   6,   2,  -2, 
 -2,   2,   6,  10,  10,   6,   2,  -2, 
 -2,   2,   6,   6,   6,   6,   2,  -2, 
 -2,   2,   2,   2,   2,   2,   2,  -2, 
 -2,  -2,  -2,  -2,  -2,  -2,  -2,  -2, 
};

const int pstPawnMg[64] = 
{ 
//A1                                H1 
 -6,  -4,  -2,   0,   0,  -2,  -4,  -6, 
 -4,  -2,   0,   2,   2,   0,  -2,  -4, 
 -2,   0,   6,   4,   4,   6,   0,  -2, 
  0,   2,  10,  14,  14,  10,   2,   0, 
  0,   2,   8,  14,  14,   8,   2,   0, 
 -2,   0,   2,   4,   4,   2,   0,  -2, 
 -4,  -2,   0,   2,   2,   0,  -2,  -4, 
 -6,  -4,  -2,   0,   0,  -2,  -4,  -6, 
};


const int pstKingEg[64] =  
{ 
-24, -16,  -8,   0,   0,  -8, -16, -24, 
-16,  -8,   0,   8,   8,   0,  -8, -16, 
 -8,   0,   8,  16,  16,   8,   0,  -8, 
  0,   8,  16,  24,  24,  16,   8,   0, 
  0,   8,  16,  24,  24,  16,   8,   0, 
 -8,   0,   8,  16,  16,   8,   0,  -8, 
-16,  -8,   0,   8,   8,   0,  -8, -16, 
-24, -16,  -8,   0,   0,  -8, -16, -24, 
};

const int pstKnightEg[64] = 
{ 
-10,  -7,  -4,  -4,  -4,  -4,  -7, -10, 
 -7,  -4,   2,   2,   2,   2,  -4,  -7, 
 -4,   2,   8,   8,   8,   8,   2,  -4, 
 -4,   2,   8,   8,   8,   8,   2,  -4, 
 -4,   2,   8,   8,   8,   8,   2,  -4, 
 -4,   2,   8,   8,   8,   8,   2,  -4, 
 -7,  -4,   2,   2,   2,   2,  -4,  -7, 
-10,  -7,  -4,  -4,  -4,  -4,  -7, -10, 
};

const int pstBishopEg[64] =  
{ 
 -2,  -2,  -2,  -2,  -2,  -2,  -2,  -2, 
 -2,   2,   2,   2,   2,   2,   2,  -2, 
 -2,   2,   6,   6,   6,   6,   2,  -2, 
 -2,   2,   6,  10,  10,   6,   2,  -2, 
 -2,   2,   6,  10,  10,   6,   2,  -2, 
 -2,   2,   6,   6,   6,   6,   2,  -2, 
 -2,   2,   2,   2,   2,   2,   2,  -2, 
 -2,  -2,  -2,  -2,  -2,  -2,  -2,  -2, 
};

const int pstRookEg[64] =  
{ 
  0,   0,   0,   0,   0,   0,   0,   0, 
  0,   0,   0,   0,   0,   0,   0,   0, 
  0,   0,   0,   0,   0,   0,   0,   0, 
  0,   0,   0,   0,   0,   0,   0,   0, 
  0,   0,   0,   0,   0,   0,   0,   0, 
  0,   0,   0,   0,   0,   0,   0,   0, 
  0,   0,   0,   0,   0,   0,   0,   0, 
  0,   0,   0,   0,   0,   0,   0,   0, 
};

const int pstQueenEg[64] =  
{ 
 -2,  -2,  -2,  -2,  -2,  -2,  -2,  -2, 
 -2,   2,   2,   2,   2,   2,   2,  -2, 
 -2,   2,   6,   6,   6,   6,   2,  -2, 
 -2,   2,   6,  10,  10,   6,   2,  -2, 
 -2,   2,   6,  10,  10,   6,   2,  -2, 
 -2,   2,   6,   6,   6,   6,   2,  -2, 
 -2,   2,   2,   2,   2,   2,   2,  -2, 
 -2,  -2,  -2,  -2,  -2,  -2,  -2,  -2, 
};

const int pstPawnEg[64] = 
{ 
//A1                                H1 
-6,  -4,  -2,   0,   0,  -2,  -4,  -6, 
 -1,   1,   3,   5,   5,   3,   1,  -1, 
 10,  12,  18,  16,  16,  18,  12,  10, 
 27,  29,  37,  41,  41,  37,  29,  27, 
 48,  50,  56,  62,  62,  56,  50,  48, 
 73,  75,  77,  79,  79,  77,  75,  73, 
104, 106, 108, 110, 110, 108, 106, 104, 
 -6,  -4,  -2,   0,   0,  -2,  -4,  -6, 
};
The modifications from the way they are used in the program are as follows:
  • The middle-game king table is not actually used in this form, but is constructed depending on the material on the board and scaled with "game phase", which is a very different function from what is proposed here. As such, this is an approximation.
  • The same holds for the rook PST, which here includes a "rook on the 7th" bonus that isn't part of the PST in Leonidas, but is awarded to a rook on the 7th as long as there are also pawns there.
  • Incentive to push the pawns forward in the endgame is likewise not part of the PST in Leonidas, but part of the pawn evaluation.
The reason I decided to include these things in the PSTs here is that they are effectively there, but calculated separately in order to be able to deal more naturally with different variants.
If you will, these are effectively Leonidas' PSTs for normal chess.

I may have mentioned it earlier, but I'll summarise again how these tables were generated (they're not tuned as such): for normal pieces (NBRQ) they are simply based on the mobility on an empty board, which is why the rook PST averages out to 0 and the queen PST is equal to the bishop. For the king, the PST is -sum over all pieces (weight*pst) and some penalty for advancing the king away from the back rank (this is an approximation, Leonidas actually uses a pawn shelter condition). The idea behind this is that a "safe" square is a square that is "hard" for enemy pieces to move to, or conversely, a square where the enemy pieces would be badly placed. The pawn table is ad-hoc and the end-game king table is simply a centralisation table.

As such, there is very little manual tuning that went into generating these tables and they are in a way the opposite of Adam's tables posted earlier: they're entirely theoretical.

I can do a similar extraction for Sjaak later (if this is useful; the tables may turn out to be so similar that there isn't much of a point), but for Jazz this will be a hopeless exercise because it doesn't use PSTs in the traditional sense (rather, it looks at the pawn structure and determines whether pieces are well placed or not). The only exception I think is that it does aim for centralisation of its knights.
lucasart
Posts: 3241
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: Piece/square table challenge

Post by lucasart »

I was wondering about Toga. Is Jerry still developping it? Where can we find the latest and strongest Toga? The last one I have is TogaII 3.0
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
Tennison
Posts: 183
Joined: Sat Nov 26, 2011 2:02 pm

Re: Piece/square table challenge

Post by Tennison »

Yes Jerry is always working on original Toga. But I think he hasn't lot of time actually.

Last official version is Toga 3.0.
Last development version is Toga 280513 (maybe 30 elo stronger than Toga 3.0).

Jerry was thinking about releasing Toga 4.0 for July/August 2013 but I don't see anything.
ernest
Posts: 2046
Joined: Wed Mar 08, 2006 8:30 pm

Re: Piece/square table challenge

Post by ernest »

Tennison wrote:Last official version is Toga 3.0.
I think the official name is Toga II 3.0
Tennison
Posts: 183
Joined: Sat Nov 26, 2011 2:02 pm

Re: Piece/square table challenge

Post by Tennison »

You're right, I forget to write the "II" ;-)
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Piece/square table challenge

Post by Evert »

I've done a little experiment using Adam's knight middle-game table.

Let us assume that the table in question is due to a combination of terms, basically centralisation, advancement and mobility (which is ~centralisation) of the knight, and its ability to attack a king on G8, and let us assume that the function is linear. We then have a function of the form

Code: Select all

         knight_table_fit[s] = w1 * centre_table[s] +
                               w2 * advance_table[s] +
                               w3 * knight_tropism[G8][s] +
                               w4 * piece_table[KNIGHT][s] +
                               w5 * 100;
Here, piece_table[KNIGHT] is the piece-square table for the knight that I posted earlier (a function of mobility). advance_table is simply a table that has all squares on the back rank=0, first rank=1, second rank=2 etc. The centre_table is

Code: Select all

   0, 2,  4,  6,  6,  4, 2, 0,
   2, 4,  6,  8,  8,  6, 4, 2,
   4, 6,  8, 10, 10,  8, 6, 4,
   6, 8, 10, 12, 12, 10, 8, 6,
   6, 8, 10, 12, 12, 10, 8, 6,
   4, 6,  8, 10, 10,  8, 6, 4,
   2, 4,  6,  8,  8,  6, 4, 2,
   0, 2,  4,  6,  6,  4, 2, 0
and knight_tropism[G8] is a table counting the number of moves is takes a knight to reach a given square (in this case, G8):

Code: Select all

  5   4   5   4   5   4   5   4 
  4   5   4   3   4   3   4   3 
  5   4   3   4   3   4   3   4 
  4   3   4   3   2   3   2   3 
  3   4   3   2   3   2   3   2 
  4   3   2   3   4   1   2   1 
  3   4   3   2   1   2   3   2 
  4   3   2   3   2   3   0   3 
This is the only asymmetric table of the 4 I'm using as a base (I could also try, but haven't yet, a "normal" tropism table). I was too lazy to write a proper fitting function, so I monte-carloed the coefficients (if I have a little time later I'll do it properly, a least-squares fit of 5 variables is hardly difficult). The best-fitting table I found so far is this (on the left, on the right are the residuals):

Code: Select all

 -86  -67  -65  -59  -67  -56  -76  -78     -13   37   -1   -5   38   37   15   -3 
 -57  -55  -22  -16  -25  -14  -47  -49       1   24   -6   15   18   -6    5   38 
 -45  -13   19    8   16   10   -4  -37       7   -3  -19    6   -8   -7    7   -5 
 -30    2   18   23   32   26   10  -21      16   -2  -16  -20  -13  -14   23   14 
 -12    3   36   42   33   44   11   -3      -2   -7  -11   -9  -23  -11    3   46 
  -8   24   56   45   37   65   32   16     -14   -6    4   19   87   78   23  -10 
  -1    1   33   39   48   42    9    7     -33   23   21   35   12   80   -7   22 
 -10    8   27   16   25   19   33   -2     -50   -8  -27  -16  -25  -19  -33    2 
with coefficients -1.26987, 9.64933, -8.48597, 4.45139 and 0.0887156. I assumed that a table value of 0 means no data, so I discarded those points when calculating the quality of the fit.
PK
Posts: 904
Joined: Mon Jan 15, 2007 11:23 am
Location: Warsza

Re: Piece/square table challenge

Post by PK »

Results for today:

Code: Select all

    Program                          Elo    +   -   Games   Score   Av.Op.  Draws

  1 Rodent 1.3 (build adam)        : 2081   11  11  3642    64.9 %   1974   18.8 %
  2 Rodent 1.3 (build pawel)       : 2060   10  10  3641    61.4 %   1979   22.3 %
  3 Rodent 1.3 (build lyudmil)     : 2016   13  13  2060    46.9 %   2038   22.4 %
  4 Rodent 1.3 (build mikko+)      : 2006   12  12  2582    50.4 %   2003   21.4 %
  5 Rodent 1.3 (build ufo)         : 2000   10  10  3524    51.8 %   1987   24.5 %
  6 Rodent 1.3 (build lucas)       : 1965   13  13  2026    42.1 %   2021   24.7 %
  7 Rodent 1.3 (build ERROR)       : 1935   14  14  2036    36.9 %   2028   22.0 %
  8 Rodent 1.3 (build daniel)      : 1836   15  15  2063    23.7 %   2040   17.5 %
Lyudmil's set comes third (and the best among "general use" tables). It is worth nothing that it scored worse against Mikko's set, but relatively better against "doctored" sets).

More news tomorrow. Enjoy!
Lyudmil Tsvetkov
Posts: 6052
Joined: Tue Jun 12, 2012 12:41 pm

Re: Piece/square table challenge

Post by Lyudmil Tsvetkov »

PK wrote:Results for today:

Code: Select all

    Program                          Elo    +   -   Games   Score   Av.Op.  Draws

  1 Rodent 1.3 (build adam)        : 2081   11  11  3642    64.9 %   1974   18.8 %
  2 Rodent 1.3 (build pawel)       : 2060   10  10  3641    61.4 %   1979   22.3 %
  3 Rodent 1.3 (build lyudmil)     : 2016   13  13  2060    46.9 %   2038   22.4 %
  4 Rodent 1.3 (build mikko+)      : 2006   12  12  2582    50.4 %   2003   21.4 %
  5 Rodent 1.3 (build ufo)         : 2000   10  10  3524    51.8 %   1987   24.5 %
  6 Rodent 1.3 (build lucas)       : 1965   13  13  2026    42.1 %   2021   24.7 %
  7 Rodent 1.3 (build ERROR)       : 1935   14  14  2036    36.9 %   2028   22.0 %
  8 Rodent 1.3 (build daniel)      : 1836   15  15  2063    23.7 %   2040   17.5 %
Lyudmil's set comes third (and the best among "general use" tables). It is worth nothing that it scored worse against Mikko's set, but relatively better against "doctored" sets).

More news tomorrow. Enjoy!
Thanks Pawel!

Very nice indeed of you to do all that testing work for us all. I imagine you sacrificed much to do that.

Bronze is good. :D I suppose what the tables lack is bonus for passers on 7th, 8th ranks, bonus for pawns on the 2nd rank on the king side (to imitate king safety), bonus for pawns on the 5th and 6th ranks on the king side (to imitate storming pawns), slanting of pieces kingwise/piece attacking bonus for squares attacking the short-castled king, etc. I think adding those features would score better, but I consider this somewhat artificial.

Thanks again.
jd1
Posts: 269
Joined: Wed Oct 24, 2012 2:07 am

Re: Piece/square table challenge

Post by jd1 »

lucasart wrote:I was wondering about Toga. Is Jerry still developping it? Where can we find the latest and strongest Toga? The last one I have is TogaII 3.0
Hi Lucas,

Yes, I am still developing Toga, but lately I have only been tidying up the code (the "Toga" part, not the "Fruit" part!). My computers have been required for another project.

The latest development version available is Toga II 280513 as Ben said, available from the Toga Developers Discussion Board, and it is maybe 20-30 elo stronger than Toga II 3.0. My private dev. version is slightly (10 elo?) stronger than that.

Jerry