hist: 移除未完成的 历史启发 相关代码

This commit is contained in:
Calcitem 2020-11-01 10:45:50 +08:00
parent b6a72ff9db
commit a8d4fb74d9
6 changed files with 1 additions and 106 deletions

View File

@ -82,23 +82,6 @@
//#define TRANSPOSITION_TABLE_DEBUG
#endif
//WIP
//#define HOSTORY_HEURISTIC
#ifdef HOSTORY_HEURISTIC
#define HOSTORY_HEURISTIC_ACTION_MOVE_ONLY
//#define HOSTORY_HEURISTIC_SCORE_HIGH_WHEN_DEEPER
#endif
#ifdef HOSTORY_HEURISTIC
//#define COMPARE_SCORE_ONLY
//#define COMPARE_RATING_PREFERRED
#define COMPARE_SCORE_PREFERRED
#else
//#define COMPARE_RATING_1ST_VALUE_2ND
//#define COMPARE_VALUE_1ST_RATING_2ND
#endif // HOSTORY_HEURISTIC
//#define DISABLE_PREFETCH
// WIP, Debugging only

View File

@ -45,9 +45,7 @@ void partial_insertion_sort(ExtMove *begin, ExtMove *end, int limit)
MovePicker::MovePicker(Position &p)
: pos(p)
{
#ifdef HOSTORY_HEURISTIC
clearHistoryScore();
#endif
}
/// MovePicker::score() assigns a numerical value to each move in a list, used
@ -181,58 +179,3 @@ Move MovePicker::next_move()
return *moves;
}
#ifdef HOSTORY_HEURISTIC
Score MovePicker::getHistoryScore(Move move)
{
Score ret = 0;
if (move < 0) {
#ifndef HOSTORY_HEURISTIC_ACTION_MOVE_ONLY
ret = placeHistory[-move];
#endif
} else if (move & 0x7f00) {
ret = moveHistory[move];
} else {
#ifndef HOSTORY_HEURISTIC_ACTION_MOVE_ONLY
ret = placeHistory[move];
#endif
}
return ret;
}
void MovePicker::setHistoryScore(Move move, Depth depth)
{
if (move == MOVE_NONE) {
return;
}
#ifdef HOSTORY_HEURISTIC_SCORE_HIGH_WHEN_DEEPER
Score score = 1 << (32 - depth);
#else
Score score = 1 << depth;
#endif
if (move < 0) {
#ifndef HOSTORY_HEURISTIC_ACTION_MOVE_ONLY
placeHistory[-move] += score;
#endif
} else if (move & 0x7f00) {
moveHistory[move] += score;
} else {
#ifndef HOSTORY_HEURISTIC_ACTION_MOVE_ONLY
moveHistory[move] += score;
#endif
}
}
void MovePicker::clearHistoryScore()
{
#ifndef HOSTORY_HEURISTIC_ACTION_MOVE_ONLY
memset(placeHistory, 0, sizeof(placeHistory));
memset(removeHistory, 0, sizeof(removeHistory));
#endif
memset(moveHistory, 0, sizeof(moveHistory));
}
#endif // HOSTORY_HEURISTIC

View File

@ -151,17 +151,6 @@ public:
{
return moveCount;
}
#ifdef HOSTORY_HEURISTIC
// TODO: Fix size
Score placeHistory[64];
Score removeHistory[64];
Score moveHistory[10240];
Score getHistoryScore(Move move);
void setHistoryScore(Move move, Depth depth);
void clearHistoryScore();
#endif // HOSTORY_HEURISTIC
};
#endif // #ifndef MOVEPICK_H_INCLUDED

View File

@ -414,10 +414,6 @@ Value search(Position *pos, Sanmill::Stack<Position> &ss, Depth depth, Depth ori
);
#endif /* TRANSPOSITION_TABLE_ENABLE */
#ifdef HOSTORY_HEURISTIC
movePicker->setHistoryScore(bestMove, depth);
#endif
assert(bestValue > -VALUE_INFINITE && bestValue < VALUE_INFINITE);
return bestValue;

View File

@ -67,9 +67,6 @@ Thread::~Thread()
assert(!searching);
exit = true;
#ifdef HOSTORY_HEURISTIC
clearHistoryScore();
#endif // HOSTORY_HEURISTIC
start_searching();
stdThread.join();
}
@ -85,8 +82,6 @@ void Thread::clear()
void Thread::start_searching()
{
clearHistoryScore();
std::lock_guard<std::mutex> lk(mutex);
searching = true;
cv.notify_one(); // Wake up the thread in idle_loop()
@ -538,11 +533,7 @@ string Thread::nextMove()
root->children[i]->move,
UCI::move(root->children[i]->move).c_str();
root->children[i]->value,
#ifdef HOSTORY_HEURISTIC
root->children[i]->score,
#else
0,
#endif
charSelect);
moveIndex++;

View File

@ -87,13 +87,6 @@ public:
void analyze(Color c);
void clearHistoryScore()
{
#ifdef HOSTORY_HEURISTIC
movePicker->clearHistoryScore();
#endif
}
#ifdef TIME_STAT
TimePoint sortTime{ 0 };
#endif