aboutsummaryrefslogtreecommitdiff
path: root/src/game_tab/right_panel
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2023-01-10 11:14:25 +0100
committerLoic Guegan <manzerbredes@mailbox.org>2023-01-10 11:14:25 +0100
commite069a29f99dfb6e1139f47f3bb291902752d1283 (patch)
tree746ffcbfc5d17f076a34eed6a86fb086df979526 /src/game_tab/right_panel
parent179a173b3b063a6e9e9807912919b77abbbe5115 (diff)
Debug animations, LiveEngine and improve arrow/squares highlights
Diffstat (limited to 'src/game_tab/right_panel')
-rw-r--r--src/game_tab/right_panel/LiveEngineDialog.cpp34
1 files changed, 21 insertions, 13 deletions
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<int> 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);