]> git.sesse.net Git - stockfish/commitdiff
Better document square flipping helpers
authorMarco Costalba <mcostalba@gmail.com>
Sun, 1 Apr 2012 10:30:54 +0000 (11:30 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 1 Apr 2012 10:30:54 +0000 (11:30 +0100)
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/bitboard.cpp
src/position.cpp
src/types.h

index 6a3c18204667b4c0b8c010592ea9fe26a2e333e6..41ce2955c147f27b2960130d0c2ec2ffa8c7d5f7 100644 (file)
@@ -236,7 +236,7 @@ void Bitboards::init() {
               {
                   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;
               }
 
@@ -273,7 +273,7 @@ namespace {
 
     for (int i = 0; i < 4; 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])
         {
             attack |= s;
index 879ac442ff43ddf5bd47b653128a893287dc7336..e3ee3d26ea59e20965036dc5788e741ad88324dd 100644 (file)
@@ -409,7 +409,7 @@ Bitboard Position::attackers_to(Square s, Bitboard occ) const {
 
 Bitboard Position::attacks_from(Piece p, Square s, Bitboard occ) {
 
-  assert(square_is_ok(s));
+  assert(is_ok(s));
 
   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 {
 
   assert(is_ok(m));
-  assert(square_is_ok(s));
+  assert(is_ok(s));
 
   Bitboard occ, xray;
   Square from = from_sq(m);
index b9964971ddb19fa4cfeb485c3abc6cd6900247b7..031cb0babda381b50f1643a9dfe2a945a3a12a02 100644 (file)
@@ -327,7 +327,7 @@ inline Color operator~(Color c) {
 }
 
 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) {
@@ -354,7 +354,7 @@ inline Square make_square(File f, Rank r) {
   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;
 }
 
@@ -367,7 +367,7 @@ inline Rank rank_of(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) {