mirror of
https://github.com/sockspls/badfish
synced 2025-04-29 16:23:09 +00:00
Move PieceValue[] and SlidingArray[] where they belong
No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
c28b9ef182
commit
d2d953713f
5 changed files with 29 additions and 49 deletions
|
@ -17,60 +17,23 @@
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
////
|
|
||||||
//// Includes
|
|
||||||
////
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "piece.h"
|
#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
|
/// Translating piece types to/from English piece letters
|
||||||
|
|
||||||
static const string PieceChars(" pnbrqk PNBRQK");
|
|
||||||
|
|
||||||
char piece_type_to_char(PieceType pt, bool upcase) {
|
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) {
|
PieceType piece_type_from_char(char c) {
|
||||||
|
|
||||||
size_t idx = PieceChars.find(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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,10 +69,6 @@ const Value RookValueEndgame = Value(0x4FE);
|
||||||
const Value QueenValueMidgame = Value(0x9D9);
|
const Value QueenValueMidgame = Value(0x9D9);
|
||||||
const Value QueenValueEndgame = Value(0x9FE);
|
const Value QueenValueEndgame = Value(0x9FE);
|
||||||
|
|
||||||
extern const Value PieceValueMidgame[17];
|
|
||||||
extern const Value PieceValueEndgame[17];
|
|
||||||
extern const int SlidingArray[18];
|
|
||||||
|
|
||||||
|
|
||||||
////
|
////
|
||||||
//// Inline functions
|
//// Inline functions
|
||||||
|
@ -90,10 +86,6 @@ inline Piece piece_of_color_and_type(Color c, PieceType pt) {
|
||||||
return Piece((int(c) << 3) | int(pt));
|
return Piece((int(c) << 3) | int(pt));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int piece_is_slider(Piece p) {
|
|
||||||
return SlidingArray[p];
|
|
||||||
}
|
|
||||||
|
|
||||||
inline SquareDelta pawn_push(Color c) {
|
inline SquareDelta pawn_push(Color c) {
|
||||||
return (c == WHITE ? DELTA_N : DELTA_S);
|
return (c == WHITE ? DELTA_N : DELTA_S);
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,26 @@ Key Position::zobExclusion;
|
||||||
|
|
||||||
Score Position::PieceSquareTable[16][64];
|
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[] = {
|
const Value Position::seeValues[] = {
|
||||||
VALUE_ZERO,
|
VALUE_ZERO,
|
||||||
PawnValueMidgame, KnightValueMidgame, BishopValueMidgame,
|
PawnValueMidgame, KnightValueMidgame, BishopValueMidgame,
|
||||||
|
|
|
@ -337,6 +337,8 @@ private:
|
||||||
static Score PieceSquareTable[16][64];
|
static Score PieceSquareTable[16][64];
|
||||||
static Key zobExclusion;
|
static Key zobExclusion;
|
||||||
static const Value seeValues[8];
|
static const Value seeValues[8];
|
||||||
|
static const Value PieceValueMidgame[17];
|
||||||
|
static const Value PieceValueEndgame[17];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,10 @@ namespace {
|
||||||
// Used for debugging SMP code.
|
// Used for debugging SMP code.
|
||||||
const bool FakeSplit = false;
|
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,
|
// 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
|
// 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
|
// split point are what this class does. All the access to shared thread data is
|
||||||
|
|
Loading…
Add table
Reference in a new issue