Merge official-stockfish/master
authorFabian Fichter <ianfab@users.noreply.github.com>
Sat, 9 Feb 2019 17:28:16 +0000 (18:28 +0100)
committerFabian Fichter <ianfab@users.noreply.github.com>
Sat, 9 Feb 2019 17:28:16 +0000 (18:28 +0100)
bench: 5031310

1  2 
src/evaluate.cpp
src/pawns.cpp
src/position.cpp

@@@ -158,17 -152,14 +158,17 @@@ namespace 
    };
  
    // PassedDanger[Rank] contains a term to weight the passed score
-   constexpr int PassedDanger[RANK_NB] = { 0, 0, 0, 2, 7, 12, 19 };
+   constexpr int PassedDanger[RANK_NB] = { 0, 0, 0, 3, 7, 11, 20 };
  
 +  // KingProximity contains a penalty according to distance from king
 +  constexpr Score KingProximity = S(2, 2);
 +
    // KingProtector[knight/bishop] contains a penalty according to distance from king
-   constexpr Score KingProtector[] = { S(4, 6), S(6, 3) };
+   constexpr Score KingProtector[] = { S(5, 6), S(6, 5) };
  
    // Assorted bonuses and penalties
-   constexpr Score BishopPawns        = S(  3,  5);
-   constexpr Score CloseEnemies       = S(  8,  0);
+   constexpr Score BishopPawns        = S(  3,  7);
+   constexpr Score CloseEnemies       = S(  6,  0);
    constexpr Score Connectivity       = S(  3,  1);
    constexpr Score CorneredBishop     = S( 50, 50);
    constexpr Score Hanging            = S( 52, 30);
          unsafeChecks &= mobilityArea[Them];
  
          kingDanger +=        kingAttackersCount[Them] * kingAttackersWeight[Them]
-                      + 64  * kingAttacksCount[Them] * (1 + 2 * !!pos.max_check_count())
-                      + 183 * popcount(kingRing[Us] & weak) * (1 + pos.captures_to_hand() + !!pos.max_check_count())
-                      + 122 * popcount(pos.blockers_for_king(Us) | unsafeChecks)
-                      - 860 * !(pos.count<QUEEN>(Them) || pos.captures_to_hand()) / (1 + !!pos.max_check_count())
-                      -   7 * mg_value(score) / 8
-                      +  17;
 -                     +  69 * kingAttacksCount[Them]
 -                     + 185 * popcount(kingRing[Us] & weak)
++                     + 69  * kingAttacksCount[Them] * (1 + 2 * !!pos.max_check_count())
++                     + 185 * popcount(kingRing[Us] & weak) * (1 + pos.captures_to_hand() + !!pos.max_check_count())
+                      + 129 * popcount(pos.blockers_for_king(Us) | unsafeChecks)
 -                     - 873 * !pos.count<QUEEN>(Them)
++                     - 873 * !(pos.count<QUEEN>(Them) || pos.captures_to_hand()) / (1 + !!pos.max_check_count())
+                      -   6 * mg_value(score) / 8
 -                     -   2 ;
++                     -   2;
  
          // Transform the kingDanger units into a Score, and subtract it from the evaluation
          if (kingDanger > 0)
diff --cc src/pawns.cpp
Simple merge
@@@ -181,24 -167,14 +181,26 @@@ void Position::init() 
    Zobrist::side = rng.rand<Key>();
    Zobrist::noPawns = rng.rand<Key>();
  
 +  for (Color c = WHITE; c <= BLACK; ++c)
 +      for (int n = 0; n < CHECKS_NB; ++n)
 +          Zobrist::checks[c][n] = rng.rand<Key>();
 +
 +  for (Color c = WHITE; c <= BLACK; ++c)
 +      for (PieceType pt = PAWN; pt <= KING; ++pt)
 +          for (int n = 0; n < SQUARE_NB; ++n)
 +              Zobrist::inHand[make_piece(c, pt)][n] = rng.rand<Key>();
 +
    // Prepare the cuckoo tables
+   std::memset(cuckoo, 0, sizeof(cuckoo));
+   std::memset(cuckooMove, 0, sizeof(cuckooMove));
    int count = 0;
 -  for (Piece pc : Pieces)
 -      for (Square s1 = SQ_A1; s1 <= SQ_H8; ++s1)
 -          for (Square s2 = Square(s1 + 1); s2 <= SQ_H8; ++s2)
 -              if (PseudoAttacks[type_of(pc)][s1] & s2)
 +  for (Color c = WHITE; c <= BLACK; ++c)
 +      for (PieceType pt = KNIGHT; pt <= QUEEN || pt == KING; pt != QUEEN ? ++pt : pt = KING)
 +      {
 +      Piece pc = make_piece(c, pt);
 +      for (Square s1 = SQ_A1; s1 <= SQ_MAX; ++s1)
 +          for (Square s2 = Square(s1 + 1); s2 <= SQ_MAX; ++s2)
 +              if (PseudoAttacks[WHITE][type_of(pc)][s1] & s2)
                {
                    Move move = make_move(s1, s2);
                    Key key = Zobrist::psq[pc][s1] ^ Zobrist::psq[pc][s2] ^ Zobrist::side;