mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-20 00:56:39 +08:00
Unify History and Gains under a single Stats class
Handling of History and Gains is almost the same, with the exception of the update logic, so unify both classes under a single Stats struct. No functional change.
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "movegen.h"
|
||||
@@ -52,23 +51,6 @@ namespace {
|
||||
}
|
||||
|
||||
|
||||
/// History class method definitions
|
||||
|
||||
void History::clear() {
|
||||
memset(history, 0, sizeof(history));
|
||||
memset(gains, 0, sizeof(gains));
|
||||
}
|
||||
|
||||
void History::update(Piece p, Square to, Value bonus) {
|
||||
if (abs(history[p][to] + bonus) < History::Max)
|
||||
history[p][to] += bonus;
|
||||
}
|
||||
|
||||
void History::update_gain(Piece p, Square to, Value gain) {
|
||||
gains[p][to] = std::max(gain, gains[p][to] - 1);
|
||||
}
|
||||
|
||||
|
||||
/// Constructors of the MovePicker class. As arguments we pass information
|
||||
/// to help it to return the presumably good moves first, to decide which
|
||||
/// moves to return (in the quiescence search, for instance, we only want to
|
||||
@@ -76,7 +58,7 @@ void History::update_gain(Piece p, Square to, Value gain) {
|
||||
/// move ordering is at the current node.
|
||||
|
||||
MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
|
||||
Search::Stack* s, Value beta) : pos(p), H(h), depth(d) {
|
||||
Search::Stack* s, Value beta) : pos(p), Hist(h), depth(d) {
|
||||
|
||||
assert(d > DEPTH_ZERO);
|
||||
|
||||
@@ -109,7 +91,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
|
||||
}
|
||||
|
||||
MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
|
||||
Square sq) : pos(p), H(h), cur(moves), end(moves) {
|
||||
Square sq) : pos(p), Hist(h), cur(moves), end(moves) {
|
||||
|
||||
assert(d <= DEPTH_ZERO);
|
||||
|
||||
@@ -141,7 +123,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
|
||||
}
|
||||
|
||||
MovePicker::MovePicker(const Position& p, Move ttm, const History& h, PieceType pt)
|
||||
: pos(p), H(h), cur(moves), end(moves) {
|
||||
: pos(p), Hist(h), cur(moves), end(moves) {
|
||||
|
||||
assert(!pos.checkers());
|
||||
|
||||
@@ -197,7 +179,7 @@ void MovePicker::score_noncaptures() {
|
||||
for (MoveStack* it = moves; it != end; ++it)
|
||||
{
|
||||
m = it->move;
|
||||
it->score = H[pos.piece_moved(m)][to_sq(m)];
|
||||
it->score = Hist[pos.piece_moved(m)][to_sq(m)];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,7 +202,7 @@ void MovePicker::score_evasions() {
|
||||
it->score = PieceValue[MG][pos.piece_on(to_sq(m))]
|
||||
- type_of(pos.piece_moved(m)) + History::Max;
|
||||
else
|
||||
it->score = H[pos.piece_moved(m)][to_sq(m)];
|
||||
it->score = Hist[pos.piece_moved(m)][to_sq(m)];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user