#include <cassert>
#include <cstring>
+#include <iomanip>
#include <iostream>
#include <sstream>
#include <algorithm>
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)) << " ";
}
int Position::see(Move m) const {
+ return do_see<false>(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<true>(m, asymmThreshold);
+}
+
+template <bool Asymmetric>
+int Position::do_see(Move m, int asymmThreshold) const {
Square from, to;
Bitboard occupied, attackers, stmAttackers;
} 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)