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

Retire operator|(File f, Rank r)

Use make_square() instead. Less fancy but
more clear.

No functional change.
This commit is contained in:
Marco Costalba 2014-03-22 23:35:30 +01:00
parent 4eee603433
commit 5f12069cbf
6 changed files with 17 additions and 17 deletions

View file

@ -110,7 +110,7 @@ namespace {
wksq = Square((idx >> 0) & 0x3F);
bksq = Square((idx >> 6) & 0x3F);
us = Color ((idx >> 12) & 0x01);
psq = File ((idx >> 13) & 0x03) | Rank(RANK_7 - (idx >> 15));
psq = make_square(File((idx >> 13) & 0x03), Rank(RANK_7 - (idx >> 15)));
result = UNKNOWN;
// Check if two pieces are on the same square or if a king can be captured

View file

@ -240,7 +240,7 @@ Value Endgame<KRKP>::operator()(const Position& pos) const {
Square rsq = relative_square(strongSide, pos.list<ROOK>(strongSide)[0]);
Square psq = relative_square(strongSide, pos.list<PAWN>(weakSide)[0]);
Square queeningSq = file_of(psq) | RANK_1;
Square queeningSq = make_square(file_of(psq), RANK_1);
Value result;
// If the stronger side's king is in front of the pawn, it's a win
@ -371,7 +371,7 @@ ScaleFactor Endgame<KBPsK>::operator()(const Position& pos) const {
&& !(pawns & ~file_bb(pawnFile)))
{
Square bishopSq = pos.list<BISHOP>(strongSide)[0];
Square queeningSq = relative_square(strongSide, pawnFile | RANK_8);
Square queeningSq = relative_square(strongSide, make_square(pawnFile, RANK_8));
Square kingSq = pos.king_square(weakSide);
if ( opposite_colors(queeningSq, bishopSq)
@ -463,7 +463,7 @@ ScaleFactor Endgame<KRPKR>::operator()(const Position& pos) const {
File f = file_of(wpsq);
Rank r = rank_of(wpsq);
Square queeningSq = f | RANK_8;
Square queeningSq = make_square(f, RANK_8);
int tempo = (pos.side_to_move() == strongSide);
// If the pawn is not too far advanced and the defending king defends the
@ -721,12 +721,12 @@ ScaleFactor Endgame<KBPPKB>::operator()(const Position& pos) const {
if (relative_rank(strongSide, psq1) > relative_rank(strongSide, psq2))
{
blockSq1 = psq1 + pawn_push(strongSide);
blockSq2 = file_of(psq2) | rank_of(psq1);
blockSq2 = make_square(file_of(psq2), rank_of(psq1));
}
else
{
blockSq1 = psq2 + pawn_push(strongSide);
blockSq2 = file_of(psq1) | rank_of(psq2);
blockSq2 = make_square(file_of(psq1), rank_of(psq2));
}
switch (file_distance(psq1, psq2))

View file

@ -70,7 +70,7 @@ const string move_to_uci(Move m, bool chess960) {
return "0000";
if (type_of(m) == CASTLING && !chess960)
to = (to > from ? FILE_G : FILE_C) | rank_of(from);
to = make_square(to > from ? FILE_G : FILE_C, rank_of(from));
string move = to_string(from) + to_string(to);

View file

@ -257,7 +257,7 @@ Value Entry::shelter_storm(const Position& pos, Square ksq) {
b = theirPawns & file_bb(f);
rkThem = b ? relative_rank(Us, frontmost_sq(Them, b)) : RANK_1;
if ( (MiddleEdges & (f | rkThem))
if ( (MiddleEdges & make_square(f, rkThem))
&& file_of(ksq) == f
&& relative_rank(Us, ksq) == rkThem - 1)
safety += Value(200);

View file

@ -274,7 +274,7 @@ void Position::set(const string& fenStr, bool isChess960, Thread* th) {
for (rsq = relative_square(c, SQ_A1); type_of(piece_on(rsq)) != ROOK; ++rsq) {}
else if (token >= 'A' && token <= 'H')
rsq = File(token - 'A') | relative_rank(c, RANK_1);
rsq = make_square(File(token - 'A'), relative_rank(c, RANK_1));
else
continue;
@ -286,7 +286,7 @@ void Position::set(const string& fenStr, bool isChess960, Thread* th) {
if ( ((ss >> col) && (col >= 'a' && col <= 'h'))
&& ((ss >> row) && (row == '3' || row == '6')))
{
st->epSquare = File(col - 'a') | Rank(row - '1');
st->epSquare = make_square(File(col - 'a'), Rank(row - '1'));
if (!(attackers_to(st->epSquare) & pieces(sideToMove, PAWN)))
st->epSquare = SQ_NONE;
@ -392,14 +392,14 @@ const string Position::fen() const {
{
for (File file = FILE_A; file <= FILE_H; ++file)
{
for (emptyCnt = 0; file <= FILE_H && empty(file | rank); ++file)
for (emptyCnt = 0; file <= FILE_H && empty(make_square(file, rank)); ++file)
++emptyCnt;
if (emptyCnt)
ss << emptyCnt;
if (file <= FILE_H)
ss << PieceToChar[piece_on(file | rank)];
ss << PieceToChar[piece_on(make_square(file, rank))];
}
if (rank > RANK_1)
@ -664,7 +664,7 @@ bool Position::gives_check(Move m, const CheckInfo& ci) const {
// the captured pawn.
case ENPASSANT:
{
Square capsq = file_of(to) | rank_of(from);
Square capsq = make_square(file_of(to), rank_of(from));
Bitboard b = (pieces() ^ from ^ capsq) | to;
return (attacks_bb< ROOK>(ci.ksq, b) & pieces(sideToMove, QUEEN, ROOK))

View file

@ -337,10 +337,6 @@ inline Square operator~(Square s) {
return Square(s ^ SQ_A8); // Vertical flip SQ_A1 -> SQ_A8
}
inline Square operator|(File f, Rank r) {
return Square((r << 3) | f);
}
inline CastlingRight operator|(Color c, CastlingSide s) {
return CastlingRight(WHITE_OO << ((s == QUEEN_SIDE) + 2 * c));
}
@ -353,6 +349,10 @@ inline Value mated_in(int ply) {
return -VALUE_MATE + ply;
}
inline Square make_square(File f, Rank r) {
return Square((r << 3) | f);
}
inline Piece make_piece(Color c, PieceType pt) {
return Piece((c << 3) | pt);
}