46 const char* result = fgets(b,
sizeof(b), stdin);
48 if(result !=
nullptr && b[0] ==
'r' || b[0] ==
'R')
52 const int args = sscanf(b,
"%u\n", &n);
57 case Parity::ZeroMod4:
62 perror = (n & 1) != 0;
66 perror = (n & 1) != 1;
70 nerror = perror || n < lo;
73 printf(
"**** Error: Invalid input. Please try again.\n");
76 printf(
"**** Error: Number unsuitable. Please try again.\n");
78 }
while(ferror || nerror);
93 Parity::ZeroMod4: Parity::Even;
94 const UINT lo = (t.
m_eCycle == CycleType::Tourney)? 4: 6;
117 const char* result = fgets(b,
sizeof(b), stdin);
119 if(result !=
nullptr){
120 const int args = sscanf(b,
"%c\n", &c);
122 cerror = s.find(c) == s.end();
125 printf(
"**** Error: Invalid input. Please try again.\n");
128 printf(
"**** Error: Invalid character. Please try again.\n");
130 }
while(ferror || cerror);
132 if(
'A' <= c && c <=
'Z')
141 printf(
" w: random walk with Warnsdorff's heuristic\n");
142 printf(
" t: Takefuji-Lee neural network\n");
143 printf(
" d: divide-and-conquer\n");
144 printf(
" c: concentric braid\n");
145 printf(
" 4: 4-cover\n");
153 bool finished =
false;
156 printf(
"Enter generation algorithm [wtdc4], h for help, r to restart.\n");
159 std::set<char> s = {
'w',
't',
'd',
'c',
'h',
'4',
'r'};
164 t = GeneratorType::Unknown;
168 t = GeneratorType::Warnsdorff;
169 printf(
"Warnsdorff's algorithm selected.\n");
173 t = GeneratorType::TakefujiLee;
174 printf(
"Takefuji-Lee neural network algorithm selected.\n");
178 t = GeneratorType::DivideAndConquer;
179 printf(
"Divide-and-conquer algorithm selected.\n");
183 t = GeneratorType::ConcentricBraid;
184 printf(
"Concentric braid algorithm selected.\n");
188 t = GeneratorType::FourCover;
189 printf(
"Four-cover algorithm selected.\n");
197 case 'r':
return true;
207 printf(
" t: knight's tour\n");
208 printf(
" y: tourney\n");
209 printf(
" j: joined tourney\n");
217 bool finished =
false;
220 printf(
"Enter tourney type [tyj], h for help, r to restart.\n");
223 std::set<char> s = {
't',
'y',
'j',
'h',
'r'};
228 t = CycleType::Unknown;
233 printf(
"Knight's tour selected.\n");
237 t = CycleType::Tourney;
238 printf(
"Tourney selected.\n");
242 t = CycleType::TourFromTourney;
243 printf(
"Joined tourney selected.\n");
251 case 'r':
return true;
263 printf(
"Obfuscated [yn], r to restart?\n");
265 std::set<char> s = {
'y',
'n',
'r'};
267 obfuscate = c ==
'y';
269 const bool bRestart = c ==
'r';
273 printf(
"Obfuscating.\n");
275 printf(
"No obfuscation\n");
284 printf(
" g: generate and save a single tourney\n");
285 printf(
" m: measure statistics on many tourneys of the same size\n");
286 printf(
" t: time the generation of many tourneys for a size range\n");
294 bool finished =
false;
297 printf(
"Select task [gmt], h for help, q to quit.\n");
300 std::set<char> s = {
'g',
'm',
't',
'h',
'q'};
310 printf(
"Generating a single tourney.\n");
315 printf(
"Measuring single and double move statistics.\n");
320 printf(
"Timing the generation of tourneys.\n");
328 case 'q':
return true;
unsigned int UINT
Abbreviation for unsigned integer.
GeneratorType
Generator type.
GeneratorType m_eGenerator
Generator type.
CycleType m_eCycle
Cycle type.