def test_optimise(): from cchess_alphazero.worker.optimize import start from cchess_alphazero.config import Config from cchess_alphazero.lib.logger import setup_logger c = Config('mini') c.resource.create_directories() setup_logger(c.resource.main_log_path) start(c)
def setup(config: Config, args): config.opts.new = args.new if args.total_step is not None: config.trainer.start_total_steps = args.total_step config.opts.device_list = args.gpu config.resource.create_directories() if args.cmd == 'self': setup_logger(config.resource.main_log_path) elif args.cmd == 'opt': setup_logger(config.resource.opt_log_path) elif args.cmd == 'play' or args.cmd == 'ob': setup_logger(config.resource.play_log_path) elif args.cmd == 'eval': setup_logger(config.resource.eval_log_path) elif args.cmd == 'sl': setup_logger(config.resource.sl_log_path)
def setup(config: Config, args): config.opts.new = args.new if args.total_step is not None: config.trainer.start_total_steps = args.total_step config.opts.device_list = args.gpu config.resource.create_directories() if args.cmd == 'self': setup_logger(config.resource.main_log_path) elif args.cmd == 'opt': setup_logger(config.resource.opt_log_path) elif args.cmd == 'play' or args.cmd == 'ob': setup_logger(config.resource.play_log_path) elif args.cmd == 'eval': setup_logger(config.resource.eval_log_path) elif args.cmd == 'sl': setup_logger(config.resource.sl_log_path)
def setup(config: Config, args): config.opts.new = args.new if args.total_step is not None: config.trainer.start_total_steps = args.total_step config.resource.create_directories() if args.cmd == 'self': setup_logger(config.resource.main_log_path) elif args.cmd == 'self2': setup_logger(config.resource.main_log_path) elif args.cmd == 'opt': setup_logger(config.resource.opt_log_path) elif args.cmd == 'play': setup_logger(config.resource.play_log_path)
from cchess_alphazero.play_games import play def setup_parameters(config): num_cores = mp.cpu_count() search_threads = 10 if num_cores < 10 else (num_cores // 10) * 10 print(f"search_threads = {search_threads}") config.play.search_threads = search_threads if __name__ == "__main__": mp.freeze_support() sys.setrecursionlimit(10000) config_type = 'distribute' config = Config(config_type=config_type) config.opts.device_list = '0' config.resource.create_directories() setup_logger(config.resource.play_log_path) config.opts.new = False config.opts.light = False pwhc = PlayWithHumanConfig() pwhc.update_play_config(config.play) config.opts.bg_style = 'WOOD' setup_parameters(config) simulation_num = input('请输入AI搜索次数(必须为整数):') ai_move_first = input('AI执红?(Y/N)') ai_move_first = True if ai_move_first == 'Y' or ai_move_first == 'y' else False config.play.simulation_num_per_move = int(simulation_num) play.start(config, not ai_move_first) input('按任意键退出...')
def setup_parameters(config): if len(sys.argv) > 1: config.internet.username = sys.argv[1] print(f'用户名设置为:{config.internet.username}') num_cores = mp.cpu_count() max_processes = 2 if len(sys.argv) > 2: max_processes = int(sys.argv[2]) search_threads = 20 print( f"max_processes = {max_processes}, search_threads = {search_threads}") config.play.max_processes = max_processes config.play.search_threads = search_threads if __name__ == "__main__": sys.setrecursionlimit(10000) config_type = 'distribute' config = Config(config_type=config_type) config.opts.device_list = '0' config.resource.create_directories() setup_logger(config.resource.main_log_path) config.internet.distributed = False config.opts.log_move = True config.opts.has_history = True setup_parameters(config) # config.internet.download_url = 'http://alphazero-1251776088.cossh.myqcloud.com/model/128x7/model_best_weight.h5' self_play.start(config)
if len(sys.argv) > 2: flag = sys.argv[2] if flag == 'new': config.internet.base_url = 'http://temp.52coding.com.cn' elif flag == 'new2': config.internet.base_url = 'http://temp3.52coding.com.cn' config.internet.upload_url = f'{config.internet.base_url}/api/upload_game_file/192x10' config.internet.upload_eval_url = f'{config.internet.base_url}/api/upload_eval_game_file' config.internet.get_latest_digest = f'{config.internet.base_url}/api/get_latest_digest/192x10' config.internet.get_evaluate_model_url = f'{config.internet.base_url}/api/query_for_evaluate' config.internet.update_elo_url = f'{config.internet.base_url}/api/add_eval_result/' search_threads = 20 print( f"max_processes = {max_processes}, search_threads = {search_threads}") config.play.max_processes = max_processes config.play.search_threads = search_threads if __name__ == "__main__": sys.setrecursionlimit(10000) config_type = 'distribute' config = Config(config_type=config_type) config.opts.device_list = '0' config.opts.log_move = True config.resource.create_directories() setup_logger(config.resource.eval_log_path) config.eval.update_play_config(config.play) setup_parameters(config) # config.internet.download_base_url = 'http://alphazero-1251776088.cossh.myqcloud.com/model/' evaluator.start(config)
def setup_parameters(config): num_cores = mp.cpu_count() search_threads = 10 if num_cores < 10 else 20 print(f"search_threads = {search_threads}") config.play.search_threads = search_threads if __name__ == "__main__": mp.freeze_support() sys.setrecursionlimit(10000) config_type = 'distribute' config = Config(config_type=config_type) config.opts.device_list = '0' config.resource.create_directories() setup_logger(config.resource.play_log_path) config.opts.new = False config.opts.light = False pwhc = PlayWithHumanConfig() pwhc.update_play_config(config.play) config.opts.bg_style = 'WOOD' setup_parameters(config) simulation_num = input('请输入AI搜索次数(必须为整数):') ai_move_first = input('AI执红?(Y/N)') ai_move_first = True if ai_move_first == 'Y' or ai_move_first == 'y' else False config.play.simulation_num_per_move = int(simulation_num) play.start(config, not ai_move_first) input('按任意键退出...')