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

Better document square flipping helpers

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2012-04-01 11:30:54 +01:00
parent 9bbd27a80f
commit 6e00aa6bae
3 changed files with 7 additions and 7 deletions

View file

@ -236,7 +236,7 @@ void Bitboards::init() {
{ {
Square to = s + Square(c == WHITE ? steps[pt][k] : -steps[pt][k]); Square to = s + Square(c == WHITE ? steps[pt][k] : -steps[pt][k]);
if (square_is_ok(to) && square_distance(s, to) < 3) if (is_ok(to) && square_distance(s, to) < 3)
StepAttacksBB[make_piece(c, pt)][s] |= to; StepAttacksBB[make_piece(c, pt)][s] |= to;
} }
@ -273,7 +273,7 @@ namespace {
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
for (Square s = sq + deltas[i]; for (Square s = sq + deltas[i];
square_is_ok(s) && square_distance(s, s - deltas[i]) == 1; is_ok(s) && square_distance(s, s - deltas[i]) == 1;
s += deltas[i]) s += deltas[i])
{ {
attack |= s; attack |= s;

View file

@ -409,7 +409,7 @@ Bitboard Position::attackers_to(Square s, Bitboard occ) const {
Bitboard Position::attacks_from(Piece p, Square s, Bitboard occ) { Bitboard Position::attacks_from(Piece p, Square s, Bitboard occ) {
assert(square_is_ok(s)); assert(is_ok(s));
switch (type_of(p)) switch (type_of(p))
{ {
@ -427,7 +427,7 @@ Bitboard Position::attacks_from(Piece p, Square s, Bitboard occ) {
bool Position::move_attacks_square(Move m, Square s) const { bool Position::move_attacks_square(Move m, Square s) const {
assert(is_ok(m)); assert(is_ok(m));
assert(square_is_ok(s)); assert(is_ok(s));
Bitboard occ, xray; Bitboard occ, xray;
Square from = from_sq(m); Square from = from_sq(m);

View file

@ -327,7 +327,7 @@ inline Color operator~(Color c) {
} }
inline Square operator~(Square s) { inline Square operator~(Square s) {
return Square(s ^ 56); return Square(s ^ 56); // Vertical flip SQ_A1 -> SQ_A8
} }
inline Value mate_in(int ply) { inline Value mate_in(int ply) {
@ -354,7 +354,7 @@ inline Square make_square(File f, Rank r) {
return Square((r << 3) | f); return Square((r << 3) | f);
} }
inline bool square_is_ok(Square s) { inline bool is_ok(Square s) {
return s >= SQ_A1 && s <= SQ_H8; return s >= SQ_A1 && s <= SQ_H8;
} }
@ -367,7 +367,7 @@ inline Rank rank_of(Square s) {
} }
inline Square mirror(Square s) { inline Square mirror(Square s) {
return Square(s ^ 7); return Square(s ^ 7); // Horizontal flip SQ_A1 -> SQ_H1
} }
inline Square relative_square(Color c, Square s) { inline Square relative_square(Color c, Square s) {