]> git.sesse.net Git - stockfish/commitdiff
Move PieceValue[] and SlidingArray[] where they belong
authorMarco Costalba <mcostalba@gmail.com>
Mon, 8 Nov 2010 08:44:28 +0000 (09:44 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Mon, 8 Nov 2010 12:18:18 +0000 (13:18 +0100)
No functional change.

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

index 84d12af107563c2809403c62b5d1ce16b031997d..a9adf57366e7ae5b731718524fa942399d048db5 100644 (file)
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-
-////
-//// Includes
-////
-
 #include <string>
 
 #include "piece.h"
 
-using namespace std;
-
-// Tables indexed by Piece
-
-const Value PieceValueMidgame[17] = {
-  VALUE_ZERO,
-  PawnValueMidgame, KnightValueMidgame, BishopValueMidgame,
-  RookValueMidgame, QueenValueMidgame,
-  VALUE_ZERO, VALUE_ZERO, VALUE_ZERO,
-  PawnValueMidgame, KnightValueMidgame, BishopValueMidgame,
-  RookValueMidgame, QueenValueMidgame,
-  VALUE_ZERO, VALUE_ZERO, VALUE_ZERO
-};
+static const std::string PieceChars(" pnbrqk PNBRQK");
 
-const Value PieceValueEndgame[17] = {
-  VALUE_ZERO,
-  PawnValueEndgame, KnightValueEndgame, BishopValueEndgame,
-  RookValueEndgame, QueenValueEndgame,
-  VALUE_ZERO, VALUE_ZERO, VALUE_ZERO,
-  PawnValueEndgame, KnightValueEndgame, BishopValueEndgame,
-  RookValueEndgame, QueenValueEndgame,
-  VALUE_ZERO, VALUE_ZERO, VALUE_ZERO
-};
-
-const int SlidingArray[18] = {
-  0, 0, 0, 1, 2, 3, 0, 0, 0, 0, 0, 1, 2, 3, 0, 0, 0, 0
-};
-
-
-////
-//// Functions
-////
 
 /// Translating piece types to/from English piece letters
 
-static const string PieceChars(" pnbrqk PNBRQK");
-
 char piece_type_to_char(PieceType pt, bool upcase) {
 
-  return PieceChars[pt + int(upcase) * 7];
+  return PieceChars[pt + (upcase ? 7 : 0)];
 }
 
 PieceType piece_type_from_char(char c) {
 
   size_t idx = PieceChars.find(c);
 
-  return idx != string::npos ? PieceType(idx % 7) : PIECE_TYPE_NONE;
+  return idx != std::string::npos ? PieceType(idx % 7) : PIECE_TYPE_NONE;
 }
index f88eead856bf13a630cb0d393d9ec0149976990f..df81e5ff47e53c47161fe26ef0be0c77c46213c4 100644 (file)
@@ -69,10 +69,6 @@ const Value RookValueEndgame   = Value(0x4FE);
 const Value QueenValueMidgame  = Value(0x9D9);
 const Value QueenValueEndgame  = Value(0x9FE);
 
-extern const Value PieceValueMidgame[17];
-extern const Value PieceValueEndgame[17];
-extern const int SlidingArray[18];
-
 
 ////
 //// Inline functions
@@ -90,10 +86,6 @@ inline Piece piece_of_color_and_type(Color c, PieceType pt) {
   return Piece((int(c) << 3) | int(pt));
 }
 
-inline int piece_is_slider(Piece p) {
-  return SlidingArray[p];
-}
-
 inline SquareDelta pawn_push(Color c) {
     return (c == WHITE ? DELTA_N : DELTA_S);
 }
index b5503cb501fbbcac919ae542231942203ec8f2eb..6abef5b47bcb42c764901fdc0cb7a871d7e80039 100644 (file)
@@ -57,7 +57,26 @@ Key Position::zobExclusion;
 
 Score Position::PieceSquareTable[16][64];
 
-// Material values used by SEE, indexed by PieceType
+// Material values arrays, indexed by Piece
+const Value Position::PieceValueMidgame[17] = {
+  VALUE_ZERO,
+  PawnValueMidgame, KnightValueMidgame, BishopValueMidgame,
+  RookValueMidgame, QueenValueMidgame, VALUE_ZERO,
+  VALUE_ZERO, VALUE_ZERO,
+  PawnValueMidgame, KnightValueMidgame, BishopValueMidgame,
+  RookValueMidgame, QueenValueMidgame
+};
+
+const Value Position::PieceValueEndgame[17] = {
+  VALUE_ZERO,
+  PawnValueEndgame, KnightValueEndgame, BishopValueEndgame,
+  RookValueEndgame, QueenValueEndgame, VALUE_ZERO,
+  VALUE_ZERO, VALUE_ZERO,
+  PawnValueEndgame, KnightValueEndgame, BishopValueEndgame,
+  RookValueEndgame, QueenValueEndgame
+};
+
+// Material values array used by SEE, indexed by PieceType
 const Value Position::seeValues[] = {
     VALUE_ZERO,
     PawnValueMidgame, KnightValueMidgame, BishopValueMidgame,
index 200dfdf95562cd246561889a6626ab9d5fce3f24..220bb31dac4cc431df03ca8358a4551283c49d06 100644 (file)
@@ -337,6 +337,8 @@ private:
   static Score PieceSquareTable[16][64];
   static Key zobExclusion;
   static const Value seeValues[8];
+  static const Value PieceValueMidgame[17];
+  static const Value PieceValueEndgame[17];
 };
 
 
index 5a4b56ba45ae2383bed345969d93432db8442f98..1a2b45d7eb92053e5f0cd55208832775c475ed44 100644 (file)
@@ -59,6 +59,10 @@ namespace {
   // Used for debugging SMP code.
   const bool FakeSplit = false;
 
+  // Fast lookup table of sliding pieces indexed by Piece
+  const bool Slidings[18] = { 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1 };
+  inline bool piece_is_slider(Piece p) { return Slidings[p]; }
+
   // ThreadsManager class is used to handle all the threads related stuff in search,
   // init, starting, parking and, the most important, launching a slave thread at a
   // split point are what this class does. All the access to shared thread data is