Piece/square table challenge

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

PK
Posts: 895
Joined: Mon Jan 15, 2007 11:23 am
Location: Warsza

Piece/square table challenge

Post by PK »

Because of numerous discussions about correct piece/square table values, I decided to issue a challenge and use some resources for the following competition. Below I publish a template which You can fill with values of Your choice. These values will constitute the entire evaluation function of a stripped-down version of my engine. The winner gets a title of "king of piece/square tables" and can decide which tuneable feature will be added in the next edition of the eval competition.

The goals of this challenge are
- to create a "comunity eval function" (or hopefully a set of such functions ordered by complexity) that can be plugged in into any engine
- to use them as a measuring tool and a ploy to get some bragging rights (i.e. "my real eval function beats this supposedly mighty value set by XXX Elo points")
- to make fun of our numbers and assumptions

Results will be published in the form of a rating list, created by pitting dumbed-down versions of Rodent against each other.

Beside these values, dumbed-down Rodent eval will use CheckmateHelper() function and will scale down score for drawish endgames. I feel that absence of these features might flatten the results. Midgame/endgame scores will be scaled linearily in 24 steps, using sum of material on both sides (B,N = 1, R = 2, Q = 4, sum cannot exceed 24)

Code: Select all


// values by Tomasz Michniewski taken from http://chessprogramming.wikispaces.com/Simplified+evaluation+function

#define PAWN_VAL 100
#define KNIGHT_VAL 320
#define BISHOP_VAL 330
#define ROOK_VAL 500
#define ROOK_VAL 900

const int pstPawnMg[64] = 
{
//A1                                H1
 0,  0,  0,  0,  0,  0,  0,  0,
 5, 10, 10,-20,-20, 10, 10,  5,
 5, -5,-10,  0,  0,-10, -5,  5,
 0,  0,  0, 20, 20,  0,  0,  0,
 5,  5, 10, 25, 25, 10,  5,  5,
 10, 10, 20, 30, 30, 20, 10, 10,
 50, 50, 50, 50, 50, 50, 50, 50,
//A8                                H8
 };

const int pstPawnEg[64] = 
{
 0,  0,  0,  0,  0,  0,  0,  0,
 5, 10, 10,-20,-20, 10, 10,  5,
 5, -5,-10,  0,  0,-10, -5,  5,
 0,  0,  0, 20, 20,  0,  0,  0,
 5,  5, 10, 25, 25, 10,  5,  5,
 10, 10, 20, 30, 30, 20, 10, 10,
 50, 50, 50, 50, 50, 50, 50, 50,
 };


const int pstKnightMg[64] = 
{
-50,-40,-30,-30,-30,-30,-40,-50,
-40,-20,  0,  5,  5,  0,-20,-40,
-30,  5, 10, 15, 15, 10,  5,-30,
-30,  0, 15, 20, 20, 15,  0,-30,
-30,  5, 15, 20, 20, 15,  5,-30,
-30,  0, 10, 15, 15, 10,  0,-30,
-40,-20,  0,  0,  0,  0,-20,-40,
-50,-40,-30,-30,-30,-30,-40,-50,
};

const int pstKnightEg[64] = 
{
-50,-40,-30,-30,-30,-30,-40,-50,
-40,-20,  0,  5,  5,  0,-20,-40,
-30,  5, 10, 15, 15, 10,  5,-30,
-30,  0, 15, 20, 20, 15,  0,-30,
-30,  5, 15, 20, 20, 15,  5,-30,
-30,  0, 10, 15, 15, 10,  0,-30,
-40,-20,  0,  0,  0,  0,-20,-40,
-50,-40,-30,-30,-30,-30,-40,-50,
};

const int pstBishopMg[64] =  
{
-20,-10,-10,-10,-10,-10,-10,-20,
-10,  5,  0,  0,  0,  0,  5,-10,
-10, 10, 10, 10, 10, 10, 10,-10,
-10,  0, 10, 10, 10, 10,  0,-10,
-10,  5,  5, 10, 10,  5,  5,-10,
-10,  0,  5, 10, 10,  5,  0,-10,
-10,  0,  0,  0,  0,  0,  0,-10,
-20,-10,-10,-10,-10,-10,-10,-20,
};

const int pstBishopEg[64] =  
{
-20,-10,-10,-10,-10,-10,-10,-20,
-10,  5,  0,  0,  0,  0,  5,-10,
-10, 10, 10, 10, 10, 10, 10,-10,
-10,  0, 10, 10, 10, 10,  0,-10,
-10,  5,  5, 10, 10,  5,  5,-10,
-10,  0,  5, 10, 10,  5,  0,-10,
-10,  0,  0,  0,  0,  0,  0,-10,
-20,-10,-10,-10,-10,-10,-10,-20,
};

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

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

const int pstQueenMg[64] =  
{
-20,-10,-10, -5, -5,-10,-10,-20,
-10,  0,  5,  0,  0,  0,  0,-10,
-10,  5,  5,  5,  5,  5,  0,-10,
  0,  0,  5,  5,  5,  5,  0, -5,
 -5,  0,  5,  5,  5,  5,  0, -5,
-10,  0,  5,  5,  5,  5,  0,-10,
-10,  0,  0,  0,  0,  0,  0,-10,
-20,-10,-10, -5, -5,-10,-10,-20,
};

