From f2e78d9f841b53b8d512ad2687ff982cf841df58 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Sat, 22 Oct 2011 15:52:53 +0100 Subject: [PATCH] Retire PieceValueXXX[] getters They don't add any value given that the corresponding table has global visibility anyhow. No functional change. Signed-off-by: Marco Costalba --- src/movepick.cpp | 8 ++++---- src/position.cpp | 6 +++--- src/position.h | 2 +- src/search.cpp | 8 ++++---- src/types.h | 8 -------- 5 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/movepick.cpp b/src/movepick.cpp index 88b4fe9c..2b20f25f 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -138,7 +138,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, const History& h, PieceType assert (!pos.in_check()); // In ProbCut we consider only captures better than parent's move - captureThreshold = piece_value_midgame(Piece(parentCapture)); + captureThreshold = PieceValueMidgame[Piece(parentCapture)]; phasePtr = ProbCutTable; if ( ttm != MOVE_NONE @@ -251,11 +251,11 @@ void MovePicker::score_captures() { for (MoveStack* cur = moves; cur != lastMove; cur++) { m = cur->move; - cur->score = piece_value_midgame(pos.piece_on(move_to(m))) + cur->score = PieceValueMidgame[pos.piece_on(move_to(m))] - type_of(pos.piece_on(move_from(m))); if (is_promotion(m)) - cur->score += piece_value_midgame(Piece(promotion_piece_type(m))); + cur->score += PieceValueMidgame[Piece(promotion_piece_type(m))]; } } @@ -290,7 +290,7 @@ void MovePicker::score_evasions() { if ((seeScore = pos.see_sign(m)) < 0) cur->score = seeScore - History::MaxValue; // Be sure we are at the bottom else if (pos.is_capture(m)) - cur->score = piece_value_midgame(pos.piece_on(move_to(m))) + cur->score = PieceValueMidgame[pos.piece_on(move_to(m))] - type_of(pos.piece_on(move_from(m))) + History::MaxValue; else cur->score = H.value(pos.piece_on(move_from(m)), move_to(m)); diff --git a/src/position.cpp b/src/position.cpp index 0a04b99b..9d7679ab 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -1351,7 +1351,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 (piece_value_midgame(piece_on(to)) >= piece_value_midgame(piece_on(from))) + if (PieceValueMidgame[piece_on(to)] >= PieceValueMidgame[piece_on(from)]) return 1; return see(m); @@ -1558,7 +1558,7 @@ Key Position::compute_material_key() const { for (Color c = WHITE; c <= BLACK; c++) for (PieceType pt = PAWN; pt <= QUEEN; pt++) - for (int i = 0, cnt = piece_count(c, pt); i < cnt; i++) + for (int i = 0; i < piece_count(c, pt); i++) result ^= zobrist[c][pt][i]; return result; @@ -1682,7 +1682,7 @@ void Position::init() { for (Piece p = WP; p <= WK; p++) { - Score ps = make_score(piece_value_midgame(p), piece_value_endgame(p)); + Score ps = make_score(PieceValueMidgame[p], PieceValueEndgame[p]); for (Square s = SQ_A1; s <= SQ_H8; s++) { diff --git a/src/position.h b/src/position.h index fd2222b4..5d14f064 100644 --- a/src/position.h +++ b/src/position.h @@ -263,7 +263,7 @@ private: // Static variables static Score pieceSquareTable[16][64]; // [piece][square] - static Key zobrist[2][8][64]; // [color][pieceType][square] + static Key zobrist[2][8][64]; // [color][pieceType][square]/[piece count] static Key zobEp[64]; // [square] static Key zobCastle[16]; // [castleRight] static Key zobSideToMove; diff --git a/src/search.cpp b/src/search.cpp index 438a01be..da95877c 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -284,7 +284,7 @@ namespace { if ( captureOrPromotion && type_of(pos.piece_on(move_to(m))) != PAWN && ( pos.non_pawn_material(WHITE) + pos.non_pawn_material(BLACK) - - piece_value_midgame(pos.piece_on(move_to(m))) == VALUE_ZERO) + - PieceValueMidgame[pos.piece_on(move_to(m))] == VALUE_ZERO) && !is_special(m)) { result += PawnEndgameExtension[PvNode]; @@ -1399,7 +1399,7 @@ split_point_start: // At split points actual search starts from here && !pos.is_passed_pawn_push(move)) { futilityValue = futilityBase - + piece_value_endgame(pos.piece_on(move_to(move))) + + PieceValueEndgame[pos.piece_on(move_to(move))] + (is_enpassant(move) ? PawnValueEndgame : VALUE_ZERO); if (futilityValue < beta) @@ -1532,7 +1532,7 @@ split_point_start: // At split points actual search starts from here while (b) { victimSq = pop_1st_bit(&b); - futilityValue = futilityBase + piece_value_endgame(pos.piece_on(victimSq)); + futilityValue = futilityBase + PieceValueEndgame[pos.piece_on(victimSq)]; // Note that here we generate illegal "double move"! if ( futilityValue >= beta @@ -1656,7 +1656,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) - && ( piece_value_midgame(pos.piece_on(tfrom)) >= piece_value_midgame(pos.piece_on(tto)) + && ( PieceValueMidgame[pos.piece_on(tfrom)] >= PieceValueMidgame[pos.piece_on(tto)] || type_of(pos.piece_on(tfrom)) == KING) && pos.move_attacks_square(m, tto)) return true; diff --git a/src/types.h b/src/types.h index 8facaafa..9ac0787e 100644 --- a/src/types.h +++ b/src/types.h @@ -350,14 +350,6 @@ extern const Value PieceValueMidgame[17]; extern const Value PieceValueEndgame[17]; extern int SquareDistance[64][64]; -inline Value piece_value_midgame(Piece p) { - return PieceValueMidgame[p]; -} - -inline Value piece_value_endgame(Piece p) { - return PieceValueEndgame[p]; -} - inline Value value_mate_in(int ply) { return VALUE_MATE - ply; } -- 2.39.2