From e069a29f99dfb6e1139f47f3bb291902752d1283 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Tue, 10 Jan 2023 11:14:25 +0100 Subject: Debug animations, LiveEngine and improve arrow/squares highlights --- src/game_tab/right_panel/LiveEngineDialog.cpp | 34 +++++++++++++++++---------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'src/game_tab/right_panel/LiveEngineDialog.cpp') diff --git a/src/game_tab/right_panel/LiveEngineDialog.cpp b/src/game_tab/right_panel/LiveEngineDialog.cpp index 0c2ecfc..2413d0b 100644 --- a/src/game_tab/right_panel/LiveEngineDialog.cpp +++ b/src/game_tab/right_panel/LiveEngineDialog.cpp @@ -101,23 +101,31 @@ void LiveEngineDialog::StartEngine() { } void LiveEngineDialog::OnTimerTick(wxTimerEvent &event) { - wxLogDebug("Tick!"); - lines_list->DeleteAllItems(); + lines_list->DeleteAllItems(); // Clear lines_list engine->SyncAfter(0); EngineEvaluation *eval=new EngineEvaluation(); - auto const &lines=engine->GetLines(); - eval->best_lines.resize(lines.size()); - for (auto const &line : lines) { - long index = lines_list->InsertItem(0, std::to_string(line.first)); + auto lines=engine->GetLines(); // First best lines + + // First retrieve lines ids from unordered map lines + std::vector ids; + for(auto const &line : lines){ + ids.push_back(line.first); + } + std::sort(ids.begin(),ids.end()); + + // Now fill eval and lines_list + for (int &id:ids) { + auto const &line=lines[id]; + long index = lines_list->InsertItem(id, std::to_string(id)); + // Update eval that will be deplayed on the board + if(line.pv.size()>0) + eval->best_lines.push_back(line.pv[0]); + // Refresh lines_list std::string line_moves; - for (std::string move : line.second.pv) { + for (std::string move : line.pv) line_moves += move + " "; - } - if(line.second.pv.size()>0){ - eval->best_lines.insert(eval->best_lines.begin()+line.first,line.second.pv[0]); - } - std::string cp_str = std::to_string(line.second.score_cp); - if (line.second.score_cp > 0) { + std::string cp_str = std::to_string(line.score_cp); + if (line.score_cp > 0) { cp_str = "+" + cp_str; } lines_list->SetItem(index, 1, cp_str); -- cgit v1.2.3