mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-24 19:16:49 +08:00
Merge branch 'master' into merge
This commit is contained in:
@@ -191,7 +191,8 @@ namespace Learner
|
||||
PSVector& sfens,
|
||||
int8_t lastTurnIsWin,
|
||||
std::atomic<uint64_t>& counter,
|
||||
uint64_t limit);
|
||||
uint64_t limit,
|
||||
Color result_color);
|
||||
|
||||
void report(uint64_t done, uint64_t new_done);
|
||||
|
||||
@@ -291,7 +292,7 @@ namespace Learner
|
||||
vector<int> move_hist_scores;
|
||||
|
||||
auto flush_psv = [&](int8_t result) {
|
||||
quit = commit_psv(th, packed_sfens, result, counter, limit);
|
||||
quit = commit_psv(th, packed_sfens, result, counter, limit, pos.side_to_move());
|
||||
};
|
||||
|
||||
for (int ply = 0; ; ++ply)
|
||||
@@ -717,7 +718,8 @@ namespace Learner
|
||||
PSVector& sfens,
|
||||
int8_t result,
|
||||
std::atomic<uint64_t>& counter,
|
||||
uint64_t limit)
|
||||
uint64_t limit,
|
||||
Color result_color)
|
||||
{
|
||||
if (!params.write_out_draw_game_in_training_data_generation && result == 0)
|
||||
{
|
||||
@@ -725,13 +727,17 @@ namespace Learner
|
||||
return false;
|
||||
}
|
||||
|
||||
auto side_to_move_from_sfen = [](auto& sfen){
|
||||
return (Color)(sfen.sfen.data[0] & 1);
|
||||
};
|
||||
|
||||
// From the final stage (one step before) to the first stage, give information on the outcome of the game for each stage.
|
||||
// The phases stored in sfens are assumed to be continuous (in order).
|
||||
for (auto it = sfens.rbegin(); it != sfens.rend(); ++it)
|
||||
{
|
||||
// If is_win == 0 (draw), multiply by -1 and it will remain 0 (draw)
|
||||
result = -result;
|
||||
it->game_result = result;
|
||||
// The side to move is packed as the lowest bit of the first byte
|
||||
const Color side_to_move = side_to_move_from_sfen(*it);
|
||||
it->game_result = side_to_move == result_color ? result : -result;
|
||||
}
|
||||
|
||||
// Write sfens in move order to make potential compression easier
|
||||
|
||||
@@ -685,10 +685,6 @@ namespace Learner
|
||||
int ply = 0;
|
||||
pos.do_move((Move)ps.move, state[ply++]);
|
||||
|
||||
// We want to position being trained on not to be terminal
|
||||
if (MoveList<LEGAL>(pos).size() == 0)
|
||||
goto RETRY_READ;
|
||||
|
||||
// Evaluation value of shallow search (qsearch)
|
||||
const auto [_, pv] = Search::qsearch(pos);
|
||||
|
||||
@@ -698,6 +694,10 @@ namespace Learner
|
||||
}
|
||||
}
|
||||
|
||||
// We want to position being trained on not to be terminal
|
||||
if (MoveList<LEGAL>(pos).size() == 0)
|
||||
goto RETRY_READ;
|
||||
|
||||
// Since we have reached the end phase of PV, add the slope here.
|
||||
pos_add_grad();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user