This requires changing color_of() definition.
No functional change.
phase = PROBCUT;
// In ProbCut we generate only captures better than parent's captured piece
- captureThreshold = PieceValue[Mg][pt];
+ captureThreshold = PieceValue[MG][pt];
ttMove = (ttm && pos.is_pseudo_legal(ttm) ? ttm : MOVE_NONE);
if (ttMove && (!pos.is_capture(ttMove) || pos.see(ttMove) <= captureThreshold))
for (MoveStack* it = moves; it != end; ++it)
{
m = it->move;
- it->score = PieceValue[Mg][pos.piece_on(to_sq(m))]
+ it->score = PieceValue[MG][pos.piece_on(to_sq(m))]
- type_of(pos.piece_moved(m));
if (type_of(m) == PROMOTION)
- it->score += PieceValue[Mg][promotion_type(m)];
+ it->score += PieceValue[MG][promotion_type(m)];
}
}
if ((seeScore = pos.see_sign(m)) < 0)
it->score = seeScore - History::MaxValue; // Be sure we are at the bottom
else if (pos.is_capture(m))
- it->score = PieceValue[Mg][pos.piece_on(to_sq(m))]
+ it->score = PieceValue[MG][pos.piece_on(to_sq(m))]
- type_of(pos.piece_moved(m)) + History::MaxValue;
else
it->score = H.value(pos.piece_moved(m), to_sq(m));
CACHE_LINE_ALIGNMENT
Score pieceSquareTable[PIECE_NB][SQUARE_NB];
-Value PieceValue[2][18] = { // [Mg / Eg][piece / pieceType]
+Value PieceValue[PHASE_NB][PIECE_NB] = {
{ VALUE_ZERO, PawnValueMg, KnightValueMg, BishopValueMg, RookValueMg, QueenValueMg },
{ VALUE_ZERO, PawnValueEg, KnightValueEg, BishopValueEg, RookValueEg, QueenValueEg } };
for (PieceType pt = PAWN; pt <= KING; pt++)
{
- PieceValue[Mg][make_piece(BLACK, pt)] = PieceValue[Mg][pt];
- PieceValue[Eg][make_piece(BLACK, pt)] = PieceValue[Eg][pt];
+ PieceValue[MG][make_piece(BLACK, pt)] = PieceValue[MG][pt];
+ PieceValue[EG][make_piece(BLACK, pt)] = PieceValue[EG][pt];
- Score v = make_score(PieceValue[Mg][pt], PieceValue[Eg][pt]);
+ Score v = make_score(PieceValue[MG][pt], PieceValue[EG][pt]);
for (Square s = SQ_A1; s <= SQ_H8; s++)
{
st->pawnKey ^= Zobrist::psq[them][PAWN][capsq];
}
else
- st->npMaterial[them] -= PieceValue[Mg][capture];
+ st->npMaterial[them] -= PieceValue[MG][capture];
// Remove the captured piece
byTypeBB[ALL_PIECES] ^= capsq;
- pieceSquareTable[make_piece(us, PAWN)][to];
// Update material
- st->npMaterial[us] += PieceValue[Mg][promotion];
+ st->npMaterial[us] += PieceValue[MG][promotion];
}
// Update pawn hash key
// Early return if SEE cannot be negative because captured piece value
// is not less then capturing one. Note that king moves always return
// here because king midgame value is set to 0.
- if (PieceValue[Mg][piece_on(to_sq(m))] >= PieceValue[Mg][piece_moved(m)])
+ if (PieceValue[MG][piece_on(to_sq(m))] >= PieceValue[MG][piece_moved(m)])
return 1;
return see(m);
stm = ~color_of(piece_on(from));
stmAttackers = attackers & pieces(stm);
if (!stmAttackers)
- return PieceValue[Mg][captured];
+ return PieceValue[MG][captured];
// The destination square is defended, which makes things rather more
// difficult to compute. We proceed by building up a "swap list" containing
// destination square, where the sides alternately capture, and always
// capture with the least valuable piece. After each capture, we look for
// new X-ray attacks from behind the capturing piece.
- swapList[0] = PieceValue[Mg][captured];
+ swapList[0] = PieceValue[MG][captured];
captured = type_of(piece_on(from));
do {
assert(slIndex < 32);
// Add the new entry to the swap list
- swapList[slIndex] = -swapList[slIndex - 1] + PieceValue[Mg][captured];
+ swapList[slIndex] = -swapList[slIndex - 1] + PieceValue[MG][captured];
slIndex++;
// Locate and remove from 'occupied' the next least valuable attacker
Value value = VALUE_ZERO;
for (PieceType pt = KNIGHT; pt <= QUEEN; pt++)
- value += piece_count(c, pt) * PieceValue[Mg][pt];
+ value += piece_count(c, pt) * PieceValue[MG][pt];
return value;
}
&& type_of(pos.piece_on(to_sq(move))) != PAWN
&& type_of(move) == NORMAL
&& ( pos.non_pawn_material(WHITE) + pos.non_pawn_material(BLACK)
- - PieceValue[Mg][pos.piece_on(to_sq(move))] == VALUE_ZERO));
+ - PieceValue[MG][pos.piece_on(to_sq(move))] == VALUE_ZERO));
// Step 12. Extend checks and, in PV nodes, also dangerous moves
if (PvNode && dangerous)
&& !pos.is_passed_pawn_push(move))
{
futilityValue = futilityBase
- + PieceValue[Eg][pos.piece_on(to_sq(move))]
+ + PieceValue[EG][pos.piece_on(to_sq(move))]
+ (type_of(move) == ENPASSANT ? PawnValueEg : VALUE_ZERO);
if (futilityValue < beta)
while (b)
{
// Note that here we generate illegal "double move"!
- if (futilityBase + PieceValue[Eg][pos.piece_on(pop_lsb(&b))] >= beta)
+ if (futilityBase + PieceValue[EG][pos.piece_on(pop_lsb(&b))] >= beta)
return true;
}
// Case 2: If the threatened piece has value less than or equal to the
// value of the threatening piece, don't prune moves which defend it.
if ( pos.is_capture(threat)
- && ( PieceValue[Mg][pos.piece_on(tfrom)] >= PieceValue[Mg][pos.piece_on(tto)]
+ && ( PieceValue[MG][pos.piece_on(tfrom)] >= PieceValue[MG][pos.piece_on(tto)]
|| type_of(pos.piece_on(tfrom)) == KING)
&& pos.move_attacks_square(m, tto))
return true;
enum Phase {
PHASE_ENDGAME = 0,
- PHASE_MIDGAME = 128
+ PHASE_MIDGAME = 128,
+ MG = 0, EG = 1, PHASE_NB = 2
};
enum ScaleFactor {
VALUE_ENSURE_INTEGER_SIZE_P = INT_MAX,
VALUE_ENSURE_INTEGER_SIZE_N = INT_MIN,
- Mg = 0, Eg = 1,
-
PawnValueMg = 198, PawnValueEg = 258,
KnightValueMg = 817, KnightValueEg = 846,
BishopValueMg = 836, BishopValueEg = 857,
};
enum Piece {
- NO_PIECE = 16, // color_of(NO_PIECE) == NO_COLOR
+ NO_PIECE = 0,
W_PAWN = 1, W_KNIGHT = 2, W_BISHOP = 3, W_ROOK = 4, W_QUEEN = 5, W_KING = 6,
B_PAWN = 9, B_KNIGHT = 10, B_BISHOP = 11, B_ROOK = 12, B_QUEEN = 13, B_KING = 14,
PIECE_NB = 16
CACHE_LINE_ALIGNMENT
extern Score pieceSquareTable[PIECE_NB][SQUARE_NB];
-extern Value PieceValue[2][18]; // [Mg / Eg][piece / pieceType]
+extern Value PieceValue[PHASE_NB][PIECE_NB];
extern int SquareDistance[SQUARE_NB][SQUARE_NB];
struct MoveStack {
}
inline Color color_of(Piece p) {
- return Color(p >> 3);
+ return p == NO_PIECE ? NO_COLOR : Color(p >> 3);
}
inline bool is_ok(Square s) {