const int pstQueenEg[64] =  
{
-20,-10,-10, -5, -5,-10,-10,-20,
-10,  0,  5,  0,  0,  0,  0,-10,
-10,  5,  5,  5,  5,  5,  0,-10,
 0,  0,  5,  5,  5,  5,  0, -5,
-5,  0,  5,  5,  5,  5,  0, -5,
-10,  0,  5,  5,  5,  5,  0,-10,
-10,  0,  0,  0,  0,  0,  0,-10,
-20,-10,-10, -5, -5,-10,-10,-20,
};

const int pstKingMg[64] =  
{
 20, 30, 10,  0,  0, 10, 30, 20,
 20, 20,  0,  0,  0,  0, 20, 20,
-10,-20,-20,-20,-20,-20,-20,-10,
-20,-30,-30,-40,-40,-30,-30,-20,
-30,-40,-40,-50,-50,-40,-40,-30,
-30,-40,-40,-50,-50,-40,-40,-30,
-30,-40,-40,-50,-50,-40,-40,-30,
-30,-40,-40,-50,-50,-40,-40,-30,
};

const int pstKingEg[64] =  
{
-50,-30,-30,-30,-30,-30,-30,-50,
-30,-30,  0,  0,  0,  0,-30,-30,
-30,-10, 20, 30, 30, 20,-10,-30,
-30,-10, 30, 40, 40, 30,-10,-30,
-30,-10, 30, 40, 40, 30,-10,-30,
-30,-10, 20, 30, 30, 20,-10,-30,
-30,-20,-10,  0,  0,-10,-20,-30,
-50,-40,-30,-20,-20,-30,-40,-50,
};
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: Piece/square table challenge

Post by lucasart »

You need to impose a restriction: PST must be unbiaised. Suppose your material values are suboptimal. Then any biais in PST could compensate. So when you load the PST, you must have a post processing function that removes the biais, by calculating the mean and substracting. It makes a more faire challenge.

The only one that can be biaised is the King one. Obviously each side always has exactly one King, so biais on King PST should have no impact.

Can we also modify the Piece values? Would make the challenge more interesting IMO.
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: Piece/square table challenge

Post by lucasart »

Here are my piece values and PST for your challenge:

Code: Select all

#define PAWN_VAL 100
#define KNIGHT_VAL 330
#define BISHOP_VAL 330
#define ROOK_VAL 540
#define QUEEN_VAL 1000

const int pstPawnMg[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,9,9,0,0,0
	0,0,0,18,18,0,0,0
	0,0,0,9,9,0,0,0
	0,0,0,0,0,0,0,0
	0,0,0,0,0,0,0,0
};

