mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-26 12:06:22 +08:00
Fixed a bug that Learner::qsearch() recognizes stalemate as checkmated.
This commit is contained in:
@@ -502,15 +502,17 @@ void MultiThinkGenSfen::thread_worker(size_t thread_id)
|
||||
break;
|
||||
}
|
||||
|
||||
if (pos.is_draw(ply)) {
|
||||
// Do not write if draw.
|
||||
break;
|
||||
}
|
||||
|
||||
// 全駒されて詰んでいたりしないか?
|
||||
if (pos.is_mated())
|
||||
if (MoveList<LEGAL>(pos).size() == 0)
|
||||
{
|
||||
if (pos.checkers()) {
|
||||
// (この局面の一つ前の局面までは書き出す)
|
||||
// Write the packed fens if checkmate.
|
||||
// Do not write if stalemate.
|
||||
flush_psv(-1);
|
||||
}
|
||||
// (この局面の一つ前の局面までは書き出す)
|
||||
// Write the positions other than this position if checkmated.
|
||||
flush_psv(-1);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1965,7 +1967,8 @@ void LearnerThink::thread_worker(size_t thread_id)
|
||||
// 全駒されて詰んでいる可能性がある。
|
||||
// また宣言勝ちの局面はPVの指し手でleafに行けないので学習から除外しておく。
|
||||
// (そのような教師局面自体を書き出すべきではないのだが古い生成ルーチンで書き出しているかも知れないので)
|
||||
if (pos.is_mated())
|
||||
// Skip the position if there are no legal moves (=checkmated or stalemate).
|
||||
if (MoveList<LEGAL>(pos).size() == 0)
|
||||
goto RetryRead;
|
||||
|
||||
// 読み込めたので試しに表示してみる。
|
||||
|
||||
@@ -1483,12 +1483,3 @@ PieceNumber Position::piece_no_of(Square sq) const
|
||||
return n;
|
||||
}
|
||||
#endif // defined(EVAL_NNUE)
|
||||
|
||||
#if defined(EVAL_LEARN)
|
||||
// <20><><EFBFBD>ǖʂŎw<C58E><77><EFBFBD>肪<EFBFBD>Ȃ<EFBFBD><C882><EFBFBD><EFBFBD><EFBFBD><EFBFBD>e<EFBFBD>X<EFBFBD>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>B<EFBFBD>w<EFBFBD><77><EFBFBD>萶<EFBFBD><E890B6><EFBFBD><EFBFBD><EFBFBD>[<5B>`<60><><EFBFBD><EFBFBD><EFBFBD>p<EFBFBD><70><EFBFBD><EFBFBD><EFBFBD>̂ő<CC82><C591><EFBFBD><EFBFBD>Ȃ<EFBFBD><C882>B<EFBFBD>T<EFBFBD><54><EFBFBD><EFBFBD><EFBFBD>ɂ͎g<CD8E><67><EFBFBD>Ȃ<EFBFBD><C882><EFBFBD><EFBFBD>ƁB
|
||||
bool Position::is_mated() const
|
||||
{
|
||||
// <20>s<EFBFBD><73><EFBFBD>ŋl<C58B>߂<EFBFBD><DF82><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ł<EFBFBD><C582><EFBFBD><EFBFBD>p<EFBFBD>^<5E>[<5B><><EFBFBD>͂Ȃ<CD82><C882>̂<EFBFBD>LEGAL_ALL<4C>ł<EFBFBD><C582><EFBFBD><EFBFBD>K<EFBFBD>v<EFBFBD>͂Ȃ<CD82><C882>B
|
||||
return MoveList<LEGAL>(*this).size() == 0;
|
||||
}
|
||||
#endif // EVAL_LEARN
|
||||
|
||||
@@ -192,9 +192,6 @@ public:
|
||||
#endif // defined(EVAL_NNUE) || defined(EVAL_LEARN)
|
||||
|
||||
#if defined(EVAL_LEARN)
|
||||
// <20><><EFBFBD>ǖʂŎw<C58E><77><EFBFBD>肪<EFBFBD>Ȃ<EFBFBD><C882><EFBFBD><EFBFBD><EFBFBD><EFBFBD>e<EFBFBD>X<EFBFBD>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>B<EFBFBD>w<EFBFBD><77><EFBFBD>萶<EFBFBD><E890B6><EFBFBD><EFBFBD><EFBFBD>[<5B>`<60><><EFBFBD><EFBFBD><EFBFBD>p<EFBFBD><70><EFBFBD><EFBFBD><EFBFBD>̂ő<CC82><C591><EFBFBD><EFBFBD>Ȃ<EFBFBD><C882>B<EFBFBD>T<EFBFBD><54><EFBFBD><EFBFBD><EFBFBD>ɂ͎g<CD8E><67><EFBFBD>Ȃ<EFBFBD><C882><EFBFBD><EFBFBD>ƁB
|
||||
bool is_mated() const;
|
||||
|
||||
// -- sfen<65><6E><EFBFBD>w<EFBFBD><77><EFBFBD>p
|
||||
|
||||
// pack<63><6B><EFBFBD>ꂽsfen<65><EFBFBD><F093BE82>B<EFBFBD><42><EFBFBD><EFBFBD><EFBFBD>Ɏw<C98E>肵<EFBFBD><E882B5><EFBFBD>o<EFBFBD>b<EFBFBD>t<EFBFBD>@<40>ɕԂ<C995><D482>B
|
||||
|
||||
@@ -1854,21 +1854,26 @@ namespace Learner
|
||||
{
|
||||
Stack stack[MAX_PLY + 10], * ss = stack + 7;
|
||||
Move pv[MAX_PLY + 1];
|
||||
std::vector<Move> pvs;
|
||||
|
||||
init_for_search(pos, ss);
|
||||
ss->pv = pv; // <20>Ƃ肠<C682><E882A0><EFBFBD><EFBFBD><EFBFBD>_<EFBFBD>~<7E>[<5B>łǂ<C582><C782><EFBFBD><EFBFBD>o<EFBFBD>b<EFBFBD>t<EFBFBD>@<40><><EFBFBD>Ȃ<EFBFBD><C882>Ƃ<EFBFBD><C682><EFBFBD><EFBFBD>Ȃ<EFBFBD><C882>B
|
||||
|
||||
if (pos.is_draw(0)) {
|
||||
// Return draw value if draw.
|
||||
return { VALUE_DRAW, {} };
|
||||
}
|
||||
|
||||
// <20>l<EFBFBD>܂<EFBFBD><DC82><EFBFBD><EFBFBD>Ă<EFBFBD><C482><EFBFBD><EFBFBD>̂<EFBFBD>
|
||||
if (pos.is_mated())
|
||||
if (MoveList<LEGAL>(pos).size() == 0)
|
||||
{
|
||||
pvs.push_back(MOVE_NONE);
|
||||
return ValueAndPV(mated_in(/*ss->ply*/ 0 + 1), pvs);
|
||||
// Return the mated value if checkmated.
|
||||
return { mated_in(/*ss->ply*/ 0 + 1), {} };
|
||||
}
|
||||
|
||||
auto bestValue = ::qsearch<PV>(pos, ss, -VALUE_INFINITE, VALUE_INFINITE, DEPTH_ZERO);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>ꂽPV<50><56><EFBFBD>Ԃ<EFBFBD><D482>B
|
||||
std::vector<Move> pvs;
|
||||
for (Move* p = &ss->pv[0]; is_ok(*p); ++p)
|
||||
pvs.push_back(*p);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user