print("Computer move for " + color[board.turn] + " is " + engine_move) board.push_san(engine_move) #Prompts and plays user's move def prompt_and_play_user_move(): while True: try: human_move = board.parse_san(input("Input move in SAN for " + color[board.turn] + ": ")) break except ValueError: print("Invalid move, input again") board.push(human_move) #Loops over moves until game is over if (board.turn and type_of_game == 'cvh') or (not board.turn and type_of_game == 'hvc'): while not board.is_game_over(): play_engine_move() prompt_and_play_user_move() elif (board.turn and type_of_game == 'hvc') or (not board.turn and type_of_game == 'cvh'): while not board.is_game_over(): prompt_and_play_user_move() play_engine_move() elif type_of_game == 'cvc': while not board.is_game_over(): play_engine_move() #prints the results of the game including PGN print() print("This is the PGN of the game:") game = chess.pgn.Game.from_board(board) print(game)