mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-04-07 02:26:29 +02:00
Improve live engine
This commit is contained in:
parent
08e6015303
commit
3cdb25e546
1 changed files with 24 additions and 4 deletions
|
@ -4,7 +4,8 @@ LiveEngineDialog::LiveEngineDialog(wxWindow *parent, std::string engine_name)
|
||||||
: LiveEngineDialogFB(parent), engine_name(engine_name), interval(1000),
|
: LiveEngineDialogFB(parent), engine_name(engine_name), interval(1000),
|
||||||
engine(NULL) {
|
engine(NULL) {
|
||||||
lines_list->InsertColumn(0, "#", wxLIST_FORMAT_LEFT, 50);
|
lines_list->InsertColumn(0, "#", wxLIST_FORMAT_LEFT, 50);
|
||||||
lines_list->InsertColumn(1, "Moves", wxLIST_FORMAT_LEFT, 300);
|
lines_list->InsertColumn(1, "CP", wxLIST_FORMAT_LEFT, 70);
|
||||||
|
lines_list->InsertColumn(2, "Line", wxLIST_FORMAT_LEFT, 300);
|
||||||
current_engine->SetLabel(engine_name);
|
current_engine->SetLabel(engine_name);
|
||||||
InitEngine();
|
InitEngine();
|
||||||
Bind(wxEVT_BUTTON, &LiveEngineDialog::TogglePauseEngine, this,
|
Bind(wxEVT_BUTTON, &LiveEngineDialog::TogglePauseEngine, this,
|
||||||
|
@ -18,6 +19,20 @@ void LiveEngineDialog::InitEngine() {
|
||||||
engine = new uciadapter::UCI(
|
engine = new uciadapter::UCI(
|
||||||
conf->Read("engines/" + engine_name + "/path").ToStdString());
|
conf->Read("engines/" + engine_name + "/path").ToStdString());
|
||||||
engine->ucinewgame();
|
engine->ucinewgame();
|
||||||
|
|
||||||
|
long index;
|
||||||
|
std::string optsPath = "engines/" + engine_name + "/options";
|
||||||
|
conf->SetPath(optsPath);
|
||||||
|
wxString opt_name;
|
||||||
|
if (conf->GetFirstGroup(opt_name, index)) {
|
||||||
|
do {
|
||||||
|
wxString optPath = opt_name + "/";
|
||||||
|
wxString default_value_wxString = conf->Read(optPath + "value");
|
||||||
|
std::string default_value = default_value_wxString.ToStdString();
|
||||||
|
engine->setoption(opt_name.ToStdString(),default_value);
|
||||||
|
} while (conf->GetNextGroup(opt_name, index));
|
||||||
|
}
|
||||||
|
|
||||||
CONFIG_CLOSE(conf);
|
CONFIG_CLOSE(conf);
|
||||||
}
|
}
|
||||||
timer.Start(interval);
|
timer.Start(interval);
|
||||||
|
@ -49,10 +64,15 @@ void LiveEngineDialog::OnTimerTick(wxTimerEvent &event) {
|
||||||
for (auto const &line : engine->GetLines()) {
|
for (auto const &line : engine->GetLines()) {
|
||||||
long index = lines_list->InsertItem(0, std::to_string(line.first));
|
long index = lines_list->InsertItem(0, std::to_string(line.first));
|
||||||
std::string line_moves;
|
std::string line_moves;
|
||||||
for(std::string move:line.second.pv){
|
for (std::string move : line.second.pv) {
|
||||||
line_moves+=move + " ";
|
line_moves += move + " ";
|
||||||
}
|
}
|
||||||
lines_list->SetItem(index, 1, line_moves);
|
std::string cp_str = std::to_string(line.second.score_cp);
|
||||||
|
if (line.second.score_cp > 0) {
|
||||||
|
cp_str = "+" + cp_str;
|
||||||
|
}
|
||||||
|
lines_list->SetItem(index, 1, cp_str);
|
||||||
|
lines_list->SetItem(index, 2, line_moves);
|
||||||
}
|
}
|
||||||
wxLogDebug("%s", engine->GetBuffer());
|
wxLogDebug("%s", engine->GetBuffer());
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue