mirror of
https://github.com/opelly27/Stockfish.git
synced 2026-05-20 16:47:37 +00:00
Merge branch 'master' into merge
This commit is contained in:
+12
-6
@@ -191,7 +191,8 @@ namespace Learner
|
|||||||
PSVector& sfens,
|
PSVector& sfens,
|
||||||
int8_t lastTurnIsWin,
|
int8_t lastTurnIsWin,
|
||||||
std::atomic<uint64_t>& counter,
|
std::atomic<uint64_t>& counter,
|
||||||
uint64_t limit);
|
uint64_t limit,
|
||||||
|
Color result_color);
|
||||||
|
|
||||||
void report(uint64_t done, uint64_t new_done);
|
void report(uint64_t done, uint64_t new_done);
|
||||||
|
|
||||||
@@ -291,7 +292,7 @@ namespace Learner
|
|||||||
vector<int> move_hist_scores;
|
vector<int> move_hist_scores;
|
||||||
|
|
||||||
auto flush_psv = [&](int8_t result) {
|
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)
|
for (int ply = 0; ; ++ply)
|
||||||
@@ -717,7 +718,8 @@ namespace Learner
|
|||||||
PSVector& sfens,
|
PSVector& sfens,
|
||||||
int8_t result,
|
int8_t result,
|
||||||
std::atomic<uint64_t>& counter,
|
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)
|
if (!params.write_out_draw_game_in_training_data_generation && result == 0)
|
||||||
{
|
{
|
||||||
@@ -725,13 +727,17 @@ namespace Learner
|
|||||||
return false;
|
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.
|
// 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).
|
// The phases stored in sfens are assumed to be continuous (in order).
|
||||||
for (auto it = sfens.rbegin(); it != sfens.rend(); ++it)
|
for (auto it = sfens.rbegin(); it != sfens.rend(); ++it)
|
||||||
{
|
{
|
||||||
// If is_win == 0 (draw), multiply by -1 and it will remain 0 (draw)
|
// The side to move is packed as the lowest bit of the first byte
|
||||||
result = -result;
|
const Color side_to_move = side_to_move_from_sfen(*it);
|
||||||
it->game_result = result;
|
it->game_result = side_to_move == result_color ? result : -result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write sfens in move order to make potential compression easier
|
// Write sfens in move order to make potential compression easier
|
||||||
|
|||||||
+4
-4
@@ -685,10 +685,6 @@ namespace Learner
|
|||||||
int ply = 0;
|
int ply = 0;
|
||||||
pos.do_move((Move)ps.move, state[ply++]);
|
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)
|
// Evaluation value of shallow search (qsearch)
|
||||||
const auto [_, pv] = Search::qsearch(pos);
|
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.
|
// Since we have reached the end phase of PV, add the slope here.
|
||||||
pos_add_grad();
|
pos_add_grad();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user