Code: Select all
#include <stdio.h>
#include <stdlib.h>
#define FLIP_TB(sq) ((sq)^0x38) // Flip top-to-bottom (A8==A1, A7==A2 etc.)
#define NUMBER_OF_TBLS 12
// Contains the tables to flip.
#include "psqt.h"
int main(void)
{
const int *ppsqt[NUMBER_OF_TBLS] = {
pstPawnMg, pstPawnEg, pstKnightMg, pstKnightEg,
pstBishopMg, pstBishopEg, pstRookMg, pstRookEg,
pstQueenMg, pstQueenEg, pstKingMg, pstKingEg
};
const char * const piece[] = {
"PawnMg", "PawnEg", "KnightMg", "KnightEg",
"BishopMg", "BishopEg", "RookMg", "RookEg",
"QueenMg", "QueenEg", "KingMg", "KingEg"
};
static int psqt[NUMBER_OF_TBLS][64];
for (int i=0; i < NUMBER_OF_TBLS; i++) {
printf("\nconst int pst%s[64] = \n{", piece[i]);
for (int sq=0; sq < 64; sq++) {
psqt[i][sq] = ppsqt[i][ FLIP_TB(sq) ];
if (!(sq % 8)) printf("\n ");
printf("%3d", psqt[i][sq]);
if (sq < 63) printf(", ");
}
printf("\n};");
}
printf("\n");
return 0;
}
Code: Select all
const int pstPawnMg[64] =
{
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,
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] =
{
-18, -18, -16, -14, -14, -16, -18, -18,
-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,
-8, -8, -6, -4, -4, -6, -8, -8
};
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,
-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,
-1, 5, 8, 11, 11, 8, 5, -1,
-9, -3, 0, 3, 3, 0, -3, -9
};
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,
8, 8, 8, 8, 8, 8, 8, 8,
0, 0, 0, 0, 0, 0, 0, 0
};
const int pstQueenMg[64] =
{
-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
};
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] =
{
37, 47, 27, 7, 7, 27, 47, 37,
30, 40, 20, 0, 0, 20, 40, 30,
16, 26, 6, -14, -14, 6, 26, 16,
9, 19, -1, -21, -21, -1, 19, 9,
2, 12, -8, -28, -28, -8, 12, 2,
-5, 5, -15, -35, -35, -15, 5, -5,
-12, -2, -22, -42, -42, -22, -2, -12,
-19, -9, -29, -49, -49, -29, -9, -19
};
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
};