mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 16:53:09 +00:00
Change NO_PIECE value and shrink PieceValue[]
This requires changing color_of() definition. No functional change.
This commit is contained in:
parent
e304db9d1e
commit
e40b06a050
4 changed files with 24 additions and 25 deletions
|
@ -131,7 +131,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, const History& h, PieceType
|
|||
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))
|
||||
|
@ -165,11 +165,11 @@ void MovePicker::score_captures() {
|
|||
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)];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -200,7 +200,7 @@ void MovePicker::score_evasions() {
|
|||
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));
|
||||
|
|
|
@ -41,7 +41,7 @@ static const string PieceToChar(" PNBRQK pnbrqk");
|
|||
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 } };
|
||||
|
||||
|
@ -86,10 +86,10 @@ void init() {
|
|||
|
||||
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++)
|
||||
{
|
||||
|
@ -830,7 +830,7 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
|
|||
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;
|
||||
|
@ -938,7 +938,7 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
|
|||
- pieceSquareTable[make_piece(us, PAWN)][to];
|
||||
|
||||
// Update material
|
||||
st->npMaterial[us] += PieceValue[Mg][promotion];
|
||||
st->npMaterial[us] += PieceValue[MG][promotion];
|
||||
}
|
||||
|
||||
// Update pawn hash key
|
||||
|
@ -1243,7 +1243,7 @@ int Position::see_sign(Move m) const {
|
|||
// 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);
|
||||
|
@ -1290,7 +1290,7 @@ int Position::see(Move m) const {
|
|||
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
|
||||
|
@ -1298,14 +1298,14 @@ int Position::see(Move m) const {
|
|||
// 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
|
||||
|
@ -1463,7 +1463,7 @@ Value Position::compute_non_pawn_material(Color c) const {
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -802,7 +802,7 @@ split_point_start: // At split points actual search starts from here
|
|||
&& 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)
|
||||
|
@ -1184,7 +1184,7 @@ split_point_start: // At split points actual search starts from here
|
|||
&& !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)
|
||||
|
@ -1315,7 +1315,7 @@ split_point_start: // At split points actual search starts from here
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -1420,7 +1420,7 @@ split_point_start: // At split points actual search starts from here
|
|||
// 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;
|
||||
|
|
11
src/types.h
11
src/types.h
|
@ -148,7 +148,8 @@ enum CastlingSide {
|
|||
|
||||
enum Phase {
|
||||
PHASE_ENDGAME = 0,
|
||||
PHASE_MIDGAME = 128
|
||||
PHASE_MIDGAME = 128,
|
||||
MG = 0, EG = 1, PHASE_NB = 2
|
||||
};
|
||||
|
||||
enum ScaleFactor {
|
||||
|
@ -179,8 +180,6 @@ enum Value {
|
|||
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,
|
||||
|
@ -195,7 +194,7 @@ enum PieceType {
|
|||
};
|
||||
|
||||
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
|
||||
|
@ -347,7 +346,7 @@ namespace Zobrist {
|
|||
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 {
|
||||
|
@ -392,7 +391,7 @@ inline PieceType type_of(Piece p) {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue