def start(): parser = create_parser() args = parser.parse_args() config_type = args.type config = Config(config_type=config_type) setup(config, args) logger.info('Config type: %s' % (config_type)) if args.cmd == 'self': from cchess_alphazero.worker import self_play config.opts.light = True # use lighten environment return self_play.start(config) elif args.cmd == 'self2': from cchess_alphazero.worker import self_play2 config.opts.light = True # use lighten environment return self_play2.start(config) elif args.cmd == 'opt': from cchess_alphazero.worker import optimize return optimize.start(config) elif args.cmd == 'play': from cchess_alphazero.play_games import play config.opts.light = False pwhc = PlayWithHumanConfig() pwhc.update_play_config(config.play) logger.info(f"AI move first : {args.ai_move_first}") play.start(config, not args.ai_move_first)
def start(): parser = create_parser() args = parser.parse_args() config_type = args.type config = Config(config_type=config_type) setup(config, args) logger.info('Config type: %s' % (config_type)) config.opts.piece_style = args.piece_style config.opts.bg_style = args.bg_style config.internet.distributed = args.distributed # # use multiple GPU gpus = torch.cuda.device_count() if gpus > 1: config.opts.use_multiple_gpus = True config.opts.gpu_num = gpus config.opts.use_gpu = True # logger.info(f"User GPU {config.opts.device_list}") elif gpus == 1: config.opts.use_gpu = True if args.cmd == 'self': # if args.ucci: # import cchess_alphazero.worker.play_with_ucci_engine as self_play # else: # if mp.get_start_method() == 'spawn': # import cchess_alphazero.worker.self_play_windows as self_play # else: # from cchess_alphazero.worker import self_play import cchess_alphazero.worker.self_play_windows as self_play return self_play.start(config) elif args.cmd == 'opt': from cchess_alphazero.worker import optimize return optimize.start(config) elif args.cmd == 'play': if args.cli: import cchess_alphazero.play_games.play_cli as play else: from cchess_alphazero.play_games import play config.opts.light = False pwhc = PlayWithHumanConfig() pwhc.update_play_config(config.play) logger.info(f"AI move first : {args.ai_move_first}") play.start(config, not args.ai_move_first) elif args.cmd == 'pk': import cchess_alphazero.worker.pk_player_windows as self_play return self_play.start(config)
def start(): parser = create_parser() args = parser.parse_args() config_type = args.type config = Config(config_type=config_type) setup(config, args) logger.info('Config type: %s' % (config_type)) config.opts.piece_style = args.piece_style config.opts.bg_style = args.bg_style config.internet.distributed = args.distributed if args.cmd == 'self': if args.ucci: import cchess_alphazero.worker.play_with_ucci_engine as self_play else: if mp.get_start_method() == 'spawn': import cchess_alphazero.worker.self_play_windows as self_play else: from cchess_alphazero.worker import self_play return self_play.start(config) elif args.cmd == 'opt': from cchess_alphazero.worker import optimize return optimize.start(config) elif args.cmd == 'play': if args.cli: import cchess_alphazero.play_games.play_cli as play else: from cchess_alphazero.play_games import play config.opts.light = False pwhc = PlayWithHumanConfig() pwhc.update_play_config(config.play) logger.info(f"AI move first : {args.ai_move_first}") play.start(config, not args.ai_move_first) elif args.cmd == 'eval': if args.elo == False: from cchess_alphazero.worker import evaluator else: import cchess_alphazero.worker.compute_elo as evaluator config.eval.update_play_config(config.play) evaluator.start(config) elif args.cmd == 'sl': if args.onegreen: import cchess_alphazero.worker.sl_onegreen as sl sl.start(config, args.skip) else: from cchess_alphazero.worker import sl sl.start(config) elif args.cmd == 'ob': from cchess_alphazero.play_games import ob_self_play pwhc = PlayWithHumanConfig() pwhc.update_play_config(config.play) ob_self_play.start(config, args.ucci, args.ai_move_first)
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): 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('按任意键退出...')