mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-22 18:17:02 +08:00
Added hack to avoid crash during machine learning.
This commit is contained in:
@@ -2056,13 +2056,17 @@ void LearnerThink::thread_worker(size_t thread_id)
|
|||||||
};
|
};
|
||||||
|
|
||||||
StateInfo state[MAX_PLY]; // qsearchのPVがそんなに長くなることはありえない。
|
StateInfo state[MAX_PLY]; // qsearchのPVがそんなに長くなることはありえない。
|
||||||
|
bool illegal_move = false;
|
||||||
for (auto m : pv)
|
for (auto m : pv)
|
||||||
{
|
{
|
||||||
// 非合法手はやってこないはずなのだが。
|
// 非合法手はやってこないはずなのだが。
|
||||||
|
// An illegal move sometimes comes here...
|
||||||
if (!pos.pseudo_legal(m) || !pos.legal(m))
|
if (!pos.pseudo_legal(m) || !pos.legal(m))
|
||||||
{
|
{
|
||||||
cout << pos << m << endl;
|
//cout << pos << m << endl;
|
||||||
assert(false);
|
//assert(false);
|
||||||
|
illegal_move = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 各PV上のnodeでも勾配を加算する場合の処理。
|
// 各PV上のnodeでも勾配を加算する場合の処理。
|
||||||
@@ -2076,6 +2080,11 @@ void LearnerThink::thread_worker(size_t thread_id)
|
|||||||
Eval::evaluate_with_no_return(pos);
|
Eval::evaluate_with_no_return(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (illegal_move) {
|
||||||
|
sync_cout << "An illical move was detected... Excluded the position from the learning data..." << sync_endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// PVの終端局面に達したので、ここで勾配を加算する。
|
// PVの終端局面に達したので、ここで勾配を加算する。
|
||||||
pos_add_grad();
|
pos_add_grad();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user