New preference to save the search results limit in arbitration mode

This commit is contained in:
Olivier Teulière 2012-03-05 22:15:42 +01:00
parent 05a51101db
commit 9160e6bc99
4 changed files with 56 additions and 7 deletions

View file

@ -40,9 +40,7 @@ void Arbitration::search()
// Search for the current player
const Rack &rack = m_players[m_currPlayer]->getCurrentRack().getRack();
LOG_DEBUG("Performing search for rack " + lfw(rack.toString()));
// FIXME arbitration begin
int limit = Settings::Instance().getInt("training.search-limit");
// FIXME arbitration end
int limit = Settings::Instance().getInt("arbitration.search-limit");
m_results.setLimit(limit);
m_results.search(getDic(), getBoard(), rack, getHistory().beforeFirstRound());
LOG_DEBUG("Found " << m_results.size() << " results");

View file

@ -177,6 +177,12 @@ Settings::Settings()
// be rejected in any case.
freegame.add("reject-invalid", Setting::TypeBoolean) = true;
// ============== Arbitration mode options ==============
Setting &arbitration = m_conf->getRoot().add("arbitration", Setting::TypeGroup);
// Number of search results kept in a search
arbitration.add("search-limit", Setting::TypeInt) = 100;
// Try to read the values from the configuration file
try
{
@ -190,6 +196,7 @@ Settings::Settings()
copySetting<int>(tmpConf, *m_conf, "duplicate.solo-value");
copySetting<bool>(tmpConf, *m_conf, "duplicate.reject-invalid");
copySetting<bool>(tmpConf, *m_conf, "freegame.reject-invalid");
copySetting<int>(tmpConf, *m_conf, "arbitration.search-limit");
}
catch (...)
{
@ -272,6 +279,8 @@ int Settings::getInt(const string &iName) const
return 16;
else if (iName == "duplicate.solo-value")
return 10;
else if (iName == "arbitration.search-limit")
return 100;
return 0;
#endif
}

View file

@ -70,6 +70,11 @@ PrefsDialog::PrefsDialog(QWidget *iParent)
checkBoxArbitAutoMaster->setToolTip(_q("If checked, a Master move will be selected "
"by default when searching the results.\n"
"It is still possible to change the Master move afterwards."));
spinBoxTrainSearchLimit->setToolTip(_q("Maximum number of results returned by a search.\n"
"The returned results will always be the best ones.\n"
"Use 0 to disable the limit (warning: searches yielding many "
"results could be very slow in this case!)."));
spinBoxArbitSearchLimit->setToolTip(spinBoxTrainSearchLimit->toolTip());
// Auto-completion on the dictionary path
QCompleter *completer = new QCompleter(this);
@ -115,6 +120,7 @@ PrefsDialog::PrefsDialog(QWidget *iParent)
checkBoxArbitAutoMaster->setChecked(autoAssignMaster);
bool linkArbit7P1 = qs.value(kARBIT_LINK_7P1, false).toBool();
checkBoxArbitLink7P1->setChecked(linkArbit7P1);
spinBoxArbitSearchLimit->setValue(Settings::Instance().getInt("arbitration.search-limit"));
}
catch (GameException &e)
{
@ -214,6 +220,8 @@ void PrefsDialog::updateSettings()
shouldEmitUpdate = true;
qs.setValue(kARBIT_LINK_7P1, checkBoxArbitLink7P1->isChecked());
}
Settings::Instance().setInt("arbitration.search-limit",
spinBoxArbitSearchLimit->value());
}
catch (GameException &e)
{

View file

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>443</width>
<height>693</height>
<height>756</height>
</rect>
</property>
<property name="windowTitle">
@ -299,9 +299,6 @@
</item>
<item>
<widget class="QSpinBox" name="spinBoxTrainSearchLimit">
<property name="toolTip">
<string>_(&quot;Maximum number of results returned by a search. The returned results will always be the best ones. Use 0 to disable the limit (warning: searches yielding many results can be extremely slow in this case!).&quot;)</string>
</property>
<property name="maximum">
<number>100000</number>
</property>
@ -354,6 +351,40 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_9">
<property name="text">
<string>_(&quot;Search results limit:&quot;)</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBoxArbitSearchLimit">
<property name="maximum">
<number>100000</number>
</property>
<property name="value">
<number>100</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
@ -385,6 +416,9 @@
<tabstop>checkBoxFreeRefuseInvalid</tabstop>
<tabstop>checkBoxIntfLinkTraining7P1</tabstop>
<tabstop>spinBoxTrainSearchLimit</tabstop>
<tabstop>checkBoxArbitAutoMaster</tabstop>
<tabstop>checkBoxArbitLink7P1</tabstop>
<tabstop>spinBoxArbitSearchLimit</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>