MCPcopy Create free account
hub / github.com/OpenNFS/OpenNFS / InitFromCommandLine

Method InitFromCommandLine

src/Config.cpp:19–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17
18
19void Config::InitFromCommandLine(int argc, char **argv) {
20 try {
21 options_description desc("Allowed options");
22 desc.add_options()
23 // Option name/short name, parameter to option, description
24 ("help,h", "Print OpenNFS command-line parameters")
25 ("vulkan", bool_switch(&vulkanRender), "Use the Vulkan renderer instead of GL default")
26 ("train", bool_switch(&trainingMode), "Launch ONFS in AI training mode")
27 ("popsize", value(&populationSize), "Number of AI agents to place in a GA generation (training mode)")
28 ("ngens", value(&nGenerations), "Number of generations to allow AI to develop for (training mode)")
29 ("nticks", value(&nTicks), "Number of ticks to allow AI agents to simulate in, per generation (training mode)")
30 ("car,c", value(&car), "Name of desired car")
31 ("track,t", value(&track), "Name of desired track")
32 ("resX,x", value<uint32_t>(&resX), "Horizontal screen resolution")
33 ("resY,y", value<uint32_t>(&resY), "Vertical screen resolution");
34
35 store(parse_command_line(argc, argv, desc), storedConfig);
36 notify(storedConfig);
37
38 if (storedConfig.count("help")) {
39 std::cout << desc
40 << "\n"; // Avoid LOG calls right now as a) Not initialised yet, b) Async nature makes printout of help vars look weird
41 std::terminate();
42 }
43
44 option_dependency(storedConfig, "train", "popsize");
45 option_dependency(storedConfig, "train", "ngens");
46 option_dependency(storedConfig, "train", "nticks");
47 }
48 catch (std::exception &e) {
49 std::cerr << e.what() << "\n";
50 std::terminate();
51 }
52}

Callers 1

mainFunction · 0.80

Calls 1

option_dependencyFunction · 0.85

Tested by

no test coverage detected