- /// King safety constants and variables. The king safety scores are taken
- /// from the array SafetyTable[]. Various little "meta-bonuses" measuring
- /// the strength of the attack are added up into an integer, which is used
- /// as an index to SafetyTable[].
-
- // Attack weights for each piece type
- const int QueenAttackWeight = 5;
- const int RookAttackWeight = 3;
- const int BishopAttackWeight = 2;
- const int KnightAttackWeight = 2;
-
- // Bonuses for safe checks, initialized from UCI options
- int QueenContactCheckBonus, DiscoveredCheckBonus;
- int QueenCheckBonus, RookCheckBonus, BishopCheckBonus, KnightCheckBonus;
-
- // Scan for queen contact mates?
- const bool QueenContactMates = true;
-
- // Bonus for having a mate threat, initialized from UCI options
- int MateThreatBonus;
-
- // ThreatBonus[][] contains bonus according to which piece type
- // attacks which one.
- const Value MidgameThreatBonus[8][8] = {
- V(0), V(0), V(0), V(0), V(0), V(0), V(0), V(0), // not used
- V(0),V(30), V(0),V(50), V(70), V(70), V(0), V(0), // KNIGHT attacks
- V(0),V(30),V(50), V(0), V(70), V(70), V(0), V(0), // BISHOP attacks
- V(0),V(20),V(40),V(40), V(0), V(50), V(0), V(0), // ROOK attacks
- V(0),V(40),V(40),V(40), V(40), V(0), V(0), V(0), // QUEEN attacks
- V(0), V(0), V(0), V(0), V(0), V(0), V(0), V(0), // not used
- V(0), V(0), V(0), V(0), V(0), V(0), V(0), V(0), // not used
- V(0), V(0), V(0), V(0), V(0), V(0), V(0), V(0) // not used
- };
-
- const Value EndgameThreatBonus[8][8] = {
- V(0), V(0), V(0), V(0), V(0), V(0), V(0), V(0), // not used
- V(0),V(40), V(0),V(50),V(100),V(100), V(0), V(0), // KNIGHT attacks
- V(0),V(40),V(50), V(0),V(100),V(100), V(0), V(0), // BISHOP attacks
- V(0),V(30),V(50),V(50), V(0), V(50), V(0), V(0), // ROOK attacks
- V(0),V(40),V(40),V(40), V(40), V(0), V(0), V(0), // QUEEN attacks
- V(0), V(0), V(0), V(0), V(0), V(0), V(0), V(0), // not used
- V(0), V(0), V(0), V(0), V(0), V(0), V(0), V(0), // not used
- V(0), V(0), V(0), V(0), V(0), V(0), V(0), V(0) // not used
- };
-
- // ThreatedByPawnPenalty[] contains a penalty according to which piece
- // type is attacked by an enemy pawn.
- const Value MidgameThreatedByPawnPenalty[8] = {
- V(0), V(0), V(50), V(50), V(70), V(80), V(0), V(0)
- };
-
- const Value EndgameThreatedByPawnPenalty[8] = {
- V(0), V(0), V(70), V(70), V(100), V(120), V(0), V(0)
- };
-
- // InitKingDanger[] contains bonuses based on the position of the defending
- // king.
- const int InitKingDanger[64] = {
+ // King danger constants and variables. The king danger scores are taken
+ // from the KingDangerTable[]. Various little "meta-bonuses" measuring
+ // the strength of the enemy attack are added up into an integer, which
+ // is used as an index to KingDangerTable[].
+ //
+ // KingAttackWeights[PieceType] contains king attack weights by piece type
+ const int KingAttackWeights[] = { 0, 0, 2, 2, 3, 5 };
+
+ // Bonuses for enemy's safe checks
+ const int QueenContactCheckBonus = 6;
+ const int RookContactCheckBonus = 4;
+ const int QueenCheckBonus = 3;
+ const int RookCheckBonus = 2;
+ const int BishopCheckBonus = 1;
+ const int KnightCheckBonus = 1;
+
+ // InitKingDanger[Square] contains penalties based on the position of the
+ // defending king, indexed by king's square (from white's point of view).
+ const int InitKingDanger[] = {