const int pstPawnEg[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 pstKnightMg[64] = {
	-60,-40,-30,-20,-20,-30,-40,-60
	-40,-20,-10,0,0,-10,-20,-40
	-30,-10,0,10,10,0,-10,-30
	-20,0,10,20,20,10,0,-20
	-20,0,10,20,20,10,0,-20
	-30,-10,0,10,10,0,-10,-30
	-40,-20,-10,0,0,-10,-20,-40
	-60,-40,-30,-20,-20,-30,-40,-60
};

const int pstKnightEg[64] = {
	-18,-12,-9,-6,-6,-9,-12,-18
	-12,-6,-3,0,0,-3,-6,-12
	-9,-3,0,3,3,0,-3,-9
	-6,0,3,6,6,3,0,-6
	-6,0,3,6,6,3,0,-6
	-9,-3,0,3,3,0,-3,-9
	-12,-6,-3,0,0,-3,-6,-12
	-18,-12,-9,-6,-6,-9,-12,-18
};

const int pstBishopMg[64] = {
	-8,-8,-6,-4,-4,-6,-8,-8
	-8,0,-2,0,0,-2,0,-8
	-6,-2,4,2,2,4,-2,-6
	-4,0,2,8,8,2,0,-4
	-4,0,2,8,8,2,0,-4
	-6,-2,4,2,2,4,-2,-6
	-8,0,-2,0,0,-2,0,-8
	-18,-18,-16,-14,-14,-16,-18,-18
};

const int pstBishopEg[64] = {
	-18,-12,-9,-6,-6,-9,-12,-18
	-12,-6,-3,0,0,-3,-6,-12
	-9,-3,0,3,3,0,-3,-9
	-6,0,3,6,6,3,0,-6
	-6,0,3,6,6,3,0,-6
	-9,-3,0,3,3,0,-3,-9
	-12,-6,-3,0,0,-3,-6,-12
	-18,-12,-9,-6,-6,-9,-12,-18
};

const int pstRookMg[64] = {
	-9,-3,0,3,3,0,-3,-9
	-1,5,8,11,11,8,5,-1
	-9,-3,0,3,3,0,-3,-9
	-9,-3,0,3,3,0,-3,-9
	-9,-3,0,3,3,0,-3,-9
	-9,-3,0,3,3,0,-3,-9
	-9,-3,0,3,3,0,-3,-9
	-9,-3,0,3,3,0,-3,-9
};

const int pstRookEg[64] = {
	0,0,0,0,0,0,0,0
	8,8,8,8,8,8,8,8
	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 pstQueenMg[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
	-5,-5,-5,-5,-5,-5,-5,-5
};

const int pstQueenEg[64] = {
	-24,-16,-12,-8,-8,-12,-16,-24
	-16,-8,-4,0,0,-4,-8,-16
	-12,-4,0,4,4,0,-4,-12
	-8,0,4,8,8,4,0,-8
	-8,0,4,8,8,4,0,-8
	-12,-4,0,4,4,0,-4,-12
	-16,-8,-4,0,0,-4,-8,-16
	-24,-16,-12,-8,-8,-12,-16,-24
};

const int pstKingMg[64] = {
	-19,-9,-29,-49,-49,-29,-9,-19
	-12,-2,-22,-42,-42,-22,-2,-12
	-5,5,-15,-35,-35,-15,5,-5
	2,12,-8,-28,-28,-8,12,2
	9,19,-1,-21,-21,-1,19,9
	16,26,6,-14,-14,6,26,16
	30,40,20,0,0,20,40,30
	37,47,27,7,7,27,47,37
};

const int pstKingEg[64] = {
	-84,-56,-42,-28,-28,-42,-56,-84
	-56,-28,-14,0,0,-14,-28,-56
	-42,-14,0,14,14,0,-14,-42
	-28,0,14,28,28,14,0,-28
	-28,0,14,28,28,14,0,-28
	-42,-14,0,14,14,0,-14,-42
	-56,-28,-14,0,0,-14,-28,-56
	-84,-56,-42,-28,-28,-42,-56,-84
};
Edit: Ah crap! I put them from Rank 8 downto Rank 1 instead of the otherway around :-S
Last edited by lucasart on Thu Jan 09, 2014 11:06 am, edited 2 times in total.
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Piece/square table challenge

Post by Evert »

Interesting idea, but I wonder what we will really learn from it. I'll take the opportunity to describe what I've been experimenting with in terms of piece square tables, and then I'll see if I can extract something useful for you later.

One note about the CPW tables: these contain some stuff that's meant to compensate for lack of more detailed chess knowledge. In the presence of such knowledge having this information in the PSQ is probably counter-productive.

For my own PSQs I try to avoid things like giving a rook a bonus on the 7th rank. Instead, I give a bonus to a rook that is on the rank where it can attack the base of the enemy pawn structure and/or a rook that is on a rank or file where it cuts off the enemy king. This takes care of "rook on the 7th" in situations where that makes sense, but it generalises better to positions where there is nothing of interest on the 7th rank. I am also very careful about pawn advancement bonuses; it seems better to decide this on a pawn-by-pawn basis rather than awarding the bonus indiscriminately.

Apart from those considerations, my piece square tables for each regular piece (non-pawn, non-king) are derived from mobility on an empty board. This is somewhat redundant with actual mobility, but so is simply centralising pieces. In practice the board is rarely empty, of course, so this seems not too bad. I think (it's been a while) I use a combination of "one-step" and "two-step" mobility. The main point of this is to increase the bonus of the actual centre squares for the knights; for sliders the second term just adds a constant (since they can reach the entire board in two moves). The tables are "centred" such that the board-average value is 0.

For the king this is of course no good. The king PSQ is really a competition between the need to centralise the king (in the end game) and to keep it safe (during the opening and middle game). Safe, in this case, means that it stays in a place where it is less likely to be attacked, which is where the enemy pieces are less likely to penetrate, which is where the enemy pieces have low mobility. In other words, it's a weighted sum of the PSQs for the enemy army, again centred. This requires a bit of twiddling because I still want to avoid unnecessary "Kg1-h1" moves, and of course g1 and h2 are not generally equal in terms of king safety in the middle game.

Sounds complicated, so why am I doing it this way? Well, I'm hoping that if I do this right it will self-adjust in a natural way to chess variants (with different armies). So far it seems no worse than what I had before, but it's been a while since I played around with it.
PK
Posts: 895
Joined: Mon Jan 15, 2007 11:23 am
Location: Warsza

Re: Piece/square table challenge

Post by PK »

Yes, piece values are part of the template, and can be changed at will.
PK
Posts: 895
Joined: Mon Jan 15, 2007 11:23 am
Location: Warsza

Re: Piece/square table challenge

Post by PK »

@Lucas, fortunately Your tables are symmetrical, so turning them upside down wasn't too much work. the match is already underway.

@Evert, I know that implementing knowledge outside of piece/square tables may be much better, but there must be a starting point somewhere. I imagine that as more specific rules are added, knowledge from piece/square tables may be modified or even removed. my rook on seventh bonus evolved precisely like that.
Adam Hair
Posts: 3226
Joined: Wed May 06, 2009 10:31 pm
Location: Fuquay-Varina, North Carolina

Re: Piece/square table challenge

Post by Adam Hair »

These PST values were determined from ~450,000 long time control engine vs engine matches (2700+ CCRL Elo), using Larry Kaufman's "The Evaluation of Material Imbalances" as a guideline.

I found the average score for White when a White piece occupied a square for 6 plies during a game after leaving the opening book, and the same for the same Black piece in its comparable square. I adjusted the scores to remove White advantage, then converted to Elo. Then I assumed that 1 Elo equals 1 centipawn.

For midgame values, I looked at moves 12 through 40, with at least 1 rook,2 minors, and 4 pawns on each side and no material imbalance. For the endgame, only after move 40 was considered and no more than 1 rook, 2 minors, and 4 pawns on each side (no material imbalance).

The endgame statistics for some pieces/squares was sparse. So, for the endgame tables I used the more statistically significant information to find 3 dimensional surfaces to model the PST values.

I used the values with Dan Honeycutt's engine Cupcake, which has some but not much chess knowledge encoded (on purpose). In one test (see below), they seemed to be worth about 19 Elo over Cupcake's original PSTs.

Code: Select all

PST test
   # ENGINE            : RATING    POINTS  PLAYED    (%)
   1 Cupcake_modified4 &#58;    8.5    3044.5    6000   50.7% <--- PST derived from engine data
   2 Cupcake_modified3 &#58;    8.3    2819.0    5566   50.6%
   3 Cupcake_modified  &#58;    4.2    6637.0   13114   50.6%
   4 Cupcake_raw       &#58;    4.0    6567.0   12979   50.6%
   5 Cupcake_modified2 &#58;    1.5    3259.5    6524   50.0%
   6 Cupcake_model     &#58;   -3.0    3890.0    7800   49.9%
   7 Cupcake_current   &#58;  -10.4    3754.0    7725   48.6% <---- original values
   8 Cupcake_crafty    &#58;  -13.1    3283.0    6800   48.3%
I doubt these values would work for a more advanced engine, but they may work well for an engine with no knowledge.

Code: Select all

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

const int pstPawnMg&#91;64&#93; =
&#123;
//A1                                H1
0, 0, 0, 0, 0, 0, 0, 0
-1, -7, -11, -35, -13, 5, 3, -5
1, 1, -6, -19, -6, -7, -4, 10
1, 14, 8, 4, 5, 4, 10, 7
9, 30, 23, 31, 31, 23, 17, 11
21, 54, 72, 56, 77, 95, 71, 11
118, 121, 173, 168, 107, 82, -16, 22
 0, 0, 0, 0, 0, 0, 0, 0
//A8                                H8
&#125;;

const int pstPawnEg&#91;64&#93; =
&#123;
0, 0, 0, 0, 0, 0, 0, 0
-17, -17, -17, -17, -17, -17, -17, -17
-11, -11, -11, -11, -11, -11, -11, -11
-7, -7, -7, -7, -7, -7, -7, -7
16, 16, 16, 16, 16, 16, 16, 16
55, 55, 55, 55, 55, 55, 55, 55
82, 82, 82, 82, 82, 82, 82, 82
0, 0, 0, 0, 0, 0, 0, 0
&#125;;
   
const int pstKnightMg&#91;64&#93; =
&#123;
-99, -30, -66, -64, -29, -19, -61, -81
-56, -31, -28, -1, -7, -20, -42, -11
-38, -16, 0, 14, 8, 3, 3, -42
-14, 0, 2, 3, 19, 12, 33, -7
-14, -4, 25, 33, 10, 33, 14, 43
-22, 18, 60, 64, 124, 143, 55, 6
-34, 24, 54, 74, 60, 122, 2, 29
-60, 0, 0, 0, 0, 0, 0, 0
&#125;;
 
const int pstKnightEg&#91;64&#93; = 
&#123;
-99, -99, -94, -88, -88, -94, -99, -99
-81, -62, -49, -43, -43, -49, -62, -81
-46, -27, -15, -9, -9, -15, -27, -46
-22, -3, 10, 16, 16, 10, -3, -22
-7, 12, 25, 31, 31, 25, 12, -7
-2, 17, 30, 36, 36, 30, 17, -2
-7, 12, 25, 31, 31, 25, 12, -7
-21, -3, 10, 16, 16, 10, -3, -21
&#125;;
 
const int pstBishopMg&#91;64&#93; =  
&#123; 
-7, 12, -8, -37, -31, -8, -45, -67
15, 5, 13, -10, 1, 2, 0, 15
5, 12, 14, 13, 10, -1, 3, 4
1, 5, 23, 32, 21, 8, 17, 4
-1, 16, 29, 27, 37, 27, 17, 4
7, 27, 20, 56, 91, 108, 53, 44
-24, -23, 30, 58, 65, 61, 69, 11
0, 0, 0, 0, 0, 0, 0, 0
&#125;;

const int pstBishopEg&#91;64&#93; =
&#123;
-27, -21, -17, -15, -15, -17, -21, -27
-10, -4, 0, 2, 2, 0, -4, -10
2, 8, 12, 14, 14, 12, 8, 2
11, 17, 21, 23, 23, 21, 17, 11
14, 20, 24, 26, 26, 24, 20, 14
13, 19, 23, 25, 25, 23, 19, 13
8, 14, 18, 20, 20, 18, 14, 8
-2, 4, 8, 10, 10, 8, 4, -2
&#125;;

const int pstRookMg&#91;64&#93; =
&#123;
-2, -1, 3, 1, 2, 1, 4, -8
-26, -6, 2, -2, 2, -10, -1, -29
-16, 0, 3, -3, 8, -1, 12, 3
-9, -5, 8, 14, 18, -17, 13, -13
19, 33, 46, 57, 53, 39, 53, 16
24, 83, 54, 75, 134, 144, 85, 75
46, 33, 64, 62, 91, 89, 70, 104
84, 0, 0, 37, 124, 0, 0, 153
&#125;;

const int pstRookEg&#91;64&#93; =
&#123;
-32, -31, -30, -29, -29, -30, -31, -32
-27, -25, -24, -24, -24, -24, -25, -27
-15, -13, -12, -12, -12, -12, -13, -15
1, 2, 3, 4, 4, 3, 2, 1
15, 17, 18, 18, 18, 18, 17, 15
25, 27, 28, 28, 28, 28, 27, 25
27, 28, 29, 30, 30, 29, 28, 27
16, 17, 18, 19, 19, 18, 17, 16
&#125;;

const int pstQueenMg&#91;64&#93; =
&#123;
1, -10, -11, 3, -15, -51, -83, -13
-7, 3, 2, 5, -1, -10, -7, -2
-11, 0, 12, 2, 8, 11, 7, -6
-9, 5, 7, 9, 18, 17, 26, 4
-6, 0, 15, 25, 32, 9, 26, 12
-16, 10, 13, 25, 37, 30, 15, 26
1, 11, 35, 0, 16, 55, 39, 57
-13, 6, -42, 0, 29, 0, 0, 102
&#125;;

const int pstQueenEg&#91;64&#93; =
&#123;
-61, -55, -52, -50, -50, -52, -55, -61
-31, -26, -22, -21, -21, -22, -26, -31
-8, -3, 1, 3, 3, 1, -3, -8
9, 14, 17, 19, 19, 17, 14, 9
19, 24, 28, 30, 30, 28, 24, 19
23, 28, 32, 34, 34, 32, 28, 23
21, 26, 30, 31, 31, 30, 26, 21
12, 17, 21, 23, 23, 21, 17, 12
&#125;;

const int pstKingMg&#91;64&#93; =
&#123;
0, 0, 0, -9, 0, -9, 25, 0
-9, -9, -9, -9, -9, -9, -9, -9
-9, -9, -9, -9, -9, -9, -9, -9
-9, -9, -9, -9, -9, -9, -9, -9
-9, -9, -9, -9, -9, -9, -9, -9
-9, -9, -9, -9, -9, -9, -9, -9
-9, -9, -9, -9, -9, -9, -9, -9
-9, -9, -9, -9, -9, -9, -9, -9
&#125;;

const int pstKingEg&#91;64&#93; =
&#123;
-34, -30, -28, -27, -27, -28, -30, -34
-17, -13, -11, -10, -10, -11, -13, -17
-2, 2, 4, 5, 5, 4, 2, -2
11, 15, 17, 18, 18, 17, 15, 11
22, 26, 28, 29, 29, 28, 26, 22
31, 34, 37, 38, 38, 37, 34, 31
38, 41, 44, 45, 45, 44, 41, 38
42, 46, 48, 50, 50, 48, 46, 42
&#125;;
PK
Posts: 895
Joined: Mon Jan 15, 2007 11:23 am
Location: Warsza

Re: Piece/square table challenge

Post by PK »

OK, this is my entry:

Code: Select all

#define PAWN_VAL 100
#define KNIGHT_VAL 325
#define BISHOP_VAL 335
#define ROOK_VAL 500
#define QUEEN_VAL 975

const int pstPawnMg&#91;64&#93; =
&#123;
//A1                                H1
  0,  0,  0,  0,  0,  0,  0,   0,
 10, 20,  0,  5,  5,  0, 20,  10,
-10,  0,  5, 15, 15,  5,  0, -10,
-15, -5, 10, 25, 25, 10, -5, -15,
-15, -5,  5, 15, 15,  5, -5, -15,
 45, 55, 65, 75, 75, 65, 55,  45,
105,115,125,135,135,125,115, 105,
  0,  0,  0,  0,  0,  0,  0,   0,
//A8                                H8
 &#125;;

const int pstPawnEg&#91;64&#93; =
&#123;
 0,  0,  0,  0,  0,  0,  0,   0,
 3,  1, -1, -3, -3, -1,  1,   3,
 3,  1, -1, -3, -3, -1,  1,   3,
 9,  6,  3,  0,  0,  3,  6,   9,
 12, 9,  6,  3,  3,  6,  9,  12,
 87,85, 83, 81, 81, 83, 85,  87,
 159,157,155,153,153,155,157,159,
 0,  0,  0,  0,  0,  0,  0,   0,
 &#125;;


const int pstKnightMg&#91;64&#93; =
&#123;
   -50, -40, -30, -25, -25, -30, -40, -50,
   -35, -25, -15, -10, -10, -15, -25, -35,
   -20, -10,   0,   5,   5,   0, -10, -20, 
   -10,   0,  10,  15,  15,  10,   0, -10, 
	-5,   5,  15,  20,  20,  15,   5,  -5,
    -5,   5,  15,  20,  20,  15,   5,  -5,
   -20, -10,   0,   5,   5,   0, -10, -20,
  -135, -25, -15, -10, -10, -15, -25, -135
&#125;;

const int pstKnightEg&#91;64&#93; =
&#123;
   -40, -30, -20, -15, -15, -20, -30, -40,
   -30, -20, -10,  -5,  -5, -10, -20, -30,
   -20, -10,   0,   5,   5,   0, -10, -20,
   -15,  -5,   5,  10,  10,   5,  -5, -15,
   -15,  -5,   5,  10,  10,   5,  -5, -15,
   -20, -10,   0,   5,   5,   0, -10, -20,
   -30, -20, -10,  -5,  -5, -10, -20, -30,
   -40, -30, -20, -15, -15, -20, -30, -40
&#125;;

const int pstBishopMg&#91;64&#93; = 
&#123;
    -2,  -5, -16,  -5,  -5, -16,  -5,  -2,
    -5,   6,   3,   6,   6,   3,   6,  -5,
    -5,   5,   8,  10,  10,   8,   5,  -5,
    -5,   0,  10,  13,  13,  10,   0,  -5,
    -5,   0,   5,  13,  13,   5,   0,  -5,
    -5,   0,   5,   5,   5,   5,   0,  -5,
    -5,   0,   0,   0,   0,   0,   0,  -5,
    -5,  -5,  -5,  -5,  -5,  -5,  -5,  -5
&#125;;

const int pstBishopEg&#91;64&#93; = 
&#123;
   -15, -10,  -8,  -5,  -5,  -8, -10, -15,
   -10,  -8,   0,   5,   5,   0,  -8, -10,
    -5,   0,   5,  10,  10,   5,   0,  -8,
    -5,   5,  10,  15,  15,  10,   5,  -5,
    -5,   5,  10,  15,  15,  10,   5,  -5,
    -8,   0,   5,  10,  10,   5,   0,  -8,
   -10,  -8,   0,   5,   5,   0,  -8, -10,
   -15, -10,  -8,  -5,  -5,  -8, -10, -15
&#125;;

const int pstRookMg&#91;64&#93; = 
&#123;
  	 0,   1,   2,   4,   4,   2,   1,   0,
    -4,  -2,   0,   2,   2,   0,  -2,  -4,
    -4,  -2,   0,   2,   2,   0,  -2,  -4,
    -4,  -2,   0,   2,   2,   0,  -2,  -4,
    -4,  -2,   0,   2,   2,   0,  -2,  -4,
    -4,  -2,   0,   2,   2,   0,  -2,  -4,
    15,  15,  15,  15,  15,  15,  15,  15,
     4,   4,   4,   4,   4,   4,   4,   4
&#125;;

const int pstRookEg&#91;64&#93; = 
&#123;
  	 0,   0,   0,   0,   0,   0,   0,   0,
    -2,   0,   0,   0,   0,   0,   0,  -2,
    -2,   0,   0,   0,   0,   0,   0,  -2,
    -2,   0,   0,   0,   0,   0,   0,  -2,
    -2,   0,   0,   0,   0,   0,   0,  -2,
    -2,   0,   0,   0,   0,   0,   0,  -2,
    15,  15,  15,  15,  15,  15,  15,  15,
     4,   4,   4,   4,   4,   4,   4,   4
&#125;;

const int pstQueenMg&#91;64&#93; = 
&#123;
	-5,  -5,  -5,  -5,  -5,  -5,  -5,  -5,
     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
&#125;;

const int pstQueenEg&#91;64&#93; = 
&#123;
   -24, -16, -12,  -8,  -8, -12, -16, -24,
   -16, -12,  -4,   0,   0,  -4, -12, -16,
   -12,  -4,   0,   4,   4,   0,  -4, -12,
    -8,   0,   4,   8,   8,   4,   0,  -8,
    -8,   0,   4,   8,   8,   4,   0,  -8,
   -12,  -4,   0,   4,   4,   0,  -4, -12,
   -16, -12,  -4,   0,   0,  -4, -12, -16,
   -24, -16, -12,  -8,  -8, -12, -16, -24
&#125;;

const int pstKingMg&#91;64&#93; = 
&#123;
    40,  50,  30,  10,  10,  30,  50,  40,
    30,  40,  20,   0,   0,  20,  40,  30,
    10,  20,   0, -20, -20,   0,  20,  10,
     0,  10, -10, -30, -30, -10,  10,   0,
   -10,   0, -20, -40, -40, -20,   0, -10,
   -20, -10, -30, -50, -50, -30, -10, -20,
   -30, -20, -40, -60, -60, -40, -20, -30,
   -40, -30, -50, -70, -70, -50, -30, -40
&#125;;

const int pstKingEg&#91;64&#93; = 
&#123;
   -72, -48, -36, -24, -24, -36, -48, -72,
   -48, -24, -12,   0,   0, -12, -24, -48,
   -36, -12,   0,  12,  12,   0, -12, -36,
   -24,   0,  12,  24,  24,  12,   0, -24,
   -24,   0,  12,  24,  24,  12,   0, -24,
   -36, -12,   0,  12,  12,   0, -12, -36,
   -48, -24, -12,   0,   0, -12, -24, -48,
   -72, -48, -36, -24, -24, -36, -48, -72
&#125;;
tables proposed by Lucas scored 42,5% against original template. now I'm running the above code against it, and Adam's version will be next.
User avatar
Bloodbane
Posts: 154
Joined: Thu Oct 03, 2013 4:17 pm

Re: Piece/square table challenge

Post by Bloodbane »

Sounds fun, here are mine from my engine Hakkapeliitta. I don't expect much as I haven't tuned them at all yet as I'm too stupid to make CLOP work.

Code: Select all

// GM Kaufman's point values
#define PAWN_VAL 100
#define KNIGHT_VAL 345
#define BISHOP_VAL 355
#define ROOK_VAL 525
#define ROOK_VAL 1000 

// -15,-10, -5, 0, 0, -5,-10,-15 for every rank&#40;except 1st, 7th and 8th&#41;, rank bonus = 5 for every rank starting from 3rd and ending at 6th
// last rank bonus = 60&#40;no other bonuses&#41;, 6th rank bonus = 20
// d3/e3 bonus = 10, d4/e4 bonus = 20, e5/d5 bonus = 20
// a4/h4 penalty = 10, f2/c2 bonus = 10, g2/b2 bonus = 5
// centered around zero
const int pstPawnMg&#91;64&#93; = &#123; 
	0,  0,  0,  0,  0,  0,  0,  0,       // 1st rank, applies to all PSTs
  -33,-18,-13,-18,-18,-13,-18,-33,
  -28,-23,-13, -3, -3,-13,-23,-28,
  -33,-18,-13, 12, 12,-13,-18,-33,
  -18,-13, -8, 17, 17, -8,-13,-18,
    7, 12, 17, 22, 22, 17, 12,  7,
   42, 42, 42, 42, 42, 42, 42, 42,
	0,  0,  0,  0,  0,  0,  0,  0     // 8th rank, applies to all PSts
&#125;;

// rank bonus = 5 starting from the 3rd rank and ending at 6th, last rank bonus = 60&#40;no other bonuses&#41;, 6th rank bonus = 20
// centered around zero
const int pstPawnEg&#91;64&#93; = &#123; 
	0,  0,  0,  0,  0,  0,  0,  0,
  -22,-22,-22,-22,-22,-22,-22,-22,
  -17,-17,-17,-17,-17,-17,-17,-17,
  -12,-12,-12,-12,-12,-12,-12,-12,
   -7, -7, -7, -7, -7, -7, -7, -7,
   18, 18, 18, 18, 18, 18, 18, 18,
   38, 38, 38, 38, 38, 38, 38, 38,
	0,  0,  0,  0,  0,  0,  0,  0
&#125;;

// based on the center-manhattan distance
// d5/e5 bonus = 10
// d6/e6 bonus = 30
// f5/c5 bonus = 10
// f6/c6 bonus = 10
// centered around zero
const int pstKnightMg&#91;64&#93; = &#123; 
  -36,-26,-16, -6, -6,-16,-26,-36,
  -26,-16, -6,  9,  9, -6,-16,-26,
  -16, -6,  9, 29, 29,  9, -6,-16,
   -6,  9, 29, 39, 39, 29,  9, -6,
   -6,  9, 39, 49, 49, 39,  9, -6,
  -16, -6, 19, 59, 59, 19, -6,-16,
  -26,-16, -6,  9,  9, -6,-16,-26,
  -36,-26,-16, -6, -6,-16,-26,-36
&#125;;

// based on the center-manhattan distance
// centered around zero
const int pstKnightEg&#91;64&#93; = &#123; 
  -34,-24,-14, -4, -4,-14,-24,-34,
  -24,-14, -4, 11, 11, -4,-14,-24,
  -14, -4, 11, 31, 31, 11, -4,-14,
   -4, 11, 31, 41, 41, 31, 11, -4,
   -4, 11, 31, 41, 41, 31, 11, -4,
  -14, -4, 11, 31, 31, 11, -4,-14,
  -24,-14, -4, 11, 11, -4,-14,-24,
  -34,-24,-14, -4, -4,-14,-24,-34
&#125;;

// based on center-manhattan distance
// last rank penalty = 10
// b2/g2 bonus = 10
// b5/g5 bonus = 5
// centered around zero
const int pstBishopMg&#91;64&#93; = &#123; 
  -24,-19,-14, -9, -9,-14,-19,-24,
   -9,  6,  1,  6,  6,  1,  6, -9,
   -4,  1,  6, 11, 11,  6,  1, -4,
    1,  6, 11, 16, 16, 11,  6,  1,
    1, 11, 11, 16, 16, 11, 11,  1,
   -4,  1,  6, 11, 11,  6,  1, -4,
   -9, -4,  1,  6,  6,  1, -4, -9,
  -14, -9, -4,  1,  1, -5, -9,-14
&#125;;

// based on center-manhattan distance
// centered around zero
const int pstBishopEg&#91;64&#93; = &#123; 
  -15,-10, -5,  0,  0, -5,-10,-15,
  -10, -5,  0,  5,  5,  0, -5,-10,
   -5,  0,  5, 10, 10,  5,  0, -5,
    0,  5, 10, 15, 15, 10,  5,  0,
    0,  5, 10, 15, 15, 10,  5,  0,
   -5,  0,  5, 10, 10,  5,  0, -5,
  -10, -5,  0,  5,  5,  0, -5,-10,
  -15,-10, -5,  0,  0, -5,-10,-15
&#125;;

// c-/f-file bonus = 2, d-/e-file bonus = 5, 7th rank bonus = 10
// centered around zero
const int pstRookMg&#91;64&#93; = &#123; 
   -3, -3, -1,  2,  2, -1, -3, -3,
   -3, -3, -1,  2,  2, -1, -3, -3,
   -3, -3, -1,  2,  2, -1, -3, -3,
   -3, -3, -1,  2,  2, -1, -3, -3,
   -3, -3, -1,  2,  2, -1, -3, -3,
   -3, -3, -1,  2,  2, -1, -3, -3,
    7,  7,  9, 12, 12,  9,  7,  7,
   -3, -3, -1,  2,  2, -1, -3, -3,
&#125;;

// all zeroes is correct, there is no correct placement even generally for the rook in the endgame
// centered around zero
const int pstRookEg&#91;64&#93; = &#123; 
    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,
&#125;;

// based on center-manhattan distance
// first rank penalty = 5
// centered around zero
const int pstQueenMg&#91;64&#93; = &#123; 
   -19,-14, -9, -4, -4, -9,-14,-19,
    -9, -4,  1,  6,  6,  1, -4, -9,
    -4,  1,  6, 11, 11,  6,  1, -4,
     1,  6, 11, 16, 16, 11,  6,  1,
     1,  6, 11, 16, 16, 11,  6,  1,
    -4,  1,  6, 11, 11,  6,  1, -4,
    -9, -4,  1,  6,  6,  1, -4, -9,
   -14, -9, -4,  1,  1, -4, -9,-14
&#125;;

// based on center-manhattan distance
// centered around zero
const int pstQueenEg&#91;64&#93; = &#123; 
  -15,-10, -5,  0,  0, -5,-10,-15,
  -10, -5,  0,  5,  5,  0, -5,-10,
   -5,  0,  5, 10, 10,  5,  0, -5,
    0,  5, 10, 15, 15, 10,  5,  0,
    0,  5, 10, 15, 15, 10,  5,  0,
   -5,  0,  5, 10, 10,  5,  0, -5,
  -10, -5,  0,  5,  5,  0, -5,-10,
  -15,-10, -5,  0,  0, -5,-10,-15
&#125;;

// stay the hell away from center, instead castle 
// cannot and should not be centered around zero
const int pstKingMg&#91;64&#93; = &#123; 
    5,  6,  4,  0,  0,  1,  6,  4,
    5,  5,  0, -5, -5,  0,  5,  5,
   -5, -5, -5,-10,-10, -5, -5, -5,
  -10,-10,-20,-30,-30,-20,-10,-10,
  -20,-25,-30,-40,-40,-30,-25,-20,
  -40,-40,-50,-60,-60,-50,-40,-40,
  -50,-50,-60,-60,-60,-60,-50,-50,
  -60,-60,-60,-60,-60,-60,-60,-60
&#125;;

// based on center-manhattan distance
// centered around zero
const int pstKingEg&#91;64&#93; = &#123; 
   -38,-28,-18, -8, -8,-18,-28,-38,
   -28,-18, -8, 13, 13, -8,-18,-28,
   -18, -8, 13, 43, 43, 13, -8,-18,
    -8, 13, 43, 53, 53, 43, 13, -8,
    -8, 13, 43, 53, 53, 43, 13, -8,
   -18, -8, 13, 43, 43, 13, -8,-18,
   -28,-18, -8, 13, 13, -8,-18,-28,
   -38,-28,-18, -8, -8,-18,-28,-38,
&#125;;

Functional programming combines the flexibility and power of abstract mathematics with the intuitive clarity of abstract mathematics.
https://github.com/mAarnos
PK
Posts: 895
Joined: Mon Jan 15, 2007 11:23 am
Location: Warsza

Re: Piece/square table challenge

Post by PK »

ok, news from the front are as follows: my set has beaten original template by 58,9%, and now I'm rooting for Adam's values - partly because of data mining thechnique he used, partly because I'd prefer not to win this competition.

Adam's set is asymmetric, which raises important point: is vertical symmetry of piece/square tables a requirement? frankly speaking, I was toying with the idea of making an educated guess that kings go to kingside more often than not, and statistically there might be some gain in "slanting" knight and queen tables towards the kingside.