From 578b21bbeedc41b6e0d1b2df46887b1636a78e2b Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Sat, 2 May 2015 02:36:39 +0200 Subject: [PATCH] Split PSQT init from Position init Easier for tuning psq tables: TUNE(myParameters, PSQT::init); Also move PSQT code in a new *.cpp file, and retire the old and hacky psqtab.h that required to be included only once to work correctly, this is not idiomatic for a header file. Give wide visibility to psq tables (previously visible only in position.cpp), this will easy the use of psq tables outside Position, for instance in move ordering. Finally trivial code style fixes of the latest patches. Original patch of Lucas Braesch. No functional change. --- src/Makefile | 2 +- src/main.cpp | 1 + src/movepick.cpp | 6 +- src/position.cpp | 31 +++------------ src/position.h | 7 +++ src/psqt.cpp | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/psqtab.h | 98 ---------------------------------------------- src/search.cpp | 3 +- 8 files changed, 134 insertions(+), 128 deletions(-) create mode 100644 src/psqt.cpp delete mode 100644 src/psqtab.h diff --git a/src/Makefile b/src/Makefile index 65ef297..840312d 100644 --- a/src/Makefile +++ b/src/Makefile @@ -35,7 +35,7 @@ PGOBENCH = ./$(EXE) bench 16 1 1000 default time ### Object files OBJS = benchmark.o bitbase.o bitboard.o endgame.o evaluate.o main.o \ - material.o misc.o movegen.o movepick.o pawns.o position.o \ + material.o misc.o movegen.o movepick.o pawns.o position.o psqt.o \ search.o thread.o timeman.o tt.o uci.o ucioption.o syzygy/tbprobe.o ### ========================================================================== diff --git a/src/main.cpp b/src/main.cpp index 8cdf9e6..adc13db 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -33,6 +33,7 @@ int main(int argc, char* argv[]) { std::cout << engine_info() << std::endl; UCI::init(Options); + PSQT::init(); Bitboards::init(); Position::init(); Bitbases::init(); diff --git a/src/movepick.cpp b/src/movepick.cpp index 3fe09bb..914cd80 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -147,9 +147,9 @@ void MovePicker::score() { // badCaptures[] array, but instead of doing it now we delay until the move // has been picked up in pick_move_from_list(). This way we save some SEE // calls in case we get a cutoff. - for (auto& m : *this){ - m.value = PieceValue[MG][pos.piece_on(to_sq(m))] - 200*relative_rank(pos.side_to_move(), to_sq(m)); - } + for (auto& m : *this) + m.value = PieceValue[MG][pos.piece_on(to_sq(m))] + - 200 * relative_rank(pos.side_to_move(), to_sq(m)); } template<> diff --git a/src/position.cpp b/src/position.cpp index 573b5df..1aa476b 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -27,7 +27,6 @@ #include "misc.h" #include "movegen.h" #include "position.h" -#include "psqtab.h" #include "thread.h" #include "tt.h" #include "uci.h" @@ -52,7 +51,6 @@ Key Position::exclusion_key() const { return st->key ^ Zobrist::exclusion; } namespace { const string PieceToChar(" PNBRQK pnbrqk"); -Score psq[COLOR_NB][PIECE_TYPE_NB][SQUARE_NB]; // min_attacker() is a helper function used by see() to locate the least // valuable attacker for the side to move, remove the attacker we just found @@ -130,10 +128,7 @@ std::ostream& operator<<(std::ostream& os, const Position& pos) { /// Position::init() initializes at startup the various arrays used to compute -/// hash keys and the piece square tables. The latter is a two-step operation: -/// Firstly, the white halves of the tables are copied from PSQT[] tables. -/// Secondly, the black halves of the tables are initialized by flipping and -/// changing the sign of the white scores. +/// hash keys. void Position::init() { @@ -160,20 +155,6 @@ void Position::init() { Zobrist::side = rng.rand(); Zobrist::exclusion = rng.rand(); - - for (PieceType pt = PAWN; pt <= KING; ++pt) - { - PieceValue[MG][make_piece(BLACK, pt)] = PieceValue[MG][pt]; - PieceValue[EG][make_piece(BLACK, pt)] = PieceValue[EG][pt]; - - Score v = make_score(PieceValue[MG][pt], PieceValue[EG][pt]); - - for (Square s = SQ_A1; s <= SQ_H8; ++s) - { - psq[WHITE][pt][ s] = (v + PSQT[pt][s]); - psq[BLACK][pt][~s] = -(v + PSQT[pt][s]); - } - } } @@ -373,7 +354,7 @@ void Position::set_state(StateInfo* si) const { Square s = pop_lsb(&b); Piece pc = piece_on(s); si->key ^= Zobrist::psq[color_of(pc)][type_of(pc)][s]; - si->psq += psq[color_of(pc)][type_of(pc)][s]; + si->psq += PSQT::psq[color_of(pc)][type_of(pc)][s]; } if (si->epSquare != SQ_NONE) @@ -725,7 +706,7 @@ void Position::do_move(Move m, StateInfo& newSt, bool givesCheck) { do_castling(us, from, to, rfrom, rto); captured = NO_PIECE_TYPE; - st->psq += psq[us][ROOK][rto] - psq[us][ROOK][rfrom]; + st->psq += PSQT::psq[us][ROOK][rto] - PSQT::psq[us][ROOK][rfrom]; k ^= Zobrist::psq[us][ROOK][rfrom] ^ Zobrist::psq[us][ROOK][rto]; } @@ -764,7 +745,7 @@ void Position::do_move(Move m, StateInfo& newSt, bool givesCheck) { prefetch(thisThread->materialTable[st->materialKey]); // Update incremental scores - st->psq -= psq[them][captured][capsq]; + st->psq -= PSQT::psq[them][captured][capsq]; // Reset rule 50 counter st->rule50 = 0; @@ -820,7 +801,7 @@ void Position::do_move(Move m, StateInfo& newSt, bool givesCheck) { ^ Zobrist::psq[us][PAWN][pieceCount[us][PAWN]]; // Update incremental score - st->psq += psq[us][promotion][to] - psq[us][PAWN][to]; + st->psq += PSQT::psq[us][promotion][to] - PSQT::psq[us][PAWN][to]; // Update material st->nonPawnMaterial[us] += PieceValue[MG][promotion]; @@ -835,7 +816,7 @@ void Position::do_move(Move m, StateInfo& newSt, bool givesCheck) { } // Update incremental scores - st->psq += psq[us][pt][to] - psq[us][pt][from]; + st->psq += PSQT::psq[us][pt][to] - PSQT::psq[us][pt][from]; // Set capture piece st->capturedType = captured; diff --git a/src/position.h b/src/position.h index ece3f44..e38020d 100644 --- a/src/position.h +++ b/src/position.h @@ -30,6 +30,13 @@ class Position; struct Thread; +namespace PSQT { + + extern Score psq[COLOR_NB][PIECE_TYPE_NB][SQUARE_NB]; + + void init(); +} + /// CheckInfo struct is initialized at c'tor time and keeps info used to detect /// if a move gives check. diff --git a/src/psqt.cpp b/src/psqt.cpp new file mode 100644 index 0000000..32601c0 --- /dev/null +++ b/src/psqt.cpp @@ -0,0 +1,114 @@ +/* + Stockfish, a UCI chess playing engine derived from Glaurung 2.1 + Copyright (C) 2004-2008 Tord Romstad (Glaurung author) + Copyright (C) 2008-2015 Marco Costalba, Joona Kiiski, Tord Romstad + + Stockfish is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Stockfish is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "types.h" + +namespace PSQT { + +#define S(mg, eg) make_score(mg, eg) + +/// BaseTable[PieceType][Square] contains Piece-Square scores. For each piece +/// type on a given square a (middlegame, endgame) score pair is assigned. Table +/// is defined just for the white side; it is symmetric for the black side. +const Score BaseTable[][SQUARE_NB] = { + { }, + { // Pawn + S( 0, 0), S( 0, 0), S( 0, 0), S( 0, 0), S( 0, 0), S( 0, 0), S( 0, 0), S( 0, 0), + S(-22, 4), S( 3,-6), S( 7, 8), S( 3,-1), S( 3,-1), S( 7, 8), S( 3,-6), S(-22, 4), + S(-25,-3), S( -7,-4), S(18, 4), S(24, 5), S(24, 5), S(18, 4), S( -7,-4), S(-25,-3), + S(-27, 1), S(-15, 2), S(15,-8), S(30,-2), S(30,-2), S(15,-8), S(-15, 2), S(-27, 1), + S(-14, 7), S( 0,12), S(-2, 4), S(18,-3), S(18,-3), S(-2, 4), S( 0,12), S(-14, 7), + S(-12, 8), S(-13,-5), S(-6, 1), S(-4, 7), S(-4, 7), S(-6, 1), S(-13,-5), S(-12, 8), + S(-17, 1), S( 10,-9), S(-4, 1), S(-6,16), S(-6,16), S(-4, 1), S( 10,-9), S(-17, 1), + S( 0, 0), S( 0, 0), S( 0, 0), S( 0, 0), S( 0, 0), S( 0, 0), S( 0, 0), S( 0, 0) + }, + { // Knight + S(-144,-98), S(-109,-83), S(-85,-51), S(-73,-16), S(-73,-16), S(-85,-51), S(-109,-83), S(-144,-98), + S( -88,-68), S( -43,-53), S(-19,-21), S( -7, 14), S( -7, 14), S(-19,-21), S( -43,-53), S( -88,-68), + S( -69,-53), S( -24,-38), S( 0, -6), S( 12, 29), S( 12, 29), S( 0, -6), S( -24,-38), S( -69,-53), + S( -28,-42), S( 17,-27), S( 41, 5), S( 53, 40), S( 53, 40), S( 41, 5), S( 17,-27), S( -28,-42), + S( -30,-42), S( 15,-27), S( 39, 5), S( 51, 40), S( 51, 40), S( 39, 5), S( 15,-27), S( -30,-42), + S( -10,-53), S( 35,-38), S( 59, -6), S( 71, 29), S( 71, 29), S( 59, -6), S( 35,-38), S( -10,-53), + S( -64,-68), S( -19,-53), S( 5,-21), S( 17, 14), S( 17, 14), S( 5,-21), S( -19,-53), S( -64,-68), + S(-200,-98), S( -65,-83), S(-41,-51), S(-29,-16), S(-29,-16), S(-41,-51), S( -65,-83), S(-200,-98) + }, + { // Bishop + S(-54,-65), S(-27,-42), S(-34,-44), S(-43,-26), S(-43,-26), S(-34,-44), S(-27,-42), S(-54,-65), + S(-29,-43), S( 8,-20), S( 1,-22), S( -8, -4), S( -8, -4), S( 1,-22), S( 8,-20), S(-29,-43), + S(-20,-33), S( 17,-10), S( 10,-12), S( 1, 6), S( 1, 6), S( 10,-12), S( 17,-10), S(-20,-33), + S(-19,-35), S( 18,-12), S( 11,-14), S( 2, 4), S( 2, 4), S( 11,-14), S( 18,-12), S(-19,-35), + S(-22,-35), S( 15,-12), S( 8,-14), S( -1, 4), S( -1, 4), S( 8,-14), S( 15,-12), S(-22,-35), + S(-28,-33), S( 9,-10), S( 2,-12), S( -7, 6), S( -7, 6), S( 2,-12), S( 9,-10), S(-28,-33), + S(-32,-43), S( 5,-20), S( -2,-22), S(-11, -4), S(-11, -4), S( -2,-22), S( 5,-20), S(-32,-43), + S(-49,-65), S(-22,-42), S(-29,-44), S(-38,-26), S(-38,-26), S(-29,-44), S(-22,-42), S(-49,-65) + }, + { // Rook + S(-22, 3), S(-17, 3), S(-12, 3), S(-8, 3), S(-8, 3), S(-12, 3), S(-17, 3), S(-22, 3), + S(-22, 3), S( -7, 3), S( -2, 3), S( 2, 3), S( 2, 3), S( -2, 3), S( -7, 3), S(-22, 3), + S(-22, 3), S( -7, 3), S( -2, 3), S( 2, 3), S( 2, 3), S( -2, 3), S( -7, 3), S(-22, 3), + S(-22, 3), S( -7, 3), S( -2, 3), S( 2, 3), S( 2, 3), S( -2, 3), S( -7, 3), S(-22, 3), + S(-22, 3), S( -7, 3), S( -2, 3), S( 2, 3), S( 2, 3), S( -2, 3), S( -7, 3), S(-22, 3), + S(-22, 3), S( -7, 3), S( -2, 3), S( 2, 3), S( 2, 3), S( -2, 3), S( -7, 3), S(-22, 3), + S(-11, 3), S( 4, 3), S( 9, 3), S(13, 3), S(13, 3), S( 9, 3), S( 4, 3), S(-11, 3), + S(-22, 3), S(-17, 3), S(-12, 3), S(-8, 3), S(-8, 3), S(-12, 3), S(-17, 3), S(-22, 3) + }, + { // Queen + S(-2,-80), S(-2,-54), S(-2,-42), S(-2,-30), S(-2,-30), S(-2,-42), S(-2,-54), S(-2,-80), + S(-2,-54), S( 8,-30), S( 8,-18), S( 8, -6), S( 8, -6), S( 8,-18), S( 8,-30), S(-2,-54), + S(-2,-42), S( 8,-18), S( 8, -6), S( 8, 6), S( 8, 6), S( 8, -6), S( 8,-18), S(-2,-42), + S(-2,-30), S( 8, -6), S( 8, 6), S( 8, 18), S( 8, 18), S( 8, 6), S( 8, -6), S(-2,-30), + S(-2,-30), S( 8, -6), S( 8, 6), S( 8, 18), S( 8, 18), S( 8, 6), S( 8, -6), S(-2,-30), + S(-2,-42), S( 8,-18), S( 8, -6), S( 8, 6), S( 8, 6), S( 8, -6), S( 8,-18), S(-2,-42), + S(-2,-54), S( 8,-30), S( 8,-18), S( 8, -6), S( 8, -6), S( 8,-18), S( 8,-30), S(-2,-54), + S(-2,-80), S(-2,-54), S(-2,-42), S(-2,-30), S(-2,-30), S(-2,-42), S(-2,-54), S(-2,-80) + }, + { // King + S(298, 27), S(332, 81), S(273,108), S(225,116), S(225,116), S(273,108), S(332, 81), S(298, 27), + S(287, 74), S(321,128), S(262,155), S(214,163), S(214,163), S(262,155), S(321,128), S(287, 74), + S(224,111), S(258,165), S(199,192), S(151,200), S(151,200), S(199,192), S(258,165), S(224,111), + S(196,135), S(230,189), S(171,216), S(123,224), S(123,224), S(171,216), S(230,189), S(196,135), + S(173,135), S(207,189), S(148,216), S(100,224), S(100,224), S(148,216), S(207,189), S(173,135), + S(146,111), S(180,165), S(121,192), S( 73,200), S( 73,200), S(121,192), S(180,165), S(146,111), + S(119, 74), S(153,128), S( 94,155), S( 46,163), S( 46,163), S( 94,155), S(153,128), S(119, 74), + S( 98, 27), S(132, 81), S( 73,108), S( 25,116), S( 25,116), S( 73,108), S(132, 81), S( 98, 27) + } +}; + +#undef S + +Score psq[COLOR_NB][PIECE_TYPE_NB][SQUARE_NB]; + +// init() initializes piece square tables: the white halves of the tables are +// copied from BaseTable[] 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) + { + PieceValue[MG][make_piece(BLACK, pt)] = PieceValue[MG][pt]; + PieceValue[EG][make_piece(BLACK, pt)] = PieceValue[EG][pt]; + + Score v = make_score(PieceValue[MG][pt], PieceValue[EG][pt]); + + for (Square s = SQ_A1; s <= SQ_H8; ++s) + psq[BLACK][pt][~s] = -(psq[WHITE][pt][ s] = (v + BaseTable[pt][s])); + } +} + +} // namespace PSQT diff --git a/src/psqtab.h b/src/psqtab.h deleted file mode 100644 index 57fb30b..0000000 --- a/src/psqtab.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - Stockfish, a UCI chess playing engine derived from Glaurung 2.1 - Copyright (C) 2004-2008 Tord Romstad (Glaurung author) - Copyright (C) 2008-2015 Marco Costalba, Joona Kiiski, Tord Romstad - - Stockfish is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Stockfish is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef PSQTAB_H_INCLUDED -#define PSQTAB_H_INCLUDED - -#include "types.h" - -#define S(mg, eg) make_score(mg, eg) - - -/// PSQT[PieceType][Square] contains Piece-Square scores. For each piece type on -/// a given square a (middlegame, endgame) score pair is assigned. PSQT is defined -/// for the white side and the tables are symmetric for the black side. - -static const Score PSQT[][SQUARE_NB] = { - { }, - { // Pawn - S( 0, 0), S( 0, 0), S( 0, 0), S( 0, 0), S( 0, 0), S( 0, 0), S( 0, 0), S( 0, 0), - S(-22, 4), S( 3,-6), S( 7, 8), S( 3,-1), S( 3,-1), S( 7, 8), S( 3,-6), S(-22, 4), - S(-25,-3), S( -7,-4), S(18, 4), S(24, 5), S(24, 5), S(18, 4), S( -7,-4), S(-25,-3), - S(-27, 1), S(-15, 2), S(15,-8), S(30,-2), S(30,-2), S(15,-8), S(-15, 2), S(-27, 1), - S(-14, 7), S( 0,12), S(-2, 4), S(18,-3), S(18,-3), S(-2, 4), S( 0,12), S(-14, 7), - S(-12, 8), S(-13,-5), S(-6, 1), S(-4, 7), S(-4, 7), S(-6, 1), S(-13,-5), S(-12, 8), - S(-17, 1), S( 10,-9), S(-4, 1), S(-6,16), S(-6,16), S(-4, 1), S( 10,-9), S(-17, 1), - S( 0, 0), S( 0, 0), S( 0, 0), S( 0, 0), S( 0, 0), S( 0, 0), S( 0, 0), S( 0, 0) - }, - { // Knight - S(-144,-98), S(-109,-83), S(-85,-51), S(-73,-16), S(-73,-16), S(-85,-51), S(-109,-83), S(-144,-98), - S( -88,-68), S( -43,-53), S(-19,-21), S( -7, 14), S( -7, 14), S(-19,-21), S( -43,-53), S( -88,-68), - S( -69,-53), S( -24,-38), S( 0, -6), S( 12, 29), S( 12, 29), S( 0, -6), S( -24,-38), S( -69,-53), - S( -28,-42), S( 17,-27), S( 41, 5), S( 53, 40), S( 53, 40), S( 41, 5), S( 17,-27), S( -28,-42), - S( -30,-42), S( 15,-27), S( 39, 5), S( 51, 40), S( 51, 40), S( 39, 5), S( 15,-27), S( -30,-42), - S( -10,-53), S( 35,-38), S( 59, -6), S( 71, 29), S( 71, 29), S( 59, -6), S( 35,-38), S( -10,-53), - S( -64,-68), S( -19,-53), S( 5,-21), S( 17, 14), S( 17, 14), S( 5,-21), S( -19,-53), S( -64,-68), - S(-200,-98), S( -65,-83), S(-41,-51), S(-29,-16), S(-29,-16), S(-41,-51), S( -65,-83), S(-200,-98) - }, - { // Bishop - S(-54,-65), S(-27,-42), S(-34,-44), S(-43,-26), S(-43,-26), S(-34,-44), S(-27,-42), S(-54,-65), - S(-29,-43), S( 8,-20), S( 1,-22), S( -8, -4), S( -8, -4), S( 1,-22), S( 8,-20), S(-29,-43), - S(-20,-33), S( 17,-10), S( 10,-12), S( 1, 6), S( 1, 6), S( 10,-12), S( 17,-10), S(-20,-33), - S(-19,-35), S( 18,-12), S( 11,-14), S( 2, 4), S( 2, 4), S( 11,-14), S( 18,-12), S(-19,-35), - S(-22,-35), S( 15,-12), S( 8,-14), S( -1, 4), S( -1, 4), S( 8,-14), S( 15,-12), S(-22,-35), - S(-28,-33), S( 9,-10), S( 2,-12), S( -7, 6), S( -7, 6), S( 2,-12), S( 9,-10), S(-28,-33), - S(-32,-43), S( 5,-20), S( -2,-22), S(-11, -4), S(-11, -4), S( -2,-22), S( 5,-20), S(-32,-43), - S(-49,-65), S(-22,-42), S(-29,-44), S(-38,-26), S(-38,-26), S(-29,-44), S(-22,-42), S(-49,-65) - }, - { // Rook - S(-22, 3), S(-17, 3), S(-12, 3), S(-8, 3), S(-8, 3), S(-12, 3), S(-17, 3), S(-22, 3), - S(-22, 3), S( -7, 3), S( -2, 3), S( 2, 3), S( 2, 3), S( -2, 3), S( -7, 3), S(-22, 3), - S(-22, 3), S( -7, 3), S( -2, 3), S( 2, 3), S( 2, 3), S( -2, 3), S( -7, 3), S(-22, 3), - S(-22, 3), S( -7, 3), S( -2, 3), S( 2, 3), S( 2, 3), S( -2, 3), S( -7, 3), S(-22, 3), - S(-22, 3), S( -7, 3), S( -2, 3), S( 2, 3), S( 2, 3), S( -2, 3), S( -7, 3), S(-22, 3), - S(-22, 3), S( -7, 3), S( -2, 3), S( 2, 3), S( 2, 3), S( -2, 3), S( -7, 3), S(-22, 3), - S(-11, 3), S( 4, 3), S( 9, 3), S(13, 3), S(13, 3), S( 9, 3), S( 4, 3), S(-11, 3), - S(-22, 3), S(-17, 3), S(-12, 3), S(-8, 3), S(-8, 3), S(-12, 3), S(-17, 3), S(-22, 3) - }, - { // Queen - S(-2,-80), S(-2,-54), S(-2,-42), S(-2,-30), S(-2,-30), S(-2,-42), S(-2,-54), S(-2,-80), - S(-2,-54), S( 8,-30), S( 8,-18), S( 8, -6), S( 8, -6), S( 8,-18), S( 8,-30), S(-2,-54), - S(-2,-42), S( 8,-18), S( 8, -6), S( 8, 6), S( 8, 6), S( 8, -6), S( 8,-18), S(-2,-42), - S(-2,-30), S( 8, -6), S( 8, 6), S( 8, 18), S( 8, 18), S( 8, 6), S( 8, -6), S(-2,-30), - S(-2,-30), S( 8, -6), S( 8, 6), S( 8, 18), S( 8, 18), S( 8, 6), S( 8, -6), S(-2,-30), - S(-2,-42), S( 8,-18), S( 8, -6), S( 8, 6), S( 8, 6), S( 8, -6), S( 8,-18), S(-2,-42), - S(-2,-54), S( 8,-30), S( 8,-18), S( 8, -6), S( 8, -6), S( 8,-18), S( 8,-30), S(-2,-54), - S(-2,-80), S(-2,-54), S(-2,-42), S(-2,-30), S(-2,-30), S(-2,-42), S(-2,-54), S(-2,-80) - }, - { // King - S(298, 27), S(332, 81), S(273,108), S(225,116), S(225,116), S(273,108), S(332, 81), S(298, 27), - S(287, 74), S(321,128), S(262,155), S(214,163), S(214,163), S(262,155), S(321,128), S(287, 74), - S(224,111), S(258,165), S(199,192), S(151,200), S(151,200), S(199,192), S(258,165), S(224,111), - S(196,135), S(230,189), S(171,216), S(123,224), S(123,224), S(171,216), S(230,189), S(196,135), - S(173,135), S(207,189), S(148,216), S(100,224), S(100,224), S(148,216), S(207,189), S(173,135), - S(146,111), S(180,165), S(121,192), S( 73,200), S( 73,200), S(121,192), S(180,165), S(146,111), - S(119, 74), S(153,128), S( 94,155), S( 46,163), S( 46,163), S( 94,155), S(153,128), S(119, 74), - S( 98, 27), S(132, 81), S( 73,108), S( 25,116), S( 25,116), S( 73,108), S(132, 81), S( 98, 27) - } -}; - -#undef S - -#endif // #ifndef PSQTAB_H_INCLUDED diff --git a/src/search.cpp b/src/search.cpp index 636b1db..18e0cb9 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -961,7 +961,8 @@ moves_loop: // When in check and at SpNode search starts from here if ( (!PvNode && cutNode) || ( History[pos.piece_on(to_sq(move))][to_sq(move)] < VALUE_ZERO - && CounterMovesHistory[pos.piece_on(prevMoveSq)][prevMoveSq][pos.piece_on(to_sq(move))][to_sq(move)] <= VALUE_ZERO)) + && CounterMovesHistory[pos.piece_on(prevMoveSq)][prevMoveSq] + [pos.piece_on(to_sq(move))][to_sq(move)] <= VALUE_ZERO)) ss->reduction += ONE_PLY; if (move == countermove) -- 1.7.0.4