Skip to content

Commit

Permalink
Merge branch 'master' into ttDepthm50c
Browse files Browse the repository at this point in the history
  • Loading branch information
vondele committed Nov 1, 2019
2 parents dd6ac0e + e8fca71 commit e0fa8e2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
24 changes: 9 additions & 15 deletions src/evaluate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ namespace {
void Evaluation<T>::initialize() {

constexpr Color Them = (Us == WHITE ? BLACK : WHITE);
constexpr Direction Up = (Us == WHITE ? NORTH : SOUTH);
constexpr Direction Down = (Us == WHITE ? SOUTH : NORTH);
constexpr Direction Up = pawn_push(Us);
constexpr Direction Down = -Up;
constexpr Bitboard LowRanks = (Us == WHITE ? Rank2BB | Rank3BB : Rank7BB | Rank6BB);

const Square ksq = pos.square<KING>(Us);
Expand All @@ -235,15 +235,9 @@ namespace {
attackedBy2[Us] = dblAttackByPawn | (attackedBy[Us][KING] & attackedBy[Us][PAWN]);

// Init our king safety tables
kingRing[Us] = attackedBy[Us][KING];
if (relative_rank(Us, ksq) == RANK_1)
kingRing[Us] |= shift<Up>(kingRing[Us]);

if (file_of(ksq) == FILE_H)
kingRing[Us] |= shift<WEST>(kingRing[Us]);

else if (file_of(ksq) == FILE_A)
kingRing[Us] |= shift<EAST>(kingRing[Us]);
Square s = make_square(clamp(file_of(ksq), FILE_B, FILE_G),
clamp(rank_of(ksq), RANK_2, RANK_7));
kingRing[Us] = PseudoAttacks[KING][s] | s;

kingAttackersCount[Them] = popcount(kingRing[Us] & pe->pawn_attacks(Them));
kingAttacksCount[Them] = kingAttackersWeight[Them] = 0;
Expand All @@ -258,7 +252,7 @@ namespace {
Score Evaluation<T>::pieces() {

constexpr Color Them = (Us == WHITE ? BLACK : WHITE);
constexpr Direction Down = (Us == WHITE ? SOUTH : NORTH);
constexpr Direction Down = -pawn_push(Us);
constexpr Bitboard OutpostRanks = (Us == WHITE ? Rank4BB | Rank5BB | Rank6BB
: Rank5BB | Rank4BB | Rank3BB);
const Square* pl = pos.squares<Pt>(Us);
Expand Down Expand Up @@ -484,7 +478,7 @@ namespace {
Score Evaluation<T>::threats() const {

constexpr Color Them = (Us == WHITE ? BLACK : WHITE);
constexpr Direction Up = (Us == WHITE ? NORTH : SOUTH);
constexpr Direction Up = pawn_push(Us);
constexpr Bitboard TRank3BB = (Us == WHITE ? Rank3BB : Rank6BB);

Bitboard b, weak, defended, nonPawnEnemies, stronglyProtected, safe;
Expand Down Expand Up @@ -578,7 +572,7 @@ namespace {
Score Evaluation<T>::passed() const {

constexpr Color Them = (Us == WHITE ? BLACK : WHITE);
constexpr Direction Up = (Us == WHITE ? NORTH : SOUTH);
constexpr Direction Up = pawn_push(Us);

auto king_proximity = [&](Color c, Square s) {
return std::min(distance(pos.square<KING>(c), s), 5);
Expand Down Expand Up @@ -669,7 +663,7 @@ namespace {
return SCORE_ZERO;

constexpr Color Them = (Us == WHITE ? BLACK : WHITE);
constexpr Direction Down = (Us == WHITE ? SOUTH : NORTH);
constexpr Direction Down = -pawn_push(Us);
constexpr Bitboard SpaceMask =
Us == WHITE ? CenterFiles & (Rank2BB | Rank3BB | Rank4BB)
: CenterFiles & (Rank7BB | Rank6BB | Rank5BB);
Expand Down
2 changes: 1 addition & 1 deletion src/movegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace {
constexpr Color Them = (Us == WHITE ? BLACK : WHITE);
constexpr Bitboard TRank7BB = (Us == WHITE ? Rank7BB : Rank2BB);
constexpr Bitboard TRank3BB = (Us == WHITE ? Rank3BB : Rank6BB);
constexpr Direction Up = (Us == WHITE ? NORTH : SOUTH);
constexpr Direction Up = pawn_push(Us);
constexpr Direction UpRight = (Us == WHITE ? NORTH_EAST : SOUTH_WEST);
constexpr Direction UpLeft = (Us == WHITE ? NORTH_WEST : SOUTH_EAST);

Expand Down
2 changes: 1 addition & 1 deletion src/pawns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ namespace {
Score evaluate(const Position& pos, Pawns::Entry* e) {

constexpr Color Them = (Us == WHITE ? BLACK : WHITE);
constexpr Direction Up = (Us == WHITE ? NORTH : SOUTH);
constexpr Direction Up = pawn_push(Us);

Bitboard neighbours, stoppers, support, phalanx, opposed;
Bitboard lever, leverPush, blocked;
Expand Down
2 changes: 1 addition & 1 deletion src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ void Thread::search() {
beta = std::min(previousScore + delta, VALUE_INFINITE);

// Adjust contempt based on root move's previousScore (dynamic contempt)
int dct = ct + 86 * previousScore / (abs(previousScore) + 176);
int dct = ct + (111 - ct / 2) * previousScore / (abs(previousScore) + 176);

contempt = (us == WHITE ? make_score(dct, dct / 2)
: -make_score(dct, dct / 2));
Expand Down

0 comments on commit e0fa8e2

Please sign in to comment.