Use an optinal argument instead of a template
parameter. Interestingly, not only is simpler,
but also faster, perhaps due to less L1 instruction
cache pressure because we don't duplicate the very
used SEE code path.
No functional change.
/// Position::see() is a static exchange evaluator: It tries to estimate the
/// Position::see() is a static exchange evaluator: It tries to estimate the
-/// material gain or loss resulting from a move. There are three versions of
-/// this function: One which takes a destination square as input, one takes a
-/// move, and one which takes a 'from' and a 'to' square. The function does
-/// not yet understand promotions captures.
+/// material gain or loss resulting from a move. Parameter 'asymmThreshold' takes
+/// tempi into account. If the side who initiated the capturing sequence does the
+/// last capture, he loses a tempo and if the result is below 'asymmThreshold'
+/// the capturing sequence is considered bad.
int Position::see_sign(Move m) const {
int Position::see_sign(Move m) const {
-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 {
+int Position::see(Move m, int asymmThreshold) const {
Square from, to;
Bitboard occupied, attackers, stmAttackers;
Square from, to;
Bitboard occupied, attackers, stmAttackers;
} while (stmAttackers);
// If we are doing asymmetric SEE evaluation and the same side does the first
} 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)
- {
+ // and the last capture, he loses a tempo and gain must be at least worth
+ // 'asymmThreshold', otherwise we replace the score with a very low value,
+ // before negamaxing.
+ if (asymmThreshold)
+ for (int i = 0; i < slIndex; i += 2)
if (swapList[i] < asymmThreshold)
if (swapList[i] < asymmThreshold)
- swapList[i] = - QueenValueMg * 16;
- }
- }
+ 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.
// 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.
void undo_null_move();
// Static exchange evaluation
void undo_null_move();
// Static exchange evaluation
+ int see(Move m, int asymmThreshold = 0) const;
int see_sign(Move m) const;
int see_sign(Move m) const;
- int see_asymm(Move m, int asymmThreshold) const;
// Accessing hash keys
Key key() const;
// Accessing hash keys
Key key() const;
// Helper functions
void do_castle(Square kfrom, Square kto, Square rfrom, Square rto);
// Helper functions
void do_castle(Square kfrom, Square kto, Square rfrom, Square rto);
- template<bool Asymmetric> int do_see(Move m, int asymmThreshold) const;
template<bool FindPinned> Bitboard hidden_checkers() const;
// Computing hash keys from scratch (for initialization and debugging)
template<bool FindPinned> Bitboard hidden_checkers() const;
// Computing hash keys from scratch (for initialization and debugging)
- // Prune moves with negative or equal SEE.
- // Also prune moves with positive SEE where capturing loses a tempo and SEE < beta - futilityBase.
+ // Prune moves with negative or equal SEE and also moves with positive
+ // SEE where capturing piece loses a tempo and SEE < beta - futilityBase.
if ( futilityBase < beta
&& depth < DEPTH_ZERO
if ( futilityBase < beta
&& depth < DEPTH_ZERO
- && pos.see_asymm(move, beta - futilityBase) <= 0)
+ && pos.see(move, beta - futilityBase) <= 0)
{
bestValue = std::max(bestValue, futilityBase);
continue;
{
bestValue = std::max(bestValue, futilityBase);
continue;