def start(config: Config): PlayWithHumanConfig().update_play_config(config.play) me_player = None env = ChessEnv().reset() while True: line = input() words = line.rstrip().split(" ",1) if words[0] == "uci": print("id name ChessZero") print("id author ChessZero") print("uciok") elif words[0] == "isready": if not me_player: me_player = get_player(config) print("readyok") elif words[0] == "ucinewgame": env.reset() elif words[0] == "position": words = words[1].split(" ",1) if words[0] == "startpos": env.reset() else: if words[0] == "fen": # skip extraneous word words = words[1].split(' ',1) fen = words[0] for _ in range(5): words = words[1].split(' ',1) fen += " " + words[0] env.update(fen) if len(words) > 1: words = words[1].split(" ",1) if words[0] == "moves": for w in words[1].split(" "): env.step(w, False) elif words[0] == "go": if not me_player: me_player = get_player(config) action = me_player.action(env, False) print(f"bestmove {action}") elif words[0] == "stop": pass elif words[0] == "quit": break
def start(config: Config): PlayWithHumanConfig().update_play_config(config.play) me_player = None env = ChessEnv().reset() while True: line = input() words = line.rstrip().split(" ", 1) if words[0] == "uci": print("id name ChessZero") print("id author ChessZero") print("uciok") elif words[0] == "isready": if not me_player: me_player = get_player(config) print("readyok") elif words[0] == "ucinewgame": env.reset() elif words[0] == "position": words = words[1].split(" ", 1) if words[0] == "startpos": env.reset() else: if words[0] == "fen": # skip extraneous word words = words[1].split(' ', 1) fen = words[0] for _ in range(5): words = words[1].split(' ', 1) fen += " " + words[0] env.update(fen) if len(words) > 1: words = words[1].split(" ", 1) if words[0] == "moves": for w in words[1].split(" "): env.step(w, False) elif words[0] == "go": if not me_player: me_player = get_player(config) action = me_player.action(env, False) print(f"bestmove {action}") elif words[0] == "stop": pass elif words[0] == "quit": break
def start(config: Config): PlayWithHumanConfig().update_play_config(config.play) config.play.thinking_loop = 1 chess_model = None env = ChessEnv().reset() while True: line = input() words = line.rstrip().split(" ", 1) if words[0] == "uci": print("id name ChessZero") print("id author ChessZero") print("uciok") elif words[0] == "isready": if chess_model is None: chess_model = PlayWithHuman(config) print("readyok") elif words[0] == "ucinewgame": env.reset() elif words[0] == "position": words = words[1].split(" ", 1) if words[0] == "startpos": env.reset() else: fen = words[0] for _ in range(5): words = words[1].split(' ', 1) fen += " "+words[0] env.update(fen) if len(words) > 1: words = words[1].split(" ", 1) if words[0] == "moves": for w in words[1].split(" "): env.step(w, False) elif words[0] == "go": action = chess_model.move_by_ai(env) print(f"bestmove {action}") elif words[0] == "stop": pass elif words[0] == "quit": break