summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
9c7e2c8)
Be fancy :-)
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
stm = Color(idx & 1);
bksq = Square((idx >> 1) & 63);
wksq = Square((idx >> 7) & 63);
stm = Color(idx & 1);
bksq = Square((idx >> 1) & 63);
wksq = Square((idx >> 7) & 63);
- psq = make_square(File((idx >> 13) & 3), Rank((idx >> 15) + 1));
+ psq = File((idx >> 13) & 3) | Rank((idx >> 15) + 1);
}
Result KPKPosition::classify_leaf(int idx) {
}
Result KPKPosition::classify_leaf(int idx) {
std::cout << "+---+---+---+---+---+---+---+---+" << '\n';
for (File file = FILE_A; file <= FILE_H; file++)
std::cout << "+---+---+---+---+---+---+---+---+" << '\n';
for (File file = FILE_A; file <= FILE_H; file++)
- std::cout << "| " << (b & make_square(file, rank) ? "X " : " ");
+ std::cout << "| " << (b & (file | rank) ? "X " : " ");
- Square queeningSq = make_square(file_of(bpsq), RANK_1);
+ Square queeningSq = file_of(bpsq) | RANK_1;
Value result;
// If the stronger side's king is in front of the pawn, it's a win
Value result;
// If the stronger side's king is in front of the pawn, it's a win
&& !(pawns & ~file_bb(pawnFile)))
{
Square bishopSq = pos.piece_list(strongerSide, BISHOP)[0];
&& !(pawns & ~file_bb(pawnFile)))
{
Square bishopSq = pos.piece_list(strongerSide, BISHOP)[0];
- Square queeningSq = relative_square(strongerSide, make_square(pawnFile, RANK_8));
+ Square queeningSq = relative_square(strongerSide, pawnFile | RANK_8);
Square kingSq = pos.king_square(weakerSide);
if ( opposite_colors(queeningSq, bishopSq)
Square kingSq = pos.king_square(weakerSide);
if ( opposite_colors(queeningSq, bishopSq)
File f = file_of(wpsq);
Rank r = rank_of(wpsq);
File f = file_of(wpsq);
Rank r = rank_of(wpsq);
- Square queeningSq = make_square(f, RANK_8);
+ Square queeningSq = f | RANK_8;
int tempo = (pos.side_to_move() == strongerSide);
// If the pawn is not too far advanced and the defending king defends the
int tempo = (pos.side_to_move() == strongerSide);
// If the pawn is not too far advanced and the defending king defends the
if (relative_rank(strongerSide, psq1) > relative_rank(strongerSide, psq2))
{
blockSq1 = psq1 + pawn_push(strongerSide);
if (relative_rank(strongerSide, psq1) > relative_rank(strongerSide, psq2))
{
blockSq1 = psq1 + pawn_push(strongerSide);
- blockSq2 = make_square(file_of(psq2), rank_of(psq1));
+ blockSq2 = file_of(psq2) | rank_of(psq1);
}
else
{
blockSq1 = psq2 + pawn_push(strongerSide);
}
else
{
blockSq1 = psq2 + pawn_push(strongerSide);
- blockSq2 = make_square(file_of(psq1), rank_of(psq2));
+ blockSq2 = file_of(psq1) | rank_of(psq2);
}
switch (file_distance(psq1, psq2))
}
switch (file_distance(psq1, psq2))
while (b)
{
s = pop_1st_bit(&b);
while (b)
{
s = pop_1st_bit(&b);
- queeningSquare = relative_square(c, make_square(file_of(s), RANK_8));
+ queeningSquare = relative_square(c, file_of(s) | RANK_8);
queeningPath = forward_bb(c, s);
// Compute plies to queening and check direct advancement
queeningPath = forward_bb(c, s);
// Compute plies to queening and check direct advancement
s = pop_1st_bit(&b);
// Compute plies from queening
s = pop_1st_bit(&b);
// Compute plies from queening
- queeningSquare = relative_square(loserSide, make_square(file_of(s), RANK_8));
+ queeningSquare = relative_square(loserSide, file_of(s) | RANK_8);
movesToGo = rank_distance(s, queeningSquare) - int(relative_rank(loserSide, s) == RANK_2);
pliesToGo = 2 * movesToGo - int(loserSide == pos.side_to_move());
movesToGo = rank_distance(s, queeningSquare) - int(relative_rank(loserSide, s) == RANK_2);
pliesToGo = 2 * movesToGo - int(loserSide == pos.side_to_move());
minKingDist = kingptg = 256;
// Compute plies from queening
minKingDist = kingptg = 256;
// Compute plies from queening
- queeningSquare = relative_square(loserSide, make_square(file_of(s), RANK_8));
+ queeningSquare = relative_square(loserSide, file_of(s) | RANK_8);
movesToGo = rank_distance(s, queeningSquare) - int(relative_rank(loserSide, s) == RANK_2);
pliesToGo = 2 * movesToGo - int(loserSide == pos.side_to_move());
movesToGo = rank_distance(s, queeningSquare) - int(relative_rank(loserSide, s) == RANK_2);
pliesToGo = 2 * movesToGo - int(loserSide == pos.side_to_move());
return "0000";
if (is_castle(m) && !chess960)
return "0000";
if (is_castle(m) && !chess960)
- to = make_square(to > from ? FILE_G : FILE_C, rank_of(from));
+ to = (to > from ? FILE_G : FILE_C) | rank_of(from);
if (is_promotion(m))
promotion = char(tolower(piece_type_to_char(promotion_type(m))));
if (is_promotion(m))
promotion = char(tolower(piece_type_to_char(promotion_type(m))));
PieceType pt = type_of(pos.piece_on(from));
if (is_castle(m))
PieceType pt = type_of(pos.piece_on(from));
if (is_castle(m))
- san = to_sq(m) < from_sq(m) ? "O-O-O" : "O-O";
+ san = to > from ? "O-O" : "O-O-O";
for (rsq = relative_square(c, SQ_A1); type_of(piece_on(rsq)) != ROOK; rsq++) {}
else if (token >= 'A' && token <= 'H')
for (rsq = relative_square(c, SQ_A1); type_of(piece_on(rsq)) != ROOK; rsq++) {}
else if (token >= 'A' && token <= 'H')
- rsq = make_square(File(token - 'A'), relative_rank(c, RANK_1));
+ rsq = File(token - 'A') | relative_rank(c, RANK_1);
if ( ((fen >> col) && (col >= 'a' && col <= 'h'))
&& ((fen >> row) && (row == '3' || row == '6')))
{
if ( ((fen >> col) && (col >= 'a' && col <= 'h'))
&& ((fen >> row) && (row == '3' || row == '6')))
{
- st->epSquare = make_square(File(col - 'a'), Rank(row - '1'));
+ st->epSquare = File(col - 'a') | Rank(row - '1');
if (!(attackers_to(st->epSquare) & pieces(sideToMove, PAWN)))
st->epSquare = SQ_NONE;
if (!(attackers_to(st->epSquare) & pieces(sideToMove, PAWN)))
st->epSquare = SQ_NONE;
for (File file = FILE_A; file <= FILE_H; file++)
{
for (File file = FILE_A; file <= FILE_H; file++)
{
- sq = make_square(file, rank);
if (is_empty(sq))
emptyCnt++;
if (is_empty(sq))
emptyCnt++;
// the captured pawn.
if (is_enpassant(m))
{
// the captured pawn.
if (is_enpassant(m))
{
- Square capsq = make_square(file_of(to), rank_of(from));
+ Square capsq = file_of(to) | rank_of(from);
Bitboard b = (pieces() ^ from ^ capsq) | to;
return (attacks_bb< ROOK>(ksq, b) & pieces(us, QUEEN, ROOK))
Bitboard b = (pieces() ^ from ^ capsq) | to;
return (attacks_bb< ROOK>(ksq, b) & pieces(us, QUEEN, ROOK))
return Square(s ^ 56); // Vertical flip SQ_A1 -> SQ_A8
}
return Square(s ^ 56); // Vertical flip SQ_A1 -> SQ_A8
}
+inline Square operator|(File f, Rank r) {
+ return Square((r << 3) | f);
+}
+
inline Value mate_in(int ply) {
return VALUE_MATE - ply;
}
inline Value mate_in(int ply) {
return VALUE_MATE - ply;
}
-inline Square make_square(File f, Rank r) {
- return Square((r << 3) | f);
-}
-
inline bool is_ok(Square s) {
return s >= SQ_A1 && s <= SQ_H8;
}
inline bool is_ok(Square s) {
return s >= SQ_A1 && s <= SQ_H8;
}