88
99__author__ = 'fsmosca'
1010__script_name__ = 'Lakas'
11- __version__ = 'v0.40 .0'
11+ __version__ = 'v0.41 .0'
1212__credits__ = ['ChrisWhittington' , 'Claes1981' , 'joergoster' , 'Matthies' ,
1313 'musketeerchess' , 'teytaud' , 'thehlopster' ,
1414 'tryingsomestuff' ]
@@ -119,7 +119,9 @@ def __init__(self, optimizer, engine_file, input_param, init_param,
119119 common_param = None , deterministic_function = False ,
120120 optimizer_name = None , spsa_scale = 500000 , proc_list = [],
121121 cutechess_debug = False , cutechess_wait = 5000 ,
122- protocol = 'uci' , enhance = False ,
122+ protocol = 'uci' ,
123+ timemargin = 50 ,
124+ enhance = False ,
123125 enhance_hashmb = 64 ,
124126 enhance_threads = 1 ,
125127 enhance_limitvalue = 15 ,
@@ -134,6 +136,7 @@ def __init__(self, optimizer, engine_file, input_param, init_param,
134136 self .games_per_budget = games_per_budget
135137 self .best_loss = best_loss
136138 self .concurrency = concurrency
139+ self .timemargin = timemargin
137140
138141 self .depth = int (depth ) if depth is not None else depth
139142 self .base_time_sec = int (base_time_sec ) if base_time_sec is not None else base_time_sec
@@ -321,7 +324,8 @@ def run(self, **param):
321324 cutechess_debug = self .cutechess_debug ,
322325 cutechess_wait = self .cutechess_wait ,
323326 move_time = self .move_time , nodes = self .nodes ,
324- protocol = self .protocol )
327+ protocol = self .protocol ,
328+ timemargin = self .timemargin )
325329
326330 min_res = 1.0 - result
327331
@@ -385,7 +389,7 @@ def get_match_commands(engine_file, test_options, base_options,
385389 concurrency , base_time_sec , inc_time_sec , match_manager ,
386390 match_manager_path ,
387391 variant , cutechess_debug , cutechess_wait ,
388- move_time , nodes , protocol ):
392+ move_time , nodes , protocol , timemargin ):
389393 if match_manager == 'cutechess' :
390394 tour_manager = Path (match_manager_path )
391395 else :
@@ -407,9 +411,9 @@ def get_match_commands(engine_file, test_options, base_options,
407411
408412 # Set the move control.
409413 if move_time is not None :
410- command += f' -each st={ move_time } timemargin= { 50 } '
414+ command += f' -each st={ move_time } '
411415 elif nodes is not None :
412- command += f' -each tc=inf nodes={ nodes } timemargin= { 50 } '
416+ command += f' -each tc=inf nodes={ nodes } '
413417 else :
414418 if base_time_sec is not None and inc_time_sec is not None and depth is not None :
415419 command += f' -each tc=0/0:{ base_time_sec } +{ inc_time_sec } depth={ depth } '
@@ -424,8 +428,8 @@ def get_match_commands(engine_file, test_options, base_options,
424428 elif depth is not None :
425429 command += f' -each tc=inf depth={ depth } '
426430
427- command += f' -engine cmd={ engine_file } name={ test_name } { test_options } proto={ protocol } '
428- command += f' -engine cmd={ engine_file } name={ base_name } { base_options } proto={ protocol } '
431+ command += f' -engine cmd={ engine_file } name={ test_name } timemargin= { timemargin } proto={ protocol } { test_options } '
432+ command += f' -engine cmd={ engine_file } name={ base_name } timemargin= { timemargin } proto={ protocol } { base_options } '
429433 command += f' -rounds { games // 2 } -games 2 -repeat 2'
430434 command += ' -recover'
431435 command += f' -wait { cutechess_wait } '
@@ -458,14 +462,15 @@ def engine_match(engine_file, test_options, base_options, opening_file,
458462 match_manager = 'cutechess' , match_manager_path = None ,
459463 variant = 'normal' , cutechess_debug = False ,
460464 cutechess_wait = 5000 , move_time = None , nodes = None ,
461- protocol = 'uci' ) -> float :
465+ protocol = 'uci' ,
466+ timemargin = 50 ) -> float :
462467 result = ''
463468
464469 tour_manager , command = get_match_commands (
465470 engine_file , test_options , base_options , opening_file ,
466471 opening_file_format , games , depth , concurrency , base_time_sec ,
467472 inc_time_sec , match_manager , match_manager_path , variant , cutechess_debug ,
468- cutechess_wait , move_time , nodes , protocol )
473+ cutechess_wait , move_time , nodes , protocol , timemargin )
469474
470475 # Execute the command line to start the match.
471476 if os_name .lower () == 'windows' :
@@ -665,6 +670,9 @@ def main():
665670 'move control like --base-time-sec or'
666671 ' --depth or --move-time-sec example:\n '
667672 '--nodes 500 ...' )
673+ parser .add_argument ('--time-margin' , required = False ,
674+ help = 'time margin in milliseconds for cutechess interface (not required), default=50.' ,
675+ default = 50 )
668676 parser .add_argument ('--optimizer' , required = False , type = str ,
669677 help = 'Type of optimizer to use, can be oneplusone or'
670678 ' tbpsa or bayesopt, or spsa, or cmaes, or ngopt, default=oneplusone.' ,
@@ -1005,6 +1013,7 @@ def main():
10051013 cutechess_debug = args .cutechess_debug ,
10061014 cutechess_wait = args .cutechess_wait ,
10071015 protocol = args .protocol ,
1016+ timemargin = args .time_margin ,
10081017 enhance = args .enhance ,
10091018 enhance_hashmb = args .enhance_hashmb ,
10101019 enhance_threads = args .enhance_threads ,
0 commit comments