Ejemplo n.º 1
0
def start(config: Config):
    PlayWithHumanConfig().update_play_config(config.play)
    chess_model = PlayWithHuman(config)

    env = ChessEnv().reset()
    human_is_black = random() < 0.5
    chess_model.start_game(human_is_black)

    while not env.done:
        if env.board.turn == chess.BLACK:
            if not human_is_black:
                action = chess_model.move_by_ai(env)
                print("IA moves to: " + action)
            else:
                action = chess_model.move_by_human(env)
                print("You move to: " + action)
        else:
            if human_is_black:
                action = chess_model.move_by_ai(env)
                print("IA moves to: " + action)
            else:
                action = chess_model.move_by_human(env)
                print("You move to: " + action)
        board, info = env.step(action)
        env.render()
        print("Board fen = " + board.fen())

    print("\nEnd of the game.")
    print("Game result:")
    print(env.board.result())
Ejemplo n.º 2
0
def start(config: Config):
    PlayWithHumanConfig().update_play_config(config.play)
    chess_model = PlayWithEngine(config)

    env = ChessEnv().reset()
    human_is_black = random() < 0.5
    chess_model.start_game(human_is_black)

    while not env.done:
        if (env.board.turn == chess.BLACK) == human_is_black:
            action = chess_model.move_by_opponent(env)
            print("You move to: " + action)
        else:
            action = chess_model.move_by_ai(env)
            print("AI moves to: " + action)
        board, info = env.step(action)
        env.render()
        print("Board FEN = " + board.fen())

    print("\nEnd of the game.")  #spaces after this?
    print("Game result:")  #and this?
    print(env.board.result())