X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fposition.cpp;h=1b2defa54662a34718bb46c79e40ae9abffbe595;hp=8c36d9ac26ab604da8b994d0943d450a77f7a1fd;hb=d23454854e72e1311363a8c98cd58a5d44c427f9;hpb=c5ec94d0f1b128fc2c691c7231663a345409d5cc diff --git a/src/position.cpp b/src/position.cpp index 8c36d9ac..1b2defa5 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -400,7 +401,8 @@ const string Position::pretty(Move move) const { if (piece_on(sq) != NO_PIECE) brd[513 - 68*rank_of(sq) + 4*file_of(sq)] = PieceToChar[piece_on(sq)]; - ss << brd << "\nFen: " << fen() << "\nKey: " << st->key << "\nCheckers: "; + ss << brd << "\nFen: " << fen() << "\nKey: " << std::hex << std::uppercase + << std::setfill('0') << std::setw(16) << st->key << "\nCheckers: "; for (Bitboard b = checkers(); b; ) ss << square_to_string(pop_lsb(&b)) << " "; @@ -1146,6 +1148,21 @@ int Position::see_sign(Move m) const { } int Position::see(Move m) const { + return do_see(m, 0); +} + +/// Position::see_asymm() takes tempi into account. +/// If the side who initiated the capturing sequence does the last capture, +/// he loses a tempo. In this case if the result is below asymmThreshold +/// the capturing sequence is considered bad. + +int Position::see_asymm(Move m, int asymmThreshold) const +{ + return do_see(m, asymmThreshold); +} + +template +int Position::do_see(Move m, int asymmThreshold) const { Square from, to; Bitboard occupied, attackers, stmAttackers; @@ -1222,6 +1239,18 @@ int Position::see(Move m) const { } while (stmAttackers); + // If we are doing asymmetric SEE evaluation and the same side does the first + // and the last capture, he loses a tempo and gain must be at least worth "asymmThreshold". + // If not, we replace the score with a very low value, before negamaxing. + if (Asymmetric) + { + for (int i = 0; i < slIndex ; i += 2) + { + if (swapList[i] < asymmThreshold) + swapList[i] = - QueenValueMg * 16; + } + } + // Having built the swap list, we negamax through it to find the best // achievable score from the point of view of the side to move. while (--slIndex)