diff --git a/src/piece.cpp b/src/piece.cpp
index 84d12af1..a9adf573 100644
--- a/src/piece.cpp
+++ b/src/piece.cpp
@@ -17,60 +17,23 @@
along with this program. If not, see .
*/
-
-////
-//// Includes
-////
-
#include
#include "piece.h"
-using namespace std;
+static const std::string PieceChars(" pnbrqk PNBRQK");
-// 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
-};
-
-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;
}
diff --git a/src/piece.h b/src/piece.h
index f88eead8..df81e5ff 100644
--- a/src/piece.h
+++ b/src/piece.h
@@ -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);
}
diff --git a/src/position.cpp b/src/position.cpp
index b5503cb5..6abef5b4 100644
--- a/src/position.cpp
+++ b/src/position.cpp
@@ -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,
diff --git a/src/position.h b/src/position.h
index 200dfdf9..220bb31d 100644
--- a/src/position.h
+++ b/src/position.h
@@ -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];
};
diff --git a/src/search.cpp b/src/search.cpp
index 5a4b56ba..1a2b45d7 100644
--- a/src/search.cpp
+++ b/src/search.cpp
@@ -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