]> git.sesse.net Git - stockfish/commitdiff
Move Pieces[] out of global visibility
authorMarco Costalba <mcostalba@gmail.com>
Sun, 7 May 2017 08:26:09 +0000 (10:26 +0200)
committerJoona Kiiski <joona@zoox.com>
Mon, 8 May 2017 03:20:02 +0000 (20:20 -0700)
It is an helper array used only in position.cpp

Also small code tidy up while there.

No functional change.

Closes #1106

src/position.cpp
src/search.h
src/types.h

index 69a756d9ce9b0b68ab0eecce7758a4ced1e05401..03d8bf8ce5f796da279297306f61104165afbc51 100644 (file)
@@ -52,6 +52,9 @@ namespace {
 
 const string PieceToChar(" PNBRQK  pnbrqk");
 
 
 const string PieceToChar(" PNBRQK  pnbrqk");
 
+const Piece Pieces[] = { W_PAWN, W_KNIGHT, W_BISHOP, W_ROOK, W_QUEEN, W_KING,
+                         B_PAWN, B_KNIGHT, B_BISHOP, B_ROOK, B_QUEEN, B_KING };
+
 // min_attacker() is a helper function used by see_ge() to locate the least
 // valuable attacker for the side to move, remove the attacker we just found
 // from the bitboards and scan for new X-ray attacks behind it.
 // min_attacker() is a helper function used by see_ge() to locate the least
 // valuable attacker for the side to move, remove the attacker we just found
 // from the bitboards and scan for new X-ray attacks behind it.
index 1218ef3be223289f10fbb744d3bab771d1b32fb8..94b59d2bfac712be92d3559cf44e02912d55fd12 100644 (file)
@@ -56,11 +56,12 @@ struct Stack {
 struct RootMove {
 
   explicit RootMove(Move m) : pv(1, m) {}
 struct RootMove {
 
   explicit RootMove(Move m) : pv(1, m) {}
-
-  bool operator<(const RootMove& m) const {
-    return m.score != score ? m.score < score : m.previousScore < previousScore; } // Descending sort
-  bool operator==(const Move& m) const { return pv[0] == m; }
   bool extract_ponder_from_tt(Position& pos);
   bool extract_ponder_from_tt(Position& pos);
+  bool operator==(const Move& m) const { return pv[0] == m; }
+  bool operator<(const RootMove& m) const { // Sort in descending order
+    return m.score != score ? m.score < score
+                            : m.previousScore < previousScore;
+  }
 
   Value score = -VALUE_INFINITE;
   Value previousScore = -VALUE_INFINITE;
 
   Value score = -VALUE_INFINITE;
   Value previousScore = -VALUE_INFINITE;
index 1514c8c162914b497a918e31a138c1b51a825c4b..417f4815755564b56d599a2ba25ad27392c64bea 100644 (file)
@@ -76,7 +76,7 @@
 #  include <immintrin.h> // Header for _pext_u64() intrinsic
 #  define pext(b, m) _pext_u64(b, m)
 #else
 #  include <immintrin.h> // Header for _pext_u64() intrinsic
 #  define pext(b, m) _pext_u64(b, m)
 #else
-#  define pext(b, m) (0)
+#  define pext(b, m) 0
 #endif
 
 #ifdef USE_POPCNT
 #endif
 
 #ifdef USE_POPCNT
@@ -205,8 +205,6 @@ enum Piece {
   PIECE_NB = 16
 };
 
   PIECE_NB = 16
 };
 
-const Piece Pieces[] = { W_PAWN, W_KNIGHT, W_BISHOP, W_ROOK, W_QUEEN, W_KING,
-                         B_PAWN, B_KNIGHT, B_BISHOP, B_ROOK, B_QUEEN, B_KING };
 extern Value PieceValue[PHASE_NB][PIECE_NB];
 
 enum Depth : int {
 extern Value PieceValue[PHASE_NB][PIECE_NB];
 
 enum Depth : int {
@@ -239,8 +237,8 @@ enum Square {
 
   NORTH =  8,
   EAST  =  1,
 
   NORTH =  8,
   EAST  =  1,
-  SOUTH = -8,
-  WEST  = -1,
+  SOUTH = -NORTH,
+  WEST  = -EAST,
 
   NORTH_EAST = NORTH + EAST,
   SOUTH_EAST = SOUTH + EAST,
 
   NORTH_EAST = NORTH + EAST,
   SOUTH_EAST = SOUTH + EAST,
@@ -331,6 +329,7 @@ inline Score operator/(Score s, int i) {
 
 /// Multiplication of a Score by an integer. We check for overflow in debug mode.
 inline Score operator*(Score s, int i) {
 
 /// Multiplication of a Score by an integer. We check for overflow in debug mode.
 inline Score operator*(Score s, int i) {
+
   Score result = Score(int(s) * i);
 
   assert(eg_value(result) == (i * eg_value(s)));
   Score result = Score(int(s) * i);
 
   assert(eg_value(result) == (i * eg_value(s)));