Fixed crash bugs.

This commit is contained in:
Hisayori Noda
2019-06-20 00:25:40 +09:00
parent 24576d77ab
commit 90ef97dcbd
8 changed files with 108 additions and 42 deletions

View File

@@ -871,7 +871,7 @@ moves_loop: // When in check, search starts from here
ss->moveCount = ++moveCount;
if (rootNode && thisThread == Threads.main() && Time.elapsed() > 3000)
if (rootNode && thisThread == Threads.main() && Time.elapsed() > 3000 && !Limits.silent)
sync_cout << "info depth " << depth / ONE_PLY
<< " currmove " << UCI::move(move, pos.is_chess960())
<< " currmovenumber " << moveCount + thisThread->pvIdx << sync_endl;
@@ -1382,7 +1382,9 @@ moves_loop: // When in check, search starts from here
ss->continuationHistory = &thisThread->continuationHistory[pos.moved_piece(move)][to_sq(move)];
// Make and search the move
//std::cout << pos << std::endl;
pos.do_move(move, st, givesCheck);
//std::cout << pos << std::endl;
value = -qsearch<NT>(pos, ss+1, -beta, -alpha, depth - ONE_PLY);
pos.undo_move(move);
@@ -1740,7 +1742,7 @@ namespace Learner
// RootNode<64><65>ss->ply == 0<><30><EFBFBD><EFBFBD><EFBFBD>̏<EFBFBD><CC8F><EFBFBD><EFBFBD>B
// <20>[<5B><><EFBFBD>N<EFBFBD><4E><EFBFBD>A<EFBFBD><41><EFBFBD><EFBFBD><EFBFBD>̂ŁAss->ply == 0<>ƂȂ<C682><C882>̂ő<CC82><C591><EFBFBD><EFBFBD>v<EFBFBD>c<EFBFBD>B
memset(ss - 4, 0, 7 * sizeof(Stack));
std::memset(ss - 7, 0, 10 * sizeof(Stack));
// Search::Limits<74>Ɋւ<C98A><D682><EFBFBD>
// <20><><EFBFBD>̃<EFBFBD><CC83><EFBFBD><EFBFBD>o<EFBFBD>[<5B>ϐ<EFBFBD><CF90><EFBFBD>global<61>Ȃ̂ő<CC82><C591>̃X<CC83><58><EFBFBD>b<EFBFBD>h<EFBFBD>ɉe<C989><65><EFBFBD><EFBFBD><EFBFBD>y<EFBFBD>ڂ<EFBFBD><DA82>̂ŋC<C58B><43><EFBFBD>‚<EFBFBD><C282><EFBFBD>ƁB
@@ -1751,7 +1753,7 @@ namespace Learner
limits.infinite = true;
// PV<50><56><EFBFBD>\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǝז<C68E><D796>Ȃ̂ŏ<CC82><C58F><EFBFBD><EFBFBD>Ă<EFBFBD><C482><EFBFBD><EFBFBD>B
//limits.silent = true;
limits.silent = true;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>p<EFBFBD><70><EFBFBD><EFBFBD><EFBFBD>Ɗe<C68A>X<EFBFBD><58><EFBFBD>b<EFBFBD>h<EFBFBD><68>nodes<65><73><EFBFBD>ώZ<CF8E><5A><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̂Ɣ<CC82><C694>r<EFBFBD><72><EFBFBD><EFBFBD><EFBFBD>Ă<EFBFBD><C482>܂<EFBFBD><DC82>B<EFBFBD><EFBFBD>Ɏg<C98E>p<EFBFBD><70><EFBFBD>Ȃ<EFBFBD><C882>B
limits.nodes = 0;
@@ -1789,8 +1791,23 @@ namespace Learner
// history<72>ނ<EFBFBD><DE82>S<EFBFBD><53><EFBFBD>N<EFBFBD><4E><EFBFBD>A<EFBFBD><41><EFBFBD><EFBFBD><EFBFBD>B<EFBFBD><42><EFBFBD>̏<EFBFBD><CC8F><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͏<EFBFBD><CD8F><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԃ<EFBFBD><D482><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>A<EFBFBD>T<EFBFBD><54><EFBFBD>̐<EFBFBD><CC90>x<EFBFBD>͂ނ<CD82><DE82><EFBFBD><EB89BA><EFBFBD><EFBFBD><EFBFBD>̂őP<C591><50><EFBFBD>͂悭<CD82><EFBFBD><ED82A9><EFBFBD>Ȃ<EFBFBD><C882>B
// th->clear();
for (int i = 4; i > 0; i--)
(ss - i)->continuationHistory = &th->continuationHistory[SQUARE_ZERO][NO_PIECE];
int ct = int(Options["Contempt"]) * PawnValueEg / 100; // From centipawns
Color us = pos.side_to_move();
// In analysis mode, adjust contempt in accordance with user preference
if (Limits.infinite || Options["UCI_AnalyseMode"])
ct = Options["Analysis Contempt"] == "Off" ? 0
: Options["Analysis Contempt"] == "Both" ? ct
: Options["Analysis Contempt"] == "White" && us == BLACK ? -ct
: Options["Analysis Contempt"] == "Black" && us == WHITE ? -ct
: ct;
// Evaluation score is from the white point of view
th->contempt = (us == WHITE ? make_score(ct, ct / 2)
: -make_score(ct, ct / 2));
for (int i = 7; i > 0; i--)
(ss - i)->continuationHistory = &th->continuationHistory[NO_PIECE][0]; // Use as sentinel
// rootMoves<65>̐ݒ<CC90>
auto& rootMoves = th->rootMoves;
@@ -1831,7 +1848,7 @@ namespace Learner
// <20><><EFBFBD><EFBFBD><EFBFBD>e<EFBFBD><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̂ŁA<C581><41><EFBFBD>͈̔͂<CD88><CD82>w<EFBFBD><77><EFBFBD>ł<EFBFBD><C582><EFBFBD><EFBFBD><EFBFBD>ɂ<EFBFBD><C982><EFBFBD><EFBFBD>̂<EFBFBD><CC82><EFBFBD><EFBFBD>߂邱<DF82>Ƃɂ<C682><C982><EFBFBD><EFBFBD>B
ValueAndPV qsearch(Position& pos)
{
Stack stack[MAX_PLY + 7], * ss = stack + 4;
Stack stack[MAX_PLY + 10], * ss = stack + 7;
Move pv[MAX_PLY + 1];
std::vector<Move> pvs;
@@ -1881,7 +1898,7 @@ namespace Learner
if (depth == DEPTH_ZERO)
return qsearch(pos);
Stack stack[MAX_PLY + 7], * ss = stack + 4;
Stack stack[MAX_PLY + 10], * ss = stack + 7;
Move pv[MAX_PLY + 1];
init_for_search(pos, ss);
@@ -1892,6 +1909,7 @@ namespace Learner
auto th = pos.this_thread();
auto& rootDepth = th->rootDepth;
auto& pvIdx = th->pvIdx;
auto& pvLast = th->pvLast;
auto& rootMoves = th->rootMoves;
auto& completedDepth = th->completedDepth;
auto& selDepth = th->selDepth;
@@ -1919,9 +1937,20 @@ namespace Learner
for (RootMove& rm : rootMoves)
rm.previousScore = rm.score;
// MultiPV
size_t pvFirst = 0;
pvLast = 0;
// MultiPV loop. We perform a full root search for each PV line
for (pvIdx = 0; pvIdx < multiPV && !Threads.stop; ++pvIdx)
{
if (pvIdx == pvLast)
{
pvFirst = pvLast;
for (pvLast++; pvLast < rootMoves.size(); pvLast++)
if (rootMoves[pvLast].tbRank != rootMoves[pvFirst].tbRank)
break;
}
// <20><><EFBFBD><EFBFBD><EA82BC><EFBFBD><EFBFBD>depth<74><68>PV line<6E>ɑ΂<C991><CE82><EFBFBD>USI info<66>ŏo<C58F>͂<EFBFBD><CD82><EFBFBD>selDepth
selDepth = 0;