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

Use bool(Bitboard b) instead of !!b (#1321)

The idiom !!b is confusing newcomers (e.g. Stefan needs explaining here https://groups.google.com/d/msg/fishcooking/vYqnsRI4brY/Gaf60QuACwAJ).

No functional change.
This commit is contained in:
Joost VandeVondele 2017-12-03 18:29:55 +01:00 committed by Marco Costalba
parent 28b6a457c2
commit 2acda1fde3
5 changed files with 7 additions and 8 deletions

View file

@ -130,7 +130,6 @@ constexpr bool more_than_one(Bitboard b) {
return b & (b - 1); return b & (b - 1);
} }
/// rank_bb() and file_bb() return a bitboard representing all the squares on /// rank_bb() and file_bb() return a bitboard representing all the squares on
/// the given file or rank. /// the given file or rank.

View file

@ -342,12 +342,12 @@ namespace {
// Bonus for outpost squares // Bonus for outpost squares
bb = OutpostRanks & ~pe->pawn_attacks_span(Them); bb = OutpostRanks & ~pe->pawn_attacks_span(Them);
if (bb & s) if (bb & s)
score += Outpost[Pt == BISHOP][!!(attackedBy[Us][PAWN] & s)] * 2; score += Outpost[Pt == BISHOP][bool(attackedBy[Us][PAWN] & s)] * 2;
else else
{ {
bb &= b & ~pos.pieces(Us); bb &= b & ~pos.pieces(Us);
if (bb) if (bb)
score += Outpost[Pt == BISHOP][!!(attackedBy[Us][PAWN] & bb)]; score += Outpost[Pt == BISHOP][bool(attackedBy[Us][PAWN] & bb)];
} }
// Bonus when behind a pawn // Bonus when behind a pawn
@ -388,7 +388,7 @@ namespace {
// Bonus when on an open or semi-open file // Bonus when on an open or semi-open file
if (pe->semiopen_file(Us, file_of(s))) if (pe->semiopen_file(Us, file_of(s)))
score += RookOnFile[!!pe->semiopen_file(Them, file_of(s))]; score += RookOnFile[bool(pe->semiopen_file(Them, file_of(s)))];
// Penalty when trapped by the king, even more if the king cannot castle // Penalty when trapped by the king, even more if the king cannot castle
else if (mob <= 3) else if (mob <= 3)
@ -450,7 +450,7 @@ namespace {
kingDanger = kingAttackersCount[Them] * kingAttackersWeight[Them] kingDanger = kingAttackersCount[Them] * kingAttackersWeight[Them]
+ 102 * kingAdjacentZoneAttacksCount[Them] + 102 * kingAdjacentZoneAttacksCount[Them]
+ 191 * popcount(kingRing[Us] & weak) + 191 * popcount(kingRing[Us] & weak)
+ 143 * !!pos.pinned_pieces(Us) + 143 * bool(pos.pinned_pieces(Us))
- 848 * !pos.count<QUEEN>(Them) - 848 * !pos.count<QUEEN>(Them)
- 9 * mg_value(score) / 8 - 9 * mg_value(score) / 8
+ 40; + 40;

View file

@ -174,7 +174,7 @@ namespace {
// Score this pawn // Score this pawn
if (supported | phalanx) if (supported | phalanx)
score += Connected[opposed][!!phalanx][popcount(supported)][relative_rank(Us, s)]; score += Connected[opposed][bool(phalanx)][popcount(supported)][relative_rank(Us, s)];
else if (!neighbours) else if (!neighbours)
score -= Isolated, e->weakUnopposed[Us] += !opposed; score -= Isolated, e->weakUnopposed[Us] += !opposed;

View file

@ -50,7 +50,7 @@ struct Entry {
} }
int pawns_on_same_color_squares(Color c, Square s) const { int pawns_on_same_color_squares(Color c, Square s) const {
return pawnsOnSquares[c][!!(DarkSquares & s)]; return pawnsOnSquares[c][bool(DarkSquares & s)];
} }
template<Color Us> template<Color Us>

View file

@ -1115,7 +1115,7 @@ moves_loop: // When in check search starts from here
const bool PvNode = NT == PV; const bool PvNode = NT == PV;
assert(InCheck == !!pos.checkers()); assert(InCheck == bool(pos.checkers()));
assert(alpha >= -VALUE_INFINITE && alpha < beta && beta <= VALUE_INFINITE); assert(alpha >= -VALUE_INFINITE && alpha < beta && beta <= VALUE_INFINITE);
assert(PvNode || (alpha == beta - 1)); assert(PvNode || (alpha == beta - 1));
assert(depth <= DEPTH_ZERO); assert(depth <= DEPTH_ZERO);