]> git.sesse.net Git - stockfish/commitdiff
Introduce table SquaresInFrontMask[2][64]
authorMarco Costalba <mcostalba@gmail.com>
Sun, 18 Apr 2010 08:45:23 +0000 (09:45 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 18 Apr 2010 08:47:31 +0000 (09:47 +0100)
It will be used to lookup squares in front of
a given square. Same concept of PassedPawnMask[]
and OutpostMask[].

Also small tweaks in bitboard.h

No functional change.

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

index 384831adc8f7061f09797cbeff28d2e166eae574..cae7e0cae32e2fedf633af09730b631661517252 100644 (file)
@@ -226,6 +226,7 @@ Bitboard StepAttackBB[16][64];
 Bitboard RayBB[64][8];
 Bitboard BetweenBB[64][64];
 
+Bitboard SquaresInFrontMask[2][64];
 Bitboard PassedPawnMask[2][64];
 Bitboard OutpostMask[2][64];
 
@@ -427,6 +428,7 @@ namespace {
     for (Color c = WHITE; c <= BLACK; c++)
         for (Square s = SQ_A1; s <= SQ_H8; s++)
         {
+            SquaresInFrontMask[c][s] = in_front_bb(c, s) & file_bb(s);
             PassedPawnMask[c][s] = in_front_bb(c, s) & this_and_neighboring_files_bb(s);
             OutpostMask[c][s] = in_front_bb(c, s) & neighboring_files_bb(s);
         }
index fb798ec9f8442e6af1d4de074776c1eae00b0e95..f27340d9a0c5764a97c3c67ae7b443c53b4d307d 100644 (file)
@@ -74,6 +74,7 @@ extern Bitboard StepAttackBB[16][64];
 extern Bitboard RayBB[64][8];
 extern Bitboard BetweenBB[64][64];
 
+extern Bitboard SquaresInFrontMask[2][64];
 extern Bitboard PassedPawnMask[2][64];
 extern Bitboard OutpostMask[2][64];
 
@@ -156,7 +157,7 @@ inline Bitboard neighboring_files_bb(File f) {
 }
 
 inline Bitboard neighboring_files_bb(Square s) {
-  return neighboring_files_bb(square_file(s));
+  return NeighboringFilesBB[square_file(s)];
 }
 
 
@@ -169,7 +170,7 @@ inline Bitboard this_and_neighboring_files_bb(File f) {
 }
 
 inline Bitboard this_and_neighboring_files_bb(Square s) {
-  return this_and_neighboring_files_bb(square_file(s));
+  return ThisAndNeighboringFilesBB[square_file(s)];
 }
 
 
@@ -195,7 +196,7 @@ inline Bitboard in_front_bb(Color c, Rank r) {
 }
 
 inline Bitboard in_front_bb(Color c, Square s) {
-  return in_front_bb(c, square_rank(s));
+  return InFrontBB[c][square_rank(s)];
 }
 
 
@@ -208,7 +209,7 @@ inline Bitboard behind_bb(Color c, Rank r) {
 }
 
 inline Bitboard behind_bb(Color c, Square s) {
-  return in_front_bb(opposite_color(c), square_rank(s));
+  return InFrontBB[opposite_color(c)][square_rank(s)];
 }
 
 
@@ -274,12 +275,11 @@ inline Bitboard squares_between(Square s1, Square s2) {
 
 /// squares_in_front_of takes a color and a square as input, and returns a
 /// bitboard representing all squares along the line in front of the square,
-/// from the point of view of the given color.  For instance,
-/// squares_in_front_of(BLACK, SQ_E4) returns a bitboard with the squares
-/// e3, e2 and e1 set.
+/// from the point of view of the given color. Definition of the table is:
+/// SquaresInFrontOf[c][s] = in_front_bb(c, s) & file_bb(s)
 
 inline Bitboard squares_in_front_of(Color c, Square s) {
-  return in_front_bb(c, s) & file_bb(s);
+  return SquaresInFrontMask[c][s];
 }
 
 
@@ -287,13 +287,14 @@ inline Bitboard squares_in_front_of(Color c, Square s) {
 /// behind the square instead of in front of the square.
 
 inline Bitboard squares_behind(Color c, Square s) {
-  return in_front_bb(opposite_color(c), s) & file_bb(s);
+  return SquaresInFrontMask[opposite_color(c)][s];
 }
 
 
 /// passed_pawn_mask takes a color and a square as input, and returns a
 /// bitboard mask which can be used to test if a pawn of the given color on
-/// the given square is a passed pawn.
+/// the given square is a passed pawn. Definition of the table is:
+/// PassedPawnMask[c][s] = in_front_bb(c, s) & this_and_neighboring_files_bb(s)
 
 inline Bitboard passed_pawn_mask(Color c, Square s) {
   return PassedPawnMask[c][s];
@@ -302,21 +303,14 @@ inline Bitboard passed_pawn_mask(Color c, Square s) {
 
 /// outpost_mask takes a color and a square as input, and returns a bitboard
 /// mask which can be used to test whether a piece on the square can possibly
-/// be driven away by an enemy pawn.
+/// be driven away by an enemy pawn. Definition of the table is:
+/// OutpostMask[c][s] = in_front_bb(c, s) & neighboring_files_bb(s);
 
 inline Bitboard outpost_mask(Color c, Square s) {
   return OutpostMask[c][s];
 }
 
 
-/// isolated_pawn_mask takes a square as input, and returns a bitboard mask
-/// which can be used to test whether a pawn on the given square is isolated.
-
-inline Bitboard isolated_pawn_mask(Square s) {
-  return neighboring_files_bb(s);
-}
-
-
 /// first_1() finds the least significant nonzero bit in a nonzero bitboard.
 /// pop_1st_bit() finds and clears the least significant nonzero bit in a
 /// nonzero bitboard.