Skip to content

Commit

Permalink
Windmill
Browse files Browse the repository at this point in the history
Bench: 3491424
  • Loading branch information
snicolet committed Jan 4, 2019
1 parent bb843a0 commit 86c62a2
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/evaluate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <cstring> // For std::memset
#include <iomanip>
#include <sstream>
#include <iostream>

#include "bitboard.h"
#include "evaluate.h"
Expand Down Expand Up @@ -96,6 +97,7 @@ namespace {
constexpr int RookSafeCheck = 880;
constexpr int BishopSafeCheck = 435;
constexpr int KnightSafeCheck = 790;
constexpr int Windmill = 500;

#define S(mg, eg) make_score(mg, eg)

Expand Down Expand Up @@ -474,6 +476,24 @@ namespace {
+ mg_value(mobility[Them] - mobility[Us])
- 30;

// Penalty when the opponent takes material by discovered check,
// like in the windmill combinaison
b = pos.blockers_for_king(Us) & pos.pieces(Them);
while (b)
{
Square s = pop_lsb(&b);
PieceType pt = type_of(pos.piece_on(s));
Bitboard attacks = (pt == PAWN ? pos.attacks_from<PAWN>(s, Them) : pos.attacks_from(pt, s));

// std::cerr << pos << std::endl;
// std::cerr << Bitboards::pretty(SquareBB[s]) << std::endl;
// std::cerr << Bitboards::pretty(attacks) << std::endl;
// std::cerr << "========================================================================" << std::endl;

if (attacks & pos.pieces(Us))
kingDanger += Windmill;
}

// Transform the kingDanger units into a Score, and subtract it from the evaluation
if (kingDanger > 0)
score -= make_score(kingDanger * kingDanger / 4096, kingDanger / 16);
Expand Down

0 comments on commit 86c62a2

Please sign in to comment.