mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-20 09:06:45 +08:00
Assorted code-style triviality
No functional change.
This commit is contained in:
@@ -137,13 +137,13 @@ namespace {
|
|||||||
V(0), V(5), V(8), V(8), V(8), V(8), V(5), V(0) }
|
V(0), V(5), V(8), V(8), V(8), V(8), V(5), V(0) }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Threat[attacking][attacked] contains bonuses according to which piece
|
// Threat[defended/weak][minor/major attacking][attacked PieceType] contains
|
||||||
// type attacks which one.
|
// bonuses according to which piece type attacks which one.
|
||||||
const Score Threat[][PIECE_TYPE_NB] = {
|
const Score Threat[][2][PIECE_TYPE_NB] = {
|
||||||
{ S(0, 0), S( 0, 0), S(19, 37), S(24, 37), S(44, 97), S(35,106) }, // Protected Minor attacks
|
{ { S(0, 0), S( 0, 0), S(19, 37), S(24, 37), S(44, 97), S(35,106) }, // Defended Minor
|
||||||
{ S(0, 0), S( 0, 0), S( 9, 14), S( 9, 14), S( 7, 14), S(24, 48) }, // Protected Major attacks
|
{ S(0, 0), S( 0, 0), S( 9, 14), S( 9, 14), S( 7, 14), S(24, 48) } }, // Defended Major
|
||||||
{ S(0, 0), S( 0,32), S(33, 41), S(31, 50), S(41,100), S(35,104) }, // Weak Minor attacks
|
{ { S(0, 0), S( 0,32), S(33, 41), S(31, 50), S(41,100), S(35,104) }, // Weak Minor
|
||||||
{ S(0, 0), S( 0,27), S(26, 57), S(26, 57), S(0 , 43), S(23, 51) } // Weak Major attacks
|
{ S(0, 0), S( 0,27), S(26, 57), S(26, 57), S(0 , 43), S(23, 51) } } // Weak Major
|
||||||
};
|
};
|
||||||
|
|
||||||
// ThreatenedByPawn[PieceType] contains a penalty according to which piece
|
// ThreatenedByPawn[PieceType] contains a penalty according to which piece
|
||||||
@@ -153,9 +153,9 @@ namespace {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Assorted bonuses and penalties used by evaluation
|
// Assorted bonuses and penalties used by evaluation
|
||||||
const Score KingOnOne = S(2 , 58);
|
const Score KingOnOne = S( 2, 58);
|
||||||
const Score KingOnMany = S(6 ,125);
|
const Score KingOnMany = S( 6,125);
|
||||||
const Score RookOnPawn = S(7 , 27);
|
const Score RookOnPawn = S( 7, 27);
|
||||||
const Score RookOpenFile = S(43, 21);
|
const Score RookOpenFile = S(43, 21);
|
||||||
const Score RookSemiOpenFile = S(19, 10);
|
const Score RookSemiOpenFile = S(19, 10);
|
||||||
const Score BishopPawns = S( 8, 12);
|
const Score BishopPawns = S( 8, 12);
|
||||||
@@ -490,8 +490,6 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// evaluate_threats() assigns bonuses according to the type of attacking piece
|
// evaluate_threats() assigns bonuses according to the type of attacking piece
|
||||||
// and the type of attacked one.
|
// and the type of attacked one.
|
||||||
|
|
||||||
@@ -500,49 +498,50 @@ namespace {
|
|||||||
|
|
||||||
const Color Them = (Us == WHITE ? BLACK : WHITE);
|
const Color Them = (Us == WHITE ? BLACK : WHITE);
|
||||||
|
|
||||||
enum { Protected_Minor, Protected_Major, Minor, Major };
|
enum { Defended, Weak };
|
||||||
Bitboard b, weakEnemies, protectedEnemies;
|
enum { Minor, Major };
|
||||||
|
|
||||||
|
Bitboard b, weak, defended;
|
||||||
Score score = SCORE_ZERO;
|
Score score = SCORE_ZERO;
|
||||||
|
|
||||||
// Enemies defended by a pawn and under our attack
|
// Non-pawn enemies defended by a pawn and under our attack
|
||||||
protectedEnemies = (pos.pieces(Them) ^ pos.pieces(Them, PAWN))
|
defended = (pos.pieces(Them) ^ pos.pieces(Them, PAWN))
|
||||||
& ei.attackedBy[Them][PAWN]
|
& ei.attackedBy[Them][PAWN]
|
||||||
& (ei.attackedBy[Us][KNIGHT] | ei.attackedBy[Us][BISHOP] | ei.attackedBy[Us][ROOK]);
|
& (ei.attackedBy[Us][KNIGHT] | ei.attackedBy[Us][BISHOP] | ei.attackedBy[Us][ROOK]);
|
||||||
|
|
||||||
if (protectedEnemies)
|
// Add a bonus according to the kind of attacking pieces
|
||||||
|
if (defended)
|
||||||
{
|
{
|
||||||
// Enemies defended by a pawn and under our attack by a minor piece
|
b = defended & (ei.attackedBy[Us][KNIGHT] | ei.attackedBy[Us][BISHOP]);
|
||||||
b = protectedEnemies & (ei.attackedBy[Us][KNIGHT] | ei.attackedBy[Us][BISHOP]);
|
|
||||||
while (b)
|
while (b)
|
||||||
score += Threat[Protected_Minor][type_of(pos.piece_on(pop_lsb(&b)))];
|
score += Threat[Defended][Minor][type_of(pos.piece_on(pop_lsb(&b)))];
|
||||||
|
|
||||||
// Enemies defended by a pawn and under our attack by a ROOK
|
b = defended & (ei.attackedBy[Us][ROOK]);
|
||||||
b = protectedEnemies & (ei.attackedBy[Us][ROOK]);
|
|
||||||
while (b)
|
while (b)
|
||||||
score += Threat[Protected_Major][type_of(pos.piece_on(pop_lsb(&b)))];
|
score += Threat[Defended][Major][type_of(pos.piece_on(pop_lsb(&b)))];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enemies not defended by a pawn and under our attack
|
// Enemies not defended by a pawn and under our attack
|
||||||
weakEnemies = pos.pieces(Them)
|
weak = pos.pieces(Them)
|
||||||
& ~ei.attackedBy[Them][PAWN]
|
& ~ei.attackedBy[Them][PAWN]
|
||||||
& ei.attackedBy[Us][ALL_PIECES];
|
& ei.attackedBy[Us][ALL_PIECES];
|
||||||
|
|
||||||
// Add a bonus according if the attacking pieces are minor or major
|
// Add a bonus according to the kind of attacking pieces
|
||||||
if (weakEnemies)
|
if (weak)
|
||||||
{
|
{
|
||||||
b = weakEnemies & (ei.attackedBy[Us][KNIGHT] | ei.attackedBy[Us][BISHOP]);
|
b = weak & (ei.attackedBy[Us][KNIGHT] | ei.attackedBy[Us][BISHOP]);
|
||||||
while (b)
|
while (b)
|
||||||
score += Threat[Minor][type_of(pos.piece_on(pop_lsb(&b)))];
|
score += Threat[Weak][Minor][type_of(pos.piece_on(pop_lsb(&b)))];
|
||||||
|
|
||||||
b = weakEnemies & (ei.attackedBy[Us][ROOK] | ei.attackedBy[Us][QUEEN]);
|
b = weak & (ei.attackedBy[Us][ROOK] | ei.attackedBy[Us][QUEEN]);
|
||||||
while (b)
|
while (b)
|
||||||
score += Threat[Major][type_of(pos.piece_on(pop_lsb(&b)))];
|
score += Threat[Weak][Major][type_of(pos.piece_on(pop_lsb(&b)))];
|
||||||
|
|
||||||
b = weakEnemies & ~ei.attackedBy[Them][ALL_PIECES];
|
b = weak & ~ei.attackedBy[Them][ALL_PIECES];
|
||||||
if (b)
|
if (b)
|
||||||
score += more_than_one(b) ? Hanging * popcount<Max15>(b) : Hanging;
|
score += more_than_one(b) ? Hanging * popcount<Max15>(b) : Hanging;
|
||||||
|
|
||||||
b = weakEnemies & ei.attackedBy[Us][KING];
|
b = weak & ei.attackedBy[Us][KING];
|
||||||
if (b)
|
if (b)
|
||||||
score += more_than_one(b) ? KingOnMany : KingOnOne;
|
score += more_than_one(b) ? KingOnMany : KingOnOne;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -331,7 +331,6 @@ namespace {
|
|||||||
alpha = (alpha + beta) / 2;
|
alpha = (alpha + beta) / 2;
|
||||||
beta = std::min(bestValue + delta, VALUE_INFINITE);
|
beta = std::min(bestValue + delta, VALUE_INFINITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -97,24 +97,20 @@ void TranspositionTable::store(const Key key, Value v, Bound b, Depth d, Move m,
|
|||||||
const uint16_t key16 = key >> 48; // Use the high 16 bits as key inside the cluster
|
const uint16_t key16 = key >> 48; // Use the high 16 bits as key inside the cluster
|
||||||
|
|
||||||
for (unsigned i = 0; i < TTClusterSize; ++i)
|
for (unsigned i = 0; i < TTClusterSize; ++i)
|
||||||
{
|
|
||||||
if (!tte[i].key16 || tte[i].key16 == key16) // Empty or overwrite old
|
if (!tte[i].key16 || tte[i].key16 == key16) // Empty or overwrite old
|
||||||
{
|
{
|
||||||
// Save preserving any existing ttMove
|
// Save preserving any existing ttMove
|
||||||
tte[i].save(key16, v, b, d, m ? m : tte[i].move(), generation, statV);
|
tte[i].save(key16, v, b, d, m ? m : tte[i].move(), generation, statV);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Implement replace strategy
|
// Implement replace strategy
|
||||||
TTEntry* replace = tte;
|
TTEntry* replace = tte;
|
||||||
for (unsigned i = 1; i < TTClusterSize; ++i)
|
for (unsigned i = 1; i < TTClusterSize; ++i)
|
||||||
{
|
|
||||||
if ( (( tte[i].genBound8 & 0xFC) == generation || tte[i].bound() == BOUND_EXACT)
|
if ( (( tte[i].genBound8 & 0xFC) == generation || tte[i].bound() == BOUND_EXACT)
|
||||||
- ((replace->genBound8 & 0xFC) == generation)
|
- ((replace->genBound8 & 0xFC) == generation)
|
||||||
- (tte[i].depth8 < replace->depth8) < 0)
|
- (tte[i].depth8 < replace->depth8) < 0)
|
||||||
replace = &tte[i];
|
replace = &tte[i];
|
||||||
}
|
|
||||||
|
|
||||||
replace->save(key16, v, b, d, m, generation, statV);
|
replace->save(key16, v, b, d, m, generation, statV);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -427,7 +427,7 @@ inline Move make(Square from, Square to, PieceType pt = KNIGHT) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline bool is_ok(Move m) {
|
inline bool is_ok(Move m) {
|
||||||
return from_sq(m) != to_sq(m); // Catches also MOVE_NULL and MOVE_NONE
|
return from_sq(m) != to_sq(m); // Catch also MOVE_NULL and MOVE_NONE
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // #ifndef TYPES_H_INCLUDED
|
#endif // #ifndef TYPES_H_INCLUDED
|
||||||
|
|||||||
Reference in New Issue
Block a user