1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 16:53:09 +00:00

Some reformatting in pawns.cpp

No functional change.
This commit is contained in:
Marco Costalba 2014-06-21 14:32:11 +02:00
parent e8baf2b772
commit aa23eb4440

View file

@ -57,7 +57,7 @@ namespace {
S( 0, 0), S( 6, 13), S(6,13), S(14,29), S( 0, 0), S( 6, 13), S(6,13), S(14,29),
S(34,68), S(83,166), S(0, 0), S( 0, 0) }; S(34,68), S(83,166), S(0, 0), S( 0, 0) };
// Levers bonus by rank // Levers bonus by rank
const Score Lever[RANK_NB] = { const Score Lever[RANK_NB] = {
S( 0, 0), S( 0, 0), S(0, 0), S(0, 0), S( 0, 0), S( 0, 0), S(0, 0), S(0, 0),
S(20,20), S(40,40), S(0, 0), S(0, 0) }; S(20,20), S(40,40), S(0, 0), S(0, 0) };
@ -74,7 +74,7 @@ namespace {
// Danger of enemy pawns moving toward our king indexed by // Danger of enemy pawns moving toward our king indexed by
// [no friendly pawn | pawn unblocked | pawn blocked][rank of enemy pawn] // [no friendly pawn | pawn unblocked | pawn blocked][rank of enemy pawn]
const Value StormDanger[3][RANK_NB] = { const Value StormDanger[][RANK_NB] = {
{ V( 0), V(64), V(128), V(51), V(26) }, { V( 0), V(64), V(128), V(51), V(26) },
{ V(26), V(32), V( 96), V(38), V(20) }, { V(26), V(32), V( 96), V(38), V(20) },
{ V( 0), V( 0), V(160), V(25), V(13) } }; { V( 0), V( 0), V(160), V(25), V(13) } };
@ -223,20 +223,19 @@ namespace Pawns {
void init() { void init() {
const int bonusesByFile[8] = { 1, 3, 3, 4, 4, 3, 3, 1 }; const int bonusByFile[] = { 1, 3, 3, 4, 4, 3, 3, 1 };
int bonus;
for (Rank r = RANK_1; r < RANK_8; ++r) for (Rank r = RANK_1; r < RANK_8; ++r)
for (File f = FILE_A; f <= FILE_H; ++f) for (File f = FILE_A; f <= FILE_H; ++f)
{ {
bonus = r * (r-1) * (r-2) + bonusesByFile[f] * (r/2 + 1); int bonus = r * (r - 1) * (r - 2) + bonusByFile[f] * (r / 2 + 1);
Connected[f][r] = make_score(bonus, bonus); Connected[f][r] = make_score(bonus, bonus);
} }
} }
/// probe() takes a position object as input, computes a Entry object, and returns /// probe() takes a position as input, computes a Entry object, and returns a
/// a pointer to it. The result is also stored in a hash table, so we don't have /// pointer to it. The result is also stored in a hash table, so we don't have
/// to recompute everything when the same pawn structure occurs again. /// to recompute everything when the same pawn structure occurs again.
Entry* probe(const Position& pos, Table& entries) { Entry* probe(const Position& pos, Table& entries) {
@ -260,30 +259,30 @@ template<Color Us>
Value Entry::shelter_storm(const Position& pos, Square ksq) { Value Entry::shelter_storm(const Position& pos, Square ksq) {
const Color Them = (Us == WHITE ? BLACK : WHITE); const Color Them = (Us == WHITE ? BLACK : WHITE);
static const Bitboard MiddleEdges = (FileABB | FileHBB) & (Rank2BB | Rank3BB); const Bitboard Edges = (FileABB | FileHBB) & (Rank2BB | Rank3BB);
Value safety = MaxSafetyBonus;
Bitboard b = pos.pieces(PAWN) & (in_front_bb(Us, rank_of(ksq)) | rank_bb(ksq)); Bitboard b = pos.pieces(PAWN) & (in_front_bb(Us, rank_of(ksq)) | rank_bb(ksq));
Bitboard ourPawns = b & pos.pieces(Us); Bitboard ourPawns = b & pos.pieces(Us);
Bitboard theirPawns = b & pos.pieces(Them); Bitboard theirPawns = b & pos.pieces(Them);
Rank rkUs, rkThem; Value safety = MaxSafetyBonus;
File kf = std::max(FILE_B, std::min(FILE_G, file_of(ksq))); File kf = std::max(FILE_B, std::min(FILE_G, file_of(ksq)));
for (File f = kf - File(1); f <= kf + File(1); ++f) for (File f = kf - File(1); f <= kf + File(1); ++f)
{ {
b = ourPawns & file_bb(f); b = ourPawns & file_bb(f);
rkUs = b ? relative_rank(Us, backmost_sq(Us, b)) : RANK_1; Rank rkUs = b ? relative_rank(Us, backmost_sq(Us, b)) : RANK_1;
b = theirPawns & file_bb(f); b = theirPawns & file_bb(f);
rkThem = b ? relative_rank(Us, frontmost_sq(Them, b)) : RANK_1; Rank rkThem = b ? relative_rank(Us, frontmost_sq(Them, b)) : RANK_1;
if ( (MiddleEdges & make_square(f, rkThem)) if ( (Edges & make_square(f, rkThem))
&& file_of(ksq) == f && file_of(ksq) == f
&& relative_rank(Us, ksq) == rkThem - 1) && relative_rank(Us, ksq) == rkThem - 1)
safety += 200; safety += 200;
else else
safety -= ShelterWeakness[rkUs] safety -= ShelterWeakness[rkUs]
+ StormDanger[rkUs == RANK_1 ? 0 : rkThem == rkUs + 1 ? 2 : 1][rkThem]; + StormDanger[rkUs == RANK_1 ? 0 :
rkThem != rkUs + 1 ? 1 : 2][rkThem];
} }
return safety; return safety;