hist: 移除未完成的 历史启发 相关代码
This commit is contained in:
parent
b6a72ff9db
commit
a8d4fb74d9
|
@ -82,23 +82,6 @@
|
||||||
//#define TRANSPOSITION_TABLE_DEBUG
|
//#define TRANSPOSITION_TABLE_DEBUG
|
||||||
#endif
|
#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
|
//#define DISABLE_PREFETCH
|
||||||
|
|
||||||
// WIP, Debugging only
|
// WIP, Debugging only
|
||||||
|
|
|
@ -45,9 +45,7 @@ void partial_insertion_sort(ExtMove *begin, ExtMove *end, int limit)
|
||||||
MovePicker::MovePicker(Position &p)
|
MovePicker::MovePicker(Position &p)
|
||||||
: pos(p)
|
: pos(p)
|
||||||
{
|
{
|
||||||
#ifdef HOSTORY_HEURISTIC
|
|
||||||
clearHistoryScore();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// MovePicker::score() assigns a numerical value to each move in a list, used
|
/// MovePicker::score() assigns a numerical value to each move in a list, used
|
||||||
|
@ -181,58 +179,3 @@ Move MovePicker::next_move()
|
||||||
|
|
||||||
return *moves;
|
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
|
|
||||||
|
|
|
@ -151,17 +151,6 @@ public:
|
||||||
{
|
{
|
||||||
return moveCount;
|
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
|
#endif // #ifndef MOVEPICK_H_INCLUDED
|
||||||
|
|
|
@ -414,10 +414,6 @@ Value search(Position *pos, Sanmill::Stack<Position> &ss, Depth depth, Depth ori
|
||||||
);
|
);
|
||||||
#endif /* TRANSPOSITION_TABLE_ENABLE */
|
#endif /* TRANSPOSITION_TABLE_ENABLE */
|
||||||
|
|
||||||
#ifdef HOSTORY_HEURISTIC
|
|
||||||
movePicker->setHistoryScore(bestMove, depth);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
assert(bestValue > -VALUE_INFINITE && bestValue < VALUE_INFINITE);
|
assert(bestValue > -VALUE_INFINITE && bestValue < VALUE_INFINITE);
|
||||||
|
|
||||||
return bestValue;
|
return bestValue;
|
||||||
|
|
|
@ -67,9 +67,6 @@ Thread::~Thread()
|
||||||
assert(!searching);
|
assert(!searching);
|
||||||
|
|
||||||
exit = true;
|
exit = true;
|
||||||
#ifdef HOSTORY_HEURISTIC
|
|
||||||
clearHistoryScore();
|
|
||||||
#endif // HOSTORY_HEURISTIC
|
|
||||||
start_searching();
|
start_searching();
|
||||||
stdThread.join();
|
stdThread.join();
|
||||||
}
|
}
|
||||||
|
@ -85,8 +82,6 @@ void Thread::clear()
|
||||||
|
|
||||||
void Thread::start_searching()
|
void Thread::start_searching()
|
||||||
{
|
{
|
||||||
clearHistoryScore();
|
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lk(mutex);
|
std::lock_guard<std::mutex> lk(mutex);
|
||||||
searching = true;
|
searching = true;
|
||||||
cv.notify_one(); // Wake up the thread in idle_loop()
|
cv.notify_one(); // Wake up the thread in idle_loop()
|
||||||
|
@ -538,11 +533,7 @@ string Thread::nextMove()
|
||||||
root->children[i]->move,
|
root->children[i]->move,
|
||||||
UCI::move(root->children[i]->move).c_str();
|
UCI::move(root->children[i]->move).c_str();
|
||||||
root->children[i]->value,
|
root->children[i]->value,
|
||||||
#ifdef HOSTORY_HEURISTIC
|
|
||||||
root->children[i]->score,
|
|
||||||
#else
|
|
||||||
0,
|
0,
|
||||||
#endif
|
|
||||||
charSelect);
|
charSelect);
|
||||||
|
|
||||||
moveIndex++;
|
moveIndex++;
|
||||||
|
|
|
@ -87,13 +87,6 @@ public:
|
||||||
|
|
||||||
void analyze(Color c);
|
void analyze(Color c);
|
||||||
|
|
||||||
void clearHistoryScore()
|
|
||||||
{
|
|
||||||
#ifdef HOSTORY_HEURISTIC
|
|
||||||
movePicker->clearHistoryScore();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef TIME_STAT
|
#ifdef TIME_STAT
|
||||||
TimePoint sortTime{ 0 };
|
TimePoint sortTime{ 0 };
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue