MCPcopy Create free account
hub / github.com/cutechess/cutechess / parseEngine

Function parseEngine

projects/cli/src/main.cpp:85–254  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83}
84
85bool parseEngine(const QStringList& args, EngineData& data)
86{
87 for (const auto& arg : args)
88 {
89 QString name = arg.section('=', 0, 0);
90 QString val = arg.section('=', 1);
91 if (name.isEmpty())
92 continue;
93
94 if (name == "conf")
95 {
96 if (!readEngineConfig(val, data.config))
97 {
98 qWarning() << "Unknown engine configuration:" << val;
99 return false;
100 }
101 }
102 else if (name == "name")
103 data.config.setName(val);
104 else if (name == "cmd")
105 data.config.setCommand(val);
106 else if (name == "dir")
107 data.config.setWorkingDirectory(val);
108 else if (name == "arg")
109 data.config.addArgument(val);
110 else if (name == "proto")
111 {
112 if (EngineFactory::protocols().contains(val))
113 data.config.setProtocol(val);
114 else
115 {
116 qWarning()<< "Usupported chess protocol:" << val;
117 return false;
118 }
119 }
120 // Line that are sent to the engine at startup, ie. before
121 // starting the chess protocol.
122 else if (name == "initstr")
123 data.config.addInitString(val.replace("\\n", "\n"));
124 // Should the engine be restarted after each game?
125 else if (name == "restart")
126 {
127 EngineConfiguration::RestartMode mode;
128 if (val == "auto")
129 mode = EngineConfiguration::RestartAuto;
130 else if (val == "on")
131 mode = EngineConfiguration::RestartOn;
132 else if (val == "off")
133 mode = EngineConfiguration::RestartOff;
134 else
135 {
136 qWarning() << "Invalid restart mode:" << val;
137 return false;
138 }
139
140 data.config.setRestartMode(mode);
141 }
142 // Trust all result claims coming from the engine?

Callers 1

parseMatchFunction · 0.85

Calls 15

readEngineConfigFunction · 0.85
setCommandMethod · 0.80
addArgumentMethod · 0.80
setProtocolMethod · 0.80
addInitStringMethod · 0.80
setRestartModeMethod · 0.80
setTimeoutScaleMethod · 0.80
setInfinityMethod · 0.80
isInfiniteMethod · 0.80
setHourglassMethod · 0.80
isHourglassMethod · 0.80
setTimePerTcMethod · 0.80

Tested by

no test coverage detected