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

Closes #1148
This commit is contained in:
Alain SAVARD 2017-06-23 00:03:58 -04:00 committed by Joona Kiiski
parent 69eb391cd7
commit 6d24ef8585
5 changed files with 53 additions and 52 deletions

View file

@ -30,11 +30,11 @@ Bitboard SquareBB[SQUARE_NB];
Bitboard FileBB[FILE_NB]; Bitboard FileBB[FILE_NB];
Bitboard RankBB[RANK_NB]; Bitboard RankBB[RANK_NB];
Bitboard AdjacentFilesBB[FILE_NB]; Bitboard AdjacentFilesBB[FILE_NB];
Bitboard InFrontBB[COLOR_NB][RANK_NB]; Bitboard ForwardRanksBB[COLOR_NB][RANK_NB];
Bitboard BetweenBB[SQUARE_NB][SQUARE_NB]; Bitboard BetweenBB[SQUARE_NB][SQUARE_NB];
Bitboard LineBB[SQUARE_NB][SQUARE_NB]; Bitboard LineBB[SQUARE_NB][SQUARE_NB];
Bitboard DistanceRingBB[SQUARE_NB][8]; Bitboard DistanceRingBB[SQUARE_NB][8];
Bitboard ForwardBB[COLOR_NB][SQUARE_NB]; Bitboard ForwardFileBB[COLOR_NB][SQUARE_NB];
Bitboard PassedPawnMask[COLOR_NB][SQUARE_NB]; Bitboard PassedPawnMask[COLOR_NB][SQUARE_NB];
Bitboard PawnAttackSpan[COLOR_NB][SQUARE_NB]; Bitboard PawnAttackSpan[COLOR_NB][SQUARE_NB];
Bitboard PseudoAttacks[PIECE_TYPE_NB][SQUARE_NB]; Bitboard PseudoAttacks[PIECE_TYPE_NB][SQUARE_NB];
@ -163,14 +163,14 @@ void Bitboards::init() {
AdjacentFilesBB[f] = (f > FILE_A ? FileBB[f - 1] : 0) | (f < FILE_H ? FileBB[f + 1] : 0); AdjacentFilesBB[f] = (f > FILE_A ? FileBB[f - 1] : 0) | (f < FILE_H ? FileBB[f + 1] : 0);
for (Rank r = RANK_1; r < RANK_8; ++r) for (Rank r = RANK_1; r < RANK_8; ++r)
InFrontBB[WHITE][r] = ~(InFrontBB[BLACK][r + 1] = InFrontBB[BLACK][r] | RankBB[r]); ForwardRanksBB[WHITE][r] = ~(ForwardRanksBB[BLACK][r + 1] = ForwardRanksBB[BLACK][r] | RankBB[r]);
for (Color c = WHITE; c <= BLACK; ++c) for (Color c = WHITE; c <= BLACK; ++c)
for (Square s = SQ_A1; s <= SQ_H8; ++s) for (Square s = SQ_A1; s <= SQ_H8; ++s)
{ {
ForwardBB[c][s] = InFrontBB[c][rank_of(s)] & FileBB[file_of(s)]; ForwardFileBB [c][s] = ForwardRanksBB[c][rank_of(s)] & FileBB[file_of(s)];
PawnAttackSpan[c][s] = InFrontBB[c][rank_of(s)] & AdjacentFilesBB[file_of(s)]; PawnAttackSpan[c][s] = ForwardRanksBB[c][rank_of(s)] & AdjacentFilesBB[file_of(s)];
PassedPawnMask[c][s] = ForwardBB[c][s] | PawnAttackSpan[c][s]; PassedPawnMask[c][s] = ForwardFileBB [c][s] | PawnAttackSpan[c][s];
} }
for (Square s1 = SQ_A1; s1 <= SQ_H8; ++s1) for (Square s1 = SQ_A1; s1 <= SQ_H8; ++s1)

View file

@ -65,11 +65,11 @@ extern Bitboard SquareBB[SQUARE_NB];
extern Bitboard FileBB[FILE_NB]; extern Bitboard FileBB[FILE_NB];
extern Bitboard RankBB[RANK_NB]; extern Bitboard RankBB[RANK_NB];
extern Bitboard AdjacentFilesBB[FILE_NB]; extern Bitboard AdjacentFilesBB[FILE_NB];
extern Bitboard InFrontBB[COLOR_NB][RANK_NB]; extern Bitboard ForwardRanksBB[COLOR_NB][RANK_NB];
extern Bitboard BetweenBB[SQUARE_NB][SQUARE_NB]; extern Bitboard BetweenBB[SQUARE_NB][SQUARE_NB];
extern Bitboard LineBB[SQUARE_NB][SQUARE_NB]; extern Bitboard LineBB[SQUARE_NB][SQUARE_NB];
extern Bitboard DistanceRingBB[SQUARE_NB][8]; extern Bitboard DistanceRingBB[SQUARE_NB][8];
extern Bitboard ForwardBB[COLOR_NB][SQUARE_NB]; extern Bitboard ForwardFileBB[COLOR_NB][SQUARE_NB];
extern Bitboard PassedPawnMask[COLOR_NB][SQUARE_NB]; extern Bitboard PassedPawnMask[COLOR_NB][SQUARE_NB];
extern Bitboard PawnAttackSpan[COLOR_NB][SQUARE_NB]; extern Bitboard PawnAttackSpan[COLOR_NB][SQUARE_NB];
extern Bitboard PseudoAttacks[PIECE_TYPE_NB][SQUARE_NB]; extern Bitboard PseudoAttacks[PIECE_TYPE_NB][SQUARE_NB];
@ -179,28 +179,28 @@ inline Bitboard between_bb(Square s1, Square s2) {
} }
/// in_front_bb() returns a bitboard representing all the squares on all the ranks /// forward_ranks_bb() returns a bitboard representing all the squares on all the ranks
/// in front of the given one, from the point of view of the given color. For /// in front of the given one, from the point of view of the given color. For
/// instance, in_front_bb(BLACK, RANK_3) will return the squares on ranks 1 and 2. /// instance, forward_ranks_bb(BLACK, SQ_D3) will return the 16 squares on ranks 1 and 2.
inline Bitboard in_front_bb(Color c, Rank r) { inline Bitboard forward_ranks_bb(Color c, Square s) {
return InFrontBB[c][r]; return ForwardRanksBB[c][rank_of(s)];
} }
/// forward_bb() returns a bitboard representing all the squares along the line /// forward_file_bb() returns a bitboard representing all the squares along the line
/// in front of the given one, from the point of view of the given color: /// in front of the given one, from the point of view of the given color:
/// ForwardBB[c][s] = in_front_bb(c, rank_of(s)) & file_bb(s) /// ForwardFileBB[c][s] = forward_ranks_bb(c, s) & file_bb(s)
inline Bitboard forward_bb(Color c, Square s) { inline Bitboard forward_file_bb(Color c, Square s) {
return ForwardBB[c][s]; return ForwardFileBB[c][s];
} }
/// pawn_attack_span() returns a bitboard representing all the squares that can be /// pawn_attack_span() returns a bitboard representing all the squares that can be
/// attacked by a pawn of the given color when it moves along its file, starting /// attacked by a pawn of the given color when it moves along its file, starting
/// from the given square: /// from the given square:
/// PawnAttackSpan[c][s] = in_front_bb(c, rank_of(s)) & adjacent_files_bb(file_of(s)); /// PawnAttackSpan[c][s] = forward_ranks_bb(c, s) & adjacent_files_bb(file_of(s));
inline Bitboard pawn_attack_span(Color c, Square s) { inline Bitboard pawn_attack_span(Color c, Square s) {
return PawnAttackSpan[c][s]; return PawnAttackSpan[c][s];
@ -209,7 +209,7 @@ inline Bitboard pawn_attack_span(Color c, Square s) {
/// passed_pawn_mask() returns a bitboard mask which can be used to test if a /// passed_pawn_mask() returns a bitboard mask which can be used to test if a
/// pawn of the given color and on the given square is a passed pawn: /// pawn of the given color and on the given square is a passed pawn:
/// PassedPawnMask[c][s] = pawn_attack_span(c, s) | forward_bb(c, s) /// PassedPawnMask[c][s] = pawn_attack_span(c, s) | forward_file_bb(c, s)
inline Bitboard passed_pawn_mask(Color c, Square s) { inline Bitboard passed_pawn_mask(Color c, Square s) {
return PassedPawnMask[c][s]; return PassedPawnMask[c][s];

View file

@ -598,7 +598,7 @@ ScaleFactor Endgame<KPsK>::operator()(const Position& pos) const {
// If all pawns are ahead of the king, on a single rook file and // If all pawns are ahead of the king, on a single rook file and
// the king is within one file of the pawns, it's a draw. // the king is within one file of the pawns, it's a draw.
if ( !(pawns & ~in_front_bb(weakSide, rank_of(ksq))) if ( !(pawns & ~forward_ranks_bb(weakSide, ksq))
&& !((pawns & ~FileABB) && (pawns & ~FileHBB)) && !((pawns & ~FileABB) && (pawns & ~FileHBB))
&& distance<File>(ksq, lsb(pawns)) <= 1) && distance<File>(ksq, lsb(pawns)) <= 1)
return SCALE_FACTOR_DRAW; return SCALE_FACTOR_DRAW;
@ -645,7 +645,7 @@ ScaleFactor Endgame<KBPKB>::operator()(const Position& pos) const {
if (relative_rank(strongSide, pawnSq) <= RANK_5) if (relative_rank(strongSide, pawnSq) <= RANK_5)
return SCALE_FACTOR_DRAW; return SCALE_FACTOR_DRAW;
Bitboard path = forward_bb(strongSide, pawnSq); Bitboard path = forward_file_bb(strongSide, pawnSq);
if (path & pos.pieces(weakSide, KING)) if (path & pos.pieces(weakSide, KING))
return SCALE_FACTOR_DRAW; return SCALE_FACTOR_DRAW;
@ -780,7 +780,7 @@ ScaleFactor Endgame<KNPKB>::operator()(const Position& pos) const {
// King needs to get close to promoting pawn to prevent knight from blocking. // King needs to get close to promoting pawn to prevent knight from blocking.
// Rules for this are very tricky, so just approximate. // Rules for this are very tricky, so just approximate.
if (forward_bb(strongSide, pawnSq) & pos.attacks_from<BISHOP>(bishopSq)) if (forward_file_bb(strongSide, pawnSq) & pos.attacks_from<BISHOP>(bishopSq))
return ScaleFactor(distance(weakKingSq, pawnSq)); return ScaleFactor(distance(weakKingSq, pawnSq));
return SCALE_FACTOR_NONE; return SCALE_FACTOR_NONE;

View file

@ -88,7 +88,7 @@ namespace {
template<Color Us> void initialize(); template<Color Us> void initialize();
template<Color Us> Score evaluate_king(); template<Color Us> Score evaluate_king();
template<Color Us> Score evaluate_threats(); template<Color Us> Score evaluate_threats();
template<Color Us> Score evaluate_passer_pawns(); template<Color Us> Score evaluate_passed_pawns();
template<Color Us> Score evaluate_space(); template<Color Us> Score evaluate_space();
template<Color Us, PieceType Pt> Score evaluate_pieces(); template<Color Us, PieceType Pt> Score evaluate_pieces();
ScaleFactor evaluate_scale_factor(Value eg); ScaleFactor evaluate_scale_factor(Value eg);
@ -416,7 +416,7 @@ namespace {
: ~Bitboard(0) ^ Rank1BB ^ Rank2BB ^ Rank3BB); : ~Bitboard(0) ^ Rank1BB ^ Rank2BB ^ Rank3BB);
const Square ksq = pos.square<KING>(Us); const Square ksq = pos.square<KING>(Us);
Bitboard undefended, b, b1, b2, safe, other; Bitboard kingOnlyDefended, b, b1, b2, safe, other;
int kingDanger; int kingDanger;
// King shelter and enemy pawns storm // King shelter and enemy pawns storm
@ -426,9 +426,9 @@ namespace {
if (kingAttackersCount[Them] > (1 - pos.count<QUEEN>(Them))) if (kingAttackersCount[Them] > (1 - pos.count<QUEEN>(Them)))
{ {
// Find the attacked squares which are defended only by our king... // Find the attacked squares which are defended only by our king...
undefended = attackedBy[Them][ALL_PIECES] kingOnlyDefended = attackedBy[Them][ALL_PIECES]
& attackedBy[Us][KING] & attackedBy[Us][KING]
& ~attackedBy2[Us]; & ~attackedBy2[Us];
// ... and those which are not defended at all in the larger king ring // ... and those which are not defended at all in the larger king ring
b = attackedBy[Them][ALL_PIECES] & ~attackedBy[Us][ALL_PIECES] b = attackedBy[Them][ALL_PIECES] & ~attackedBy[Us][ALL_PIECES]
@ -437,11 +437,11 @@ namespace {
// Initialize the 'kingDanger' variable, which will be transformed // Initialize the 'kingDanger' variable, which will be transformed
// later into a king danger score. The initial value is based on the // later into a king danger score. The initial value is based on the
// number and types of the enemy's attacking pieces, the number of // number and types of the enemy's attacking pieces, the number of
// attacked and undefended squares around our king and the quality of // attacked and weak squares around our king, the absence of queen and
// the pawn shelter (current 'score' value). // the quality of the pawn shelter (current 'score' value).
kingDanger = kingAttackersCount[Them] * kingAttackersWeight[Them] kingDanger = kingAttackersCount[Them] * kingAttackersWeight[Them]
+ 102 * kingAdjacentZoneAttacksCount[Them] + 102 * kingAdjacentZoneAttacksCount[Them]
+ 201 * popcount(undefended) + 201 * popcount(kingOnlyDefended)
+ 143 * (popcount(b) + !!pos.pinned_pieces(Us)) + 143 * (popcount(b) + !!pos.pinned_pieces(Us))
- 848 * !pos.count<QUEEN>(Them) - 848 * !pos.count<QUEEN>(Them)
- 9 * mg_value(score) / 8 - 9 * mg_value(score) / 8
@ -449,7 +449,7 @@ namespace {
// Analyse the safe enemy's checks which are possible on next move // Analyse the safe enemy's checks which are possible on next move
safe = ~pos.pieces(Them); safe = ~pos.pieces(Them);
safe &= ~attackedBy[Us][ALL_PIECES] | (undefended & attackedBy2[Them]); safe &= ~attackedBy[Us][ALL_PIECES] | (kingOnlyDefended & attackedBy2[Them]);
b1 = pos.attacks_from< ROOK>(ksq); b1 = pos.attacks_from< ROOK>(ksq);
b2 = pos.attacks_from<BISHOP>(ksq); b2 = pos.attacks_from<BISHOP>(ksq);
@ -532,8 +532,7 @@ namespace {
const Square Up = (Us == WHITE ? NORTH : SOUTH); const Square Up = (Us == WHITE ? NORTH : SOUTH);
const Square Left = (Us == WHITE ? NORTH_WEST : SOUTH_EAST); const Square Left = (Us == WHITE ? NORTH_WEST : SOUTH_EAST);
const Square Right = (Us == WHITE ? NORTH_EAST : SOUTH_WEST); const Square Right = (Us == WHITE ? NORTH_EAST : SOUTH_WEST);
const Bitboard TRank2BB = (Us == WHITE ? Rank2BB : Rank7BB); const Bitboard TRank3BB = (Us == WHITE ? Rank3BB : Rank6BB);
const Bitboard TRank7BB = (Us == WHITE ? Rank7BB : Rank2BB);
Bitboard b, weak, defended, stronglyProtected, safeThreats; Bitboard b, weak, defended, stronglyProtected, safeThreats;
Score score = SCORE_ZERO; Score score = SCORE_ZERO;
@ -596,14 +595,15 @@ namespace {
score += ThreatByKing[more_than_one(b)]; score += ThreatByKing[more_than_one(b)];
} }
// Bonus if some pawns can safely push and attack an enemy piece // Find squares where our pawns can push on the next move
b = pos.pieces(Us, PAWN) & ~TRank7BB; b = shift<Up>(pos.pieces(Us, PAWN)) & ~pos.pieces();
b = shift<Up>(b | (shift<Up>(b & TRank2BB) & ~pos.pieces())); b |= shift<Up>(b & TRank3BB) & ~pos.pieces();
b &= ~pos.pieces() // Keep only the squares which are not completely unsafe
& ~attackedBy[Them][PAWN] b &= ~attackedBy[Them][PAWN]
& (attackedBy[Us][ALL_PIECES] | ~attackedBy[Them][ALL_PIECES]); & (attackedBy[Us][ALL_PIECES] | ~attackedBy[Them][ALL_PIECES]);
// Add a bonus for each new pawn threats from those squares
b = (shift<Left>(b) | shift<Right>(b)) b = (shift<Left>(b) | shift<Right>(b))
& pos.pieces(Them) & pos.pieces(Them)
& ~attackedBy[Us][PAWN]; & ~attackedBy[Us][PAWN];
@ -617,13 +617,14 @@ namespace {
} }
// evaluate_passer_pawns() evaluates the passed pawns and candidate passed // evaluate_passed_pawns() evaluates the passed pawns and candidate passed
// pawns of the given color. // pawns of the given color.
template<Tracing T> template<Color Us> template<Tracing T> template<Color Us>
Score Evaluation<T>::evaluate_passer_pawns() { Score Evaluation<T>::evaluate_passed_pawns() {
const Color Them = (Us == WHITE ? BLACK : WHITE); const Color Them = (Us == WHITE ? BLACK : WHITE);
const Square Up = (Us == WHITE ? NORTH : SOUTH);
Bitboard b, bb, squaresToQueen, defendedSquares, unsafeSquares; Bitboard b, bb, squaresToQueen, defendedSquares, unsafeSquares;
Score score = SCORE_ZERO; Score score = SCORE_ZERO;
@ -634,9 +635,9 @@ namespace {
{ {
Square s = pop_lsb(&b); Square s = pop_lsb(&b);
assert(!(pos.pieces(Them, PAWN) & forward_bb(Us, s + pawn_push(Us)))); assert(!(pos.pieces(Them, PAWN) & forward_file_bb(Us, s + Up)));
bb = forward_bb(Us, s) & (attackedBy[Them][ALL_PIECES] | pos.pieces(Them)); bb = forward_file_bb(Us, s) & (attackedBy[Them][ALL_PIECES] | pos.pieces(Them));
score -= HinderPassedPawn * popcount(bb); score -= HinderPassedPawn * popcount(bb);
int r = relative_rank(Us, s) - RANK_2; int r = relative_rank(Us, s) - RANK_2;
@ -646,7 +647,7 @@ namespace {
if (rr) if (rr)
{ {
Square blockSq = s + pawn_push(Us); Square blockSq = s + Up;
// Adjust bonus based on the king's proximity // Adjust bonus based on the king's proximity
ebonus += distance(pos.square<KING>(Them), blockSq) * 5 * rr ebonus += distance(pos.square<KING>(Them), blockSq) * 5 * rr
@ -654,7 +655,7 @@ namespace {
// If blockSq is not the queening square then consider also a second push // If blockSq is not the queening square then consider also a second push
if (relative_rank(Us, blockSq) != RANK_8) if (relative_rank(Us, blockSq) != RANK_8)
ebonus -= distance(pos.square<KING>(Us), blockSq + pawn_push(Us)) * rr; ebonus -= distance(pos.square<KING>(Us), blockSq + Up) * rr;
// If the pawn is free to advance, then increase the bonus // If the pawn is free to advance, then increase the bonus
if (pos.empty(blockSq)) if (pos.empty(blockSq))
@ -662,9 +663,9 @@ namespace {
// If there is a rook or queen attacking/defending the pawn from behind, // If there is a rook or queen attacking/defending the pawn from behind,
// consider all the squaresToQueen. Otherwise consider only the squares // consider all the squaresToQueen. Otherwise consider only the squares
// in the pawn's path attacked or occupied by the enemy. // in the pawn's path attacked or occupied by the enemy.
defendedSquares = unsafeSquares = squaresToQueen = forward_bb(Us, s); defendedSquares = unsafeSquares = squaresToQueen = forward_file_bb(Us, s);
bb = forward_bb(Them, s) & pos.pieces(ROOK, QUEEN) & pos.attacks_from<ROOK>(s); bb = forward_file_bb(Them, s) & pos.pieces(ROOK, QUEEN) & pos.attacks_from<ROOK>(s);
if (!(pos.pieces(Us) & bb)) if (!(pos.pieces(Us) & bb))
defendedSquares &= attackedBy[Us][ALL_PIECES]; defendedSquares &= attackedBy[Us][ALL_PIECES];
@ -692,7 +693,7 @@ namespace {
// Scale down bonus for candidate passers which need more than one // Scale down bonus for candidate passers which need more than one
// pawn push to become passed or have a pawn in front of them. // pawn push to become passed or have a pawn in front of them.
if (!pos.pawn_passed(Us, s + pawn_push(Us)) || (pos.pieces(PAWN) & forward_bb(Us, s))) if (!pos.pawn_passed(Us, s + Up) || (pos.pieces(PAWN) & forward_file_bb(Us, s)))
mbonus /= 2, ebonus /= 2; mbonus /= 2, ebonus /= 2;
score += make_score(mbonus, ebonus) + PassedFile[file_of(s)]; score += make_score(mbonus, ebonus) + PassedFile[file_of(s)];
@ -852,8 +853,8 @@ namespace {
score += evaluate_threats<WHITE>() score += evaluate_threats<WHITE>()
- evaluate_threats<BLACK>(); - evaluate_threats<BLACK>();
score += evaluate_passer_pawns<WHITE>() score += evaluate_passed_pawns<WHITE>()
- evaluate_passer_pawns<BLACK>(); - evaluate_passed_pawns<BLACK>();
if (pos.non_pawn_material() >= SpaceThreshold) if (pos.non_pawn_material() >= SpaceThreshold)
score += evaluate_space<WHITE>() score += evaluate_space<WHITE>()

View file

@ -126,7 +126,7 @@ namespace {
e->pawnAttacksSpan[Us] |= pawn_attack_span(Us, s); e->pawnAttacksSpan[Us] |= pawn_attack_span(Us, s);
// Flag the pawn // Flag the pawn
opposed = theirPawns & forward_bb(Us, s); opposed = theirPawns & forward_file_bb(Us, s);
stoppers = theirPawns & passed_pawn_mask(Us, s); stoppers = theirPawns & passed_pawn_mask(Us, s);
lever = theirPawns & PawnAttacks[Us][s]; lever = theirPawns & PawnAttacks[Us][s];
leverPush = theirPawns & PawnAttacks[Us][s + Up]; leverPush = theirPawns & PawnAttacks[Us][s + Up];
@ -158,7 +158,7 @@ namespace {
// which could become passed after one or two pawn pushes when are // which could become passed after one or two pawn pushes when are
// not attacked more times than defended. // not attacked more times than defended.
if ( !(stoppers ^ lever ^ leverPush) if ( !(stoppers ^ lever ^ leverPush)
&& !(ourPawns & forward_bb(Us, s)) && !(ourPawns & forward_file_bb(Us, s))
&& popcount(supported) >= popcount(lever) && popcount(supported) >= popcount(lever)
&& popcount(phalanx) >= popcount(leverPush)) && popcount(phalanx) >= popcount(leverPush))
e->passedPawns[Us] |= s; e->passedPawns[Us] |= s;
@ -250,7 +250,7 @@ Value Entry::shelter_storm(const Position& pos, Square ksq) {
enum { BlockedByKing, Unopposed, BlockedByPawn, Unblocked }; enum { BlockedByKing, Unopposed, BlockedByPawn, Unblocked };
Bitboard b = pos.pieces(PAWN) & (in_front_bb(Us, rank_of(ksq)) | rank_bb(ksq)); Bitboard b = pos.pieces(PAWN) & (forward_ranks_bb(Us, 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);
Value safety = MaxSafetyBonus; Value safety = MaxSafetyBonus;
@ -261,7 +261,7 @@ Value Entry::shelter_storm(const Position& pos, Square ksq) {
b = ourPawns & file_bb(f); b = ourPawns & file_bb(f);
Rank 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);
Rank rkThem = b ? relative_rank(Us, frontmost_sq(Them, b)) : RANK_1; Rank rkThem = b ? relative_rank(Us, frontmost_sq(Them, b)) : RANK_1;
int d = std::min(f, FILE_H - f); int d = std::min(f, FILE_H - f);