X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fpsqt.cpp;h=56d966f05710c1ece833d9d9d04935a98ada9925;hp=913d03530b263ee4ad37c05b17348f3314398539;hb=e258c5a779af3b330cbb797b12b272ea0dd83a40;hpb=d4af15f682c1967450233ab62cba1a6c5d601df6 diff --git a/src/psqt.cpp b/src/psqt.cpp index 913d0353..56d966f0 100644 --- a/src/psqt.cpp +++ b/src/psqt.cpp @@ -18,8 +18,15 @@ along with this program. If not, see . */ +#include + #include "types.h" +Value PieceValue[PHASE_NB][PIECE_NB] = { + { VALUE_ZERO, PawnValueMg, KnightValueMg, BishopValueMg, RookValueMg, QueenValueMg }, + { VALUE_ZERO, PawnValueEg, KnightValueEg, BishopValueEg, RookValueEg, QueenValueEg } +}; + namespace PSQT { #define S(mg, eg) make_score(mg, eg) @@ -32,13 +39,12 @@ const Score Bonus[][RANK_NB][int(FILE_NB) / 2] = { { }, { // Pawn { S( 0, 0), S( 0, 0), S( 0, 0), S( 0, 0) }, - { S(-19, 5), S( 1,-4), S( 7, 8), S( 3,-2) }, - { S(-26,-6), S( -7,-5), S( 19, 5), S(24, 4) }, - { S(-25, 1), S(-14, 3), S( 16,-8), S(31,-3) }, - { S(-14, 6), S( 0, 9), S( -1, 7), S(17,-6) }, - { S(-14, 6), S(-13,-5), S(-10, 2), S(-6, 4) }, - { S(-12, 1), S( 15,-9), S( -8, 1), S(-4,18) }, - { S( 0, 0), S( 0, 0), S( 0, 0), S( 0, 0) } + { S(-11, 7), S( 6,-4), S( 7, 8), S( 3,-2) }, + { S(-18,-4), S( -2,-5), S( 19, 5), S(24, 4) }, + { S(-17, 3), S( -9, 3), S( 20,-8), S(35,-3) }, + { S( -6, 8), S( 5, 9), S( 3, 7), S(21,-6) }, + { S( -6, 8), S( -8,-5), S( -6, 2), S(-2, 4) }, + { S( -4, 3), S( 20,-9), S( -8, 1), S(-4,18) } }, { // Knight { S(-143, -97), S(-96,-82), S(-80,-46), S(-73,-14) }, @@ -81,37 +87,38 @@ const Score Bonus[][RANK_NB][int(FILE_NB) / 2] = { { S(-1,-75), S(-4,-54), S(-1,-44), S( 0,-30) } }, { // King - { S(291, 28), S(344, 76), S(294,103), S(219,112) }, - { S(289, 70), S(329,119), S(263,170), S(205,159) }, - { S(226,109), S(271,164), S(202,195), S(136,191) }, - { S(204,131), S(212,194), S(175,194), S(137,204) }, - { S(177,132), S(205,187), S(143,224), S( 94,227) }, - { S(147,118), S(188,178), S(113,199), S( 70,197) }, - { S(116, 72), S(158,121), S( 93,142), S( 48,161) }, - { S( 94, 30), S(120, 76), S( 78,101), S( 31,111) } + { S(260, 0), S(313, 48), S(263, 75), S(188, 84) }, + { S(258, 42), S(298, 91), S(232,142), S(174,131) }, + { S(195, 81), S(240,136), S(171,167), S(105,163) }, + { S(173,103), S(181,166), S(144,166), S(106,176) }, + { S(146,104), S(174,159), S(112,196), S( 63,199) }, + { S(116, 90), S(157,150), S( 82,171), S( 39,169) }, + { S( 85, 44), S(127, 93), S( 62,114), S( 17,133) }, + { S( 63, 2), S( 89, 48), S( 47, 73), S( 0, 83) } } }; #undef S -Score psq[COLOR_NB][PIECE_TYPE_NB][SQUARE_NB]; +Score psq[PIECE_NB][SQUARE_NB]; -// init() initializes piece square tables: the white halves of the tables are +// init() initializes piece-square tables: the white halves of the tables are // copied from Bonus[] adding the piece value, then the black halves of the // tables are initialized by flipping and changing the sign of the white scores. void init() { - for (PieceType pt = PAWN; pt <= KING; ++pt) + for (Piece pc = W_PAWN; pc <= W_KING; ++pc) { - PieceValue[MG][make_piece(BLACK, pt)] = PieceValue[MG][pt]; - PieceValue[EG][make_piece(BLACK, pt)] = PieceValue[EG][pt]; + PieceValue[MG][~pc] = PieceValue[MG][pc]; + PieceValue[EG][~pc] = PieceValue[EG][pc]; - Score v = make_score(PieceValue[MG][pt], PieceValue[EG][pt]); + Score v = make_score(PieceValue[MG][pc], PieceValue[EG][pc]); for (Square s = SQ_A1; s <= SQ_H8; ++s) { - int edgeDistance = file_of(s) < FILE_E ? file_of(s) : FILE_H - file_of(s); - psq[BLACK][pt][~s] = -(psq[WHITE][pt][s] = v + Bonus[pt][rank_of(s)][edgeDistance]); + File f = std::min(file_of(s), FILE_H - file_of(s)); + psq[ pc][ s] = v + Bonus[pc][rank_of(s)][f]; + psq[~pc][~s] = -psq[pc][s]; } } }