void AnalysisWidget::showAnalysis(const Analysis& analysis) { int mpv = analysis.mpv() - 1; bool bestMove = analysis.bestMove(); if (bestMove) { if (m_analyses.count() && m_analyses.last().bestMove()) { m_analyses.removeLast(); } m_analyses.append(analysis); } else if(mpv < 0 || mpv > m_analyses.count() || mpv >= ui.vpcount->value()) { return; } else if(mpv == m_analyses.count()) { m_analyses.append(analysis); } else { m_analyses[mpv] = analysis; } updateAnalysis(); if (bestMove) { emit receivedBestMove(analysis); } }
void AnalysisWidget::setPosition(const Board& board) { if (ui.btPin->isChecked()) { m_NextBoard = board; return; } if(m_board != board) { m_board = board; m_NextBoard = board; m_analyses.clear(); m_tablebase->abortLookup(); m_tablebaseEvaluation.clear(); if(AppSettings->getValue("/General/onlineTablebases").toBool()) { if (!(m_board.isStalemate() || m_board.isCheckmate())) { if(objectName() == "Analysis") { m_tablebase->getBestMove(m_board.toFen()); } } } updateAnalysis(); if(m_engine && m_engine->isActive()) { m_engine->startAnalysis(m_board, ui.vpcount->value(), m_moveTime, m_bUciNewGame); m_bUciNewGame = false; } } }
void AnalysisWidget::showTablebaseMove(Move move, int score) { QString result; if(score == 0) { result = tr("Draw"); } else if((score < 0) == (m_board.toMove() == Black)) { result = tr("White wins in %n moves", "", qAbs(score)); } else { result = tr("Black wins in %n moves", "", qAbs(score)); } Move move1 = m_board.prepareMove(move.from(), move.to()); if(move.isPromotion()) { move1.setPromoted(pieceType(move.promotedPiece())); } m_tablebaseEvaluation = QString("%1 - %2").arg(m_board.moveToFullSan(move1)).arg(result); updateAnalysis(); }
// -------------------------------------------------------------------------- void voAnalysisParameterEditorWidgetPrivate::init() { Q_Q(voAnalysisParameterEditorWidget); q->setWindowTitle("Run analysis - Parameters"); QVBoxLayout * verticalLayout = new QVBoxLayout(); verticalLayout->setMargin(0); q->setLayout(verticalLayout); // Editor this->AnalysisParameterEditor = new QtTreePropertyBrowser(q); this->AnalysisParameterEditor->setPropertiesWithoutValueMarked(true); this->AnalysisParameterEditor->setRootIsDecorated(true); this->AnalysisParameterEditor->setHeaderVisible(false); verticalLayout->addWidget(this->AnalysisParameterEditor); // ButtonBox QDialogButtonBox * dialogButton = new QDialogButtonBox(QDialogButtonBox::Reset | QDialogButtonBox::Ok | QDialogButtonBox::Apply); dialogButton->setCenterButtons(true); verticalLayout->addWidget(dialogButton); this->ApplyButton = dialogButton->button(QDialogButtonBox::Apply); this->ResetButton = dialogButton->button(QDialogButtonBox::Reset); this->OkButton = dialogButton->button(QDialogButtonBox::Ok); this->ApplyButton->setText("Update"); this->OkButton->setText("Clone"); QObject::connect(this->ApplyButton, SIGNAL(clicked()), q, SLOT(updateAnalysis())); QObject::connect(this->ResetButton, SIGNAL(clicked()), q, SLOT(reset())); QObject::connect(this->OkButton, SIGNAL(clicked()), q, SLOT(cloneAnalysis())); this->setButtonsEnabled(false); }