Ejemplo n.º 1
0
EngineConfiguration::EngineConfiguration(const QVariant& variant)
	: m_variants(QStringList() << "standard"),
	  m_whiteEvalPov(false),
	  m_pondering(false),
	  m_validateClaims(true),
	  m_restartMode(RestartAuto)
{
	const QVariantMap map = variant.toMap();

	setName(map["name"].toString());
	setCommand(map["command"].toString());
	setWorkingDirectory(map["workingDirectory"].toString());
	setStderrFile(map["stderrFile"].toString());
	setProtocol(map["protocol"].toString());

	if (map.contains("initStrings"))
		setInitStrings(map["initStrings"].toStringList());
	if (map.contains("whitepov"))
		setWhiteEvalPov(map["whitepov"].toBool());
	if (map.contains("ponder"))
		setPondering(map["ponder"].toBool());

	if (map.contains("restart"))
	{
		const QString val(map["restart"].toString());
		if (val == "auto")
			setRestartMode(RestartAuto);
		else if (val == "on")
			setRestartMode(RestartOn);
		else if (val == "off")
			setRestartMode(RestartOff);
	}

	if (map.contains("validateClaims"))
		setClaimsValidated(map["validateClaims"].toBool());

	if (map.contains("variants"))
		setSupportedVariants(map["variants"].toStringList());

	if (map.contains("options"))
	{
		const QVariantList optionsList = map["options"].toList();
		EngineOption* option = nullptr;

		foreach (const QVariant& optionVariant, optionsList)
		{
			if ((option = EngineOptionFactory::create(optionVariant.toMap())) != nullptr)
				addOption(option);
		}
	}
}
Ejemplo n.º 2
0
void ChessEngine::applyConfiguration(const EngineConfiguration& configuration)
{
	if (!configuration.name().isEmpty())
		setName(configuration.name());

	foreach (const QString& str, configuration.initStrings())
		write(str);

	foreach (EngineOption* option, configuration.options())
		setOption(option->name(), option->value());

	m_whiteEvalPov = configuration.whiteEvalPov();
	m_pondering = configuration.pondering();
	m_restartMode = configuration.restartMode();
	setClaimsValidated(configuration.areClaimsValidated());
}