version 1.4.44b
[polyglot.git] / main.c
1 \r
2 // main.c\r
3 \r
4 // includes\r
5 \r
6 #include <errno.h>\r
7 #include <stdio.h>\r
8 #include <stdlib.h>\r
9 #include <string.h>\r
10 \r
11 #include "attack.h"\r
12 #include "board.h"\r
13 #include "book.h"\r
14 #include "book_make.h"\r
15 #include "book_merge.h"\r
16 #include "engine.h"\r
17 #include "epd.h"\r
18 #include "fen.h"\r
19 #include "gui.h"\r
20 #include "hash.h"\r
21 #include "list.h"\r
22 #include "main.h"\r
23 #include "mainloop.h"\r
24 #include "move.h"\r
25 #include "move_gen.h"\r
26 #include "option.h"\r
27 #include "piece.h"\r
28 #include "search.h"\r
29 #include "square.h"\r
30 #include "uci.h"\r
31 #include "util.h"\r
32 #include "xboard2uci.h"\r
33 #include "uci2uci.h"\r
34 #include "ini.h"\r
35 \r
36 // constants\r
37 \r
38 \r
39 static const char * const Version = "1.4.44b";\r
40 static const char * const HelpMessage = "\\r
41 SYNTAX\n\\r
42 * polyglot [configfile] [-noini] [-ec engine] [-ed enginedirectory] [-en enginename] [-log] [-lf logfile] [-hash value] [-bk book] [-pg <name>=<value>]* [-uci <name>=<value>]*\n\\r
43 * polyglot make-book [-pgn inputfile] [-bin outputfile] [-max-ply ply] [-min-game games] [-min-score score] [-only-white] [-only-black] [-uniform]\n\\r
44 * polyglot merge-book -in1 inputfile1 -in2 inputfile2 [-out outputfile]\n\\r
45 * polyglot info-book [-bin inputfile] [-exact]\n\\r
46 * polyglot dump-book [-bin inputfile] -color color [-out outputfile]\n\\r
47 * polyglot [configfile] epd-test [engineoptions] [-epd inputfile] [-min-depth depth] [-max-depth depth] [-min-time time] [-max-time time] [-depth-delta delta]\n\\r
48 * polyglot perft [-fen fen] [-max-depth depth]\\r
49 ";\r
50 \r
51 static const int SearchDepth = 63;\r
52 static const double SearchTime = 3600.0;\r
53 static const int StringSize = 4096;\r
54 \r
55 // variables\r
56 \r
57 static bool Init;\r
58 \r
59 // prototypes\r
60 \r
61 static void init_book ();\r
62 static void stop_search  ();\r
63 \r
64 // functions\r
65 \r
66 // arg_shift_left()\r
67 \r
68 static void arg_shift_left(char **argv, int index){\r
69     int i;\r
70     for(i=index; argv[i]!=NULL; i++){\r
71         argv[i]=argv[i+1];\r
72     }\r
73 }\r
74 \r
75 // write_ini()\r
76 \r
77 static void write_ini(const char *filename,\r
78                       option_list_t *pg_options,\r
79                       option_list_t *uci_options){\r
80     option_t *opt;\r
81     char tmp[StringSize];\r
82     FILE *f;\r
83     f=fopen(filename,"w");\r
84     if(!f){\r
85         my_fatal("write_ini(): Cannot open %s for writing.\n",filename);\r
86     }\r
87     fprintf(f,"; You may edit this file to set options for the\n"\r
88               "; UCI engine whose PolyGlot name is %s.\n"\r
89               "; You may also safely delete this file\n"\r
90               "; to restore the default options.\n",\r
91             option_get_string(Option,"EngineName"));\r
92     fprintf(f,"[PolyGlot]\n");\r
93     option_start_iter(pg_options);\r
94     while((opt=option_next(pg_options))){\r
95         if(!my_string_equal(opt->value,opt->default_)&&\r
96            !IS_BUTTON(opt) &&\r
97            (opt->mode & XBOARD)){\r
98             snprintf(tmp,sizeof(tmp),"%s=%s\n",opt->name,opt->value);\r
99             tmp[sizeof(tmp)-1]='\0';\r
100             fprintf(f,"%s",tmp);\r
101         }\r
102     }\r
103     fprintf(f,"[Engine]\n");\r
104     option_start_iter(uci_options);\r
105     while((opt=option_next(uci_options))){\r
106         if(!my_string_equal(opt->value,opt->default_)&&\r
107            !IS_BUTTON(opt)){\r
108             snprintf(tmp,sizeof(tmp),"%s=%s\n",opt->name,opt->value);\r
109             tmp[sizeof(tmp)-1]='\0';\r
110             fprintf(f,"%s",tmp);\r
111         }\r
112     }\r
113     fclose(f);\r
114 }\r
115 \r
116 // write_ini_ex()\r
117 \r
118 static void write_ini_ex(const char *filename,\r
119                          ini_t *ini){\r
120     ini_entry_t *entry;\r
121     char tmp[StringSize];\r
122     FILE *f;\r
123     f=fopen(filename,"w");\r
124     if(!f){\r
125         my_fatal("write_ini_ex(): Cannot open %s for writing.\n",filename);\r
126     }\r
127     fprintf(f,"; You may edit this file to set options for the\n"\r
128               "; UCI engine whose PolyGlot name is %s.\n"\r
129               "; You may also safely delete this file\n"\r
130               "; to restore the default options.\n",\r
131             option_get_string(Option,"EngineName"));\r
132     fprintf(f,"[PolyGlot]\n");\r
133     ini_start_iter(ini);\r
134     while((entry=ini_next(ini))){\r
135       if(my_string_case_equal(entry->section,"polyglot")){\r
136         snprintf(tmp,sizeof(tmp),"%s=%s\n",\r
137                  entry->name,\r
138                  entry->value);\r
139         tmp[sizeof(tmp)-1]='\0';\r
140         fprintf(f,"%s",tmp);\r
141       }\r
142     }\r
143     fprintf(f,"[Engine]\n");\r
144     ini_start_iter(ini);\r
145     while((entry=ini_next(ini))){\r
146       if(my_string_case_equal(entry->section,"engine")){\r
147         snprintf(tmp,sizeof(tmp),"%s=%s\n",\r
148                  entry->name,\r
149                  entry->value);\r
150         tmp[sizeof(tmp)-1]='\0';\r
151         fprintf(f,"%s",tmp);\r
152       }\r
153     }\r
154     fclose(f);\r
155 }\r
156 \r
157 \r
158 // main()\r
159 \r
160 int main(int argc, char * argv[]) {\r
161     ini_t ini[1],ini_save[1];\r
162     ini_entry_t *entry;\r
163     char *arg;\r
164     int arg_index;\r
165     bool NoIni, Persist;\r
166  \r
167     if(!DEBUG){\r
168         printf("PolyGlot %s by Fabien Letouzey.\n",Version);\r
169     }else{\r
170         printf("PolyGlot %s by Fabien Letouzey (debug build).\n",Version);\r
171     }\r
172 \r
173     if(argc>=2 && ((my_string_case_equal(argv[1],"help")) || (my_string_case_equal(argv[1],"-help")) || (my_string_case_equal(argv[1],"--help")) ||  (my_string_case_equal(argv[1],"-h")) ||  my_string_case_equal(argv[1],"/?"))){\r
174         printf("%s\n",HelpMessage);\r
175         return EXIT_SUCCESS;\r
176     }\r
177 \r
178    // init\r
179 \r
180     Init = FALSE;\r
181 \r
182     util_init();\r
183     option_init_pg();\r
184     \r
185     square_init();\r
186     piece_init();\r
187     attack_init();\r
188     \r
189     hash_init();\r
190 \r
191     my_random_init();\r
192 \r
193     ini_init(ini);\r
194     ini_init(ini_save);\r
195 \r
196         // book utilities\r
197     \r
198     if (argc >= 2 && my_string_equal(argv[1],"make-book")) {\r
199         book_make(argc,argv);\r
200         return EXIT_SUCCESS;\r
201     }\r
202     \r
203     if (argc >= 2 && my_string_equal(argv[1],"merge-book")) {\r
204         book_merge(argc,argv);\r
205         return EXIT_SUCCESS;\r
206     }\r
207 \r
208     if (argc >= 2 && my_string_equal(argv[1],"dump-book")) {\r
209         book_dump(argc,argv);\r
210         return EXIT_SUCCESS;\r
211     }\r
212     \r
213     if (argc >= 2 && my_string_equal(argv[1],"info-book")) {\r
214         book_info(argc,argv);\r
215         return EXIT_SUCCESS;\r
216     }\r
217 \r
218         // perft\r
219     \r
220     if (argc >= 2 && my_string_equal(argv[1],"perft")) {\r
221         do_perft(argc,argv);\r
222         return EXIT_SUCCESS;\r
223     }\r
224 \r
225         // TODO: If logging is enabled on the command line turn it on NOW\r
226         // and do not allow it to be overridden later. \r
227     \r
228         // What is the config file? This is very hacky right now.\r
229 \r
230         // Do we want a config file at all?\r
231 \r
232     arg_index=0;\r
233     NoIni=FALSE;\r
234     while((arg=argv[arg_index++])){\r
235         if(my_string_equal(arg,"-noini")){\r
236             NoIni=TRUE;\r
237             break;\r
238         }\r
239     }\r
240     arg_shift_left(argv,arg_index-1);\r
241     if(NoIni){\r
242         option_set(Option,"OptionFile","<empty>");\r
243     }\r
244 \r
245         // Ok see if first argument looks like config file\r
246     \r
247     if(argv[1] && !my_string_equal(argv[1],"epd-test") && !(argv[1][0]=='-')){\r
248                 // first argument must be  config file\r
249         if(!NoIni){\r
250             option_set(Option,"OptionFile",argv[1]);\r
251         }else{\r
252                 // ignore\r
253         }\r
254         arg_shift_left(argv,1);\r
255     }else{\r
256             // Config file is the default.\r
257             // This has already been set above or in "option_init_pg()"\r
258     }\r
259     \r
260 \r
261         // if we use a config file: load it!\r
262     \r
263     if(!my_string_equal(option_get_string(Option,"OptionFile"),"<empty>")){\r
264         if(ini_parse(ini,option_get_string(Option,"OptionFile"))){\r
265             my_fatal("main(): Can't open file \"%s\": %s\n",\r
266                    option_get_string(Option,"OptionFile"),\r
267                    strerror(errno));\r
268         }\r
269     }\r
270         // remind the reader of what options are in effect\r
271 \r
272     my_log("POLYGLOG Options from ini file\n");\r
273     ini_disp(ini);\r
274 \r
275         // extract PG options\r
276     \r
277     ini_start_iter(ini);\r
278     while((entry=ini_next(ini))){\r
279         if(my_string_case_equal(entry->section,"polyglot")){\r
280             option_set(Option,entry->name,entry->value);\r
281             option_set_default(Option,entry->name,entry->value);\r
282         }\r
283     }\r
284 \r
285         // start logging if required\r
286     \r
287     if (option_get_bool(Option,"Log")) {\r
288         my_log_open(option_get_string(Option,"LogFile"));\r
289     }\r
290 \r
291         // log welcome stuff\r
292     \r
293     if(!DEBUG){\r
294         my_log("PolyGlot %s by Fabien Letouzey\n",Version);\r
295     }else{\r
296         my_log("PolyGlot %s by Fabien Letouzey (debug build)\n",Version);\r
297     }    \r
298     my_log("POLYGLOT *** START ***\n");\r
299     my_log("POLYGLOT INI file \"%s\"\n",option_get_string(Option,"OptionFile"));\r
300 \r
301         // open book (presumably this should go else where)\r
302     \r
303     init_book();\r
304 \r
305         // scavenge command line for options necessary to start the engine\r
306     \r
307     arg_index=1;\r
308     while((arg=argv[arg_index])){\r
309         if(my_string_equal(arg,"-ec") && argv[arg_index+1]){\r
310             option_set(Option,"EngineCommand",argv[arg_index+1]);\r
311             arg_shift_left(argv,arg_index);\r
312             arg_shift_left(argv,arg_index);\r
313             continue;\r
314         }\r
315         if(my_string_equal(arg,"-ed") && argv[arg_index+1]){\r
316             option_set(Option,"EngineDir",argv[arg_index+1]);\r
317             arg_shift_left(argv,arg_index);\r
318             arg_shift_left(argv,arg_index);\r
319             continue;\r
320         }\r
321         if(my_string_equal(arg,"-en") && argv[arg_index+1]){\r
322             option_set(Option,"EngineName",argv[arg_index+1]);\r
323             arg_shift_left(argv,arg_index);\r
324             arg_shift_left(argv,arg_index);\r
325             continue;\r
326         }\r
327         arg_index++;\r
328     }\r
329 \r
330         // start engine\r
331     \r
332     engine_open(Engine);\r
333     if(!engine_active(Engine)){\r
334         my_fatal("Could not start \"%s\"\n",option_get(Option,"EngineCommand"));\r
335     }\r
336 \r
337         // switch to UCI mode if necessary\r
338     \r
339     if (option_get_bool(Option,"UCI")) {\r
340         my_log("POLYGLOT *** Switching to UCI mode ***\n");\r
341     }\r
342 \r
343         // initialize uci parsing and send uci command. \r
344         // Parse options and wait for uciok\r
345     \r
346     uci_open(Uci,Engine);\r
347 \r
348         // get engine name from engine if not supplied in config file\r
349     \r
350     if (my_string_equal(option_get_string(Option,"EngineName"),"<empty>")) {\r
351         option_set(Option,"EngineName",Uci->name);\r
352     }\r
353 \r
354         // what is the name of the persist file?\r
355 \r
356     if(my_string_equal(option_get_string(Option,"PersistFile"),"<empty>")){\r
357         char tmp[StringSize];\r
358         snprintf(tmp,sizeof(tmp),"PG_%s.ini",\r
359                  option_get_string(Option,"EngineName"));\r
360         tmp[sizeof(tmp)-1]='\0';\r
361         option_set(Option,"PersistFile",tmp);\r
362     }\r
363 \r
364     // Load the persist file\r
365 \r
366     my_log("POLYGLOT PersistFile=%s\n",option_get_string(Option,"PersistFile"));   \r
367     if(ini_parse(ini_save,option_get_string(Option,"PersistFile"))){\r
368       my_log("POLYGLOT Unable to open PersistFile\n"); \r
369     }\r
370 \r
371     // Do we want to use the persist file?\r
372 \r
373     entry=ini_find(ini_save,"polyglot","Persist");\r
374     if(!entry){\r
375       Persist=option_get_bool(Option,"Persist");\r
376     }else{\r
377       Persist=(my_string_case_equal(entry->value,"false") || \r
378                my_string_equal(entry->value,"0"))?FALSE:TRUE;\r
379     }\r
380 \r
381     // if "Persist" now happens to be false, forget about the\r
382     // persist file    \r
383 \r
384     if(!Persist){\r
385       my_log("POLYGLOT Ignoring PersistFile");\r
386       ini_clear(ini_save);\r
387     }\r
388 \r
389     option_set(Option,"Persist",Persist?"true":"false");\r
390 \r
391     // parse the command line and merge remaining options\r
392 \r
393     arg_index=1;\r
394     while((arg=argv[arg_index])){\r
395         if(my_string_equal(arg,"-log")){\r
396             ini_insert_ex(ini_save,"PolyGlot","Log","true");\r
397             arg_shift_left(argv,arg_index);\r
398             continue;\r
399         }\r
400         if(my_string_equal(arg,"-lf") && argv[arg_index+1]){\r
401             ini_insert_ex(ini_save,"PolyGlot","LogFile",argv[arg_index+1]);\r
402             arg_shift_left(argv,arg_index);\r
403             arg_shift_left(argv,arg_index);\r
404             continue;\r
405         }\r
406         if(my_string_equal(arg,"-hash") && argv[arg_index+1]){\r
407             ini_insert_ex(ini_save,"Engine","Hash",argv[arg_index+1]);\r
408             arg_shift_left(argv,arg_index);\r
409             arg_shift_left(argv,arg_index);\r
410             continue;\r
411         }\r
412         if(my_string_equal(arg,"-bk") && argv[arg_index+1]){\r
413             ini_insert_ex(ini_save,"PolyGlot","Book","true");\r
414             ini_insert_ex(ini_save,"PolyGlot","BookFile",argv[arg_index+1]);\r
415             arg_shift_left(argv,arg_index);\r
416             arg_shift_left(argv,arg_index);\r
417             continue;\r
418         }\r
419         if((my_string_equal(arg,"-pg")||my_string_equal(arg,"-uci")) &&\r
420            argv[arg_index]){\r
421             int ret;\r
422             char section[StringSize];\r
423             char name[StringSize];\r
424             char value[StringSize];\r
425             ret=ini_line_parse(argv[arg_index++],section,name,value);\r
426             if(ret==NAME_VALUE){\r
427                 if(my_string_equal(arg,"-pg")){\r
428                     ini_insert_ex(ini_save,"PolyGlot",name,value);\r
429                 }else{\r
430                     ini_insert_ex(ini_save,"Engine",name,value);\r
431                 }\r
432             }\r
433             arg_shift_left(argv,arg_index);\r
434             arg_shift_left(argv,arg_index);\r
435             continue;\r
436         }\r
437         arg_index++;\r
438     }\r
439 \r
440         // remind the reader once again about options\r
441 \r
442     my_log("POLYGLOG Options from PersistFile and command line\n");\r
443     ini_disp(ini_save);\r
444 \r
445         // extract PG options; this time do not set the default\r
446         // polyglot_set_option() performs the necessary actions such\r
447         // as opening the log file/opening book etcetera.\r
448     \r
449     ini_start_iter(ini_save);\r
450     while((entry=ini_next(ini_save))){\r
451         if(my_string_case_equal(entry->section,"polyglot")){\r
452             polyglot_set_option(entry->name,entry->value);\r
453         }\r
454     }\r
455 \r
456         // done initializing\r
457     \r
458     Init = TRUE;\r
459     \r
460         // collect engine options from config file(s) and send to engine\r
461     \r
462     ini_start_iter(ini);\r
463     while((entry=ini_next(ini))){\r
464         if(my_string_case_equal(entry->section,"engine")){\r
465                 // also updates value in Uci->option\r
466             uci_send_option(Uci,entry->name,"%s",entry->value);\r
467                 // since this comes from the ini file, also update default\r
468             option_set_default(Uci->option,entry->name,entry->value);\r
469                 // this is inherited, it probably does not work correctly\r
470            if(my_string_case_equal(entry->name,"MultiPV") &&\r
471               atoi(entry->value)>1){\r
472                Uci->multipv_mode=TRUE;\r
473            }\r
474         }\r
475     }\r
476     ini_start_iter(ini_save);\r
477     while((entry=ini_next(ini_save))){\r
478         if(my_string_case_equal(entry->section,"engine")){\r
479                 // also updates value in Uci->option\r
480             uci_send_option(Uci,entry->name,"%s",entry->value);\r
481                 // this is inherited, it probably does not work correctly\r
482             if(my_string_case_equal(entry->name,"MultiPV") &&\r
483                atoi(entry->value)>1){\r
484                 Uci->multipv_mode=TRUE;\r
485             }\r
486         }\r
487     }\r
488    \r
489     \r
490         // EPD test\r
491     \r
492     if (argv[1] && my_string_equal(argv[1],"epd-test")){\r
493         argc=0;\r
494         while((arg=argv[argc++]));\r
495         epd_test(argc-1,argv);\r
496         return EXIT_SUCCESS;\r
497     }\r
498     \r
499         // Anything that hasn't been parsed yet is a syntax error\r
500 \r
501     if(argv[1]){\r
502         my_fatal("main(): Unknown option: %s\n",argv[1]);\r
503     }\r
504 \r
505 \r
506     gui_init(GUI);\r
507     mainloop();\r
508     return EXIT_SUCCESS; \r
509 }\r
510 \r
511 // polyglot_set_option()\r
512 \r
513 void polyglot_set_option(const char *name, const char *value){ // this must be cleaned up!\r
514     option_t *opt;\r
515     my_log("POLYGLOT Setting PolyGlot option %s=\"%s\"\n",name,value);\r
516     if(my_string_case_equal(name,"Defaults")){\r
517       option_start_iter(Uci->option);\r
518       while((opt=option_next(Uci->option))){\r
519         if(!IS_BUTTON(opt)){\r
520         // also sets opt->value\r
521           uci_send_option(Uci,opt->name,opt->default_);\r
522         }\r
523       }\r
524       option_start_iter(Option);\r
525       while((opt=option_next(Option))){\r
526         if(!IS_BUTTON(opt)){\r
527           polyglot_set_option(opt->name,opt->default_);\r
528         }\r
529       }\r
530       xboard2uci_send_options();\r
531     }\r
532     option_set(Option,name,value);\r
533     if(option_get_bool(Option,"Book")&&(my_string_case_equal(name,"BookFile")||my_string_case_equal(name,"Book"))){\r
534         my_log("POLYGLOT *** SETTING BOOK ***\n");\r
535         my_log("POLYGLOT BOOK \"%s\"\n",option_get_string(Option,"BookFile"));\r
536         book_close();\r
537         book_clear();\r
538         book_open(option_get_string(Option,"BookFile"));\r
539         if(!book_is_open()){\r
540             my_log("POLYGLOT Unable to open book \"%s\"\n",option_get_string(Option,"BookFile"));\r
541         }\r
542     }else if(option_get_bool(Option,"Log")&&(my_string_case_equal(name,"LogFile") ||my_string_case_equal(name,"Log"))){\r
543         my_log("POLYGLOT *** SWITCHING LOGFILE ***\n");\r
544         my_log("POLYGLOT LOGFILE \"%s\"\n",option_get_string(Option,"LogFile"));\r
545         my_log_close();\r
546         my_log_open(option_get_string(Option,"LogFile"));\r
547     }else if(option_get_bool(Option,"UseNice") &&(my_string_case_equal(name,"NiceValue")||my_string_case_equal(name,"UseNice"))){\r
548         my_log("POLYGLOT Adjust Engine Piority\n");\r
549         engine_set_nice_value(Engine,atoi(option_get_string(Option,"NiceValue")));\r
550     }else if(my_string_case_equal(name,"Book") && !option_get_bool(Option,"Book")){\r
551         book_close();\r
552         book_clear();\r
553     }else if(my_string_case_equal(name,"UseNice") && !option_get_bool(Option,"UseNice")){\r
554         my_log("POLYGLOT Adjust Engine Piority\n");\r
555         engine_set_nice_value(Engine,0);\r
556     }else if(my_string_case_equal(name,"Log") && !option_get_bool(Option,"Log")){\r
557         my_log("POLYGLOT QUIT LOGGING\n");\r
558         my_log_close();\r
559     }\r
560 }\r
561 \r
562 \r
563 // init_book()\r
564 \r
565 static void init_book(){\r
566     book_clear();\r
567     if (option_get_bool(Option,"Book")){\r
568         my_log("POLYGLOT *** SETTING BOOK ***\n");\r
569         my_log("POLYGLOT BOOK \"%s\"\n",option_get_string(Option,"BookFile"));\r
570         book_open(option_get_string(Option,"BookFile"));\r
571         if(!book_is_open()){\r
572             my_log("POLYGLOT Unable to open book \"%s\"\n",\r
573                    option_get_string(Option,"BookFile"));\r
574         }\r
575     }\r
576 }\r
577 \r
578 \r
579 // quit()\r
580 \r
581 void quit() {\r
582 \r
583     ini_t empty[1];\r
584 \r
585     ini_init(empty);\r
586 \r
587     my_log("POLYGLOT *** QUIT ***\n");\r
588     \r
589     if (Init) {\r
590         \r
591         stop_search();\r
592         engine_send(Engine,"quit");\r
593         my_log("POLYGLOT Closing engine\n");\r
594         engine_close(Engine);\r
595         \r
596     }\r
597     //    printf("def=%s val=%s\n",option_get_default(Option,"Persist"),option_get_string(Option,"Persist"));\r
598     if(option_get_bool(Option,"Persist")){\r
599         write_ini(option_get_string(Option,"PersistFile"),\r
600                   Option,Uci->option);\r
601     }else if(!my_string_case_equal(option_get_default(Option,"Persist"),\r
602                                   option_get_string(Option,"Persist"))){\r
603       // Hack\r
604       ini_insert_ex(empty,"PolyGlot","Persist","false");\r
605       write_ini_ex(option_get_string(Option,"PersistFile"),empty);\r
606     }else{\r
607       write_ini_ex(option_get_string(Option,"PersistFile"),empty);\r
608     }\r
609     my_log("POLYGLOT Calling exit\n");\r
610     exit(EXIT_SUCCESS);\r
611 }\r
612 \r
613 // stop_search()\r
614 \r
615 static void stop_search() {\r
616     \r
617     if (Init && Uci->searching) {\r
618         \r
619         ASSERT(Uci->searching);\r
620         ASSERT(Uci->pending_nb>=1);\r
621         \r
622         my_log("POLYGLOT STOP SEARCH\n");\r
623         \r
624         if (option_get_bool(Option,"SyncStop")) {\r
625             uci_send_stop_sync(Uci);\r
626         } else {\r
627             uci_send_stop(Uci);\r
628         }\r
629     }\r
630 }\r
631 \r
632 \r
633 // end of main.cpp\r
634 \r