import random


def ai_turn(goal):
    """
    Returns the score for the opponent's turn.

    This function rolls the die for the opponent, and adds the value to the turn
    score. Using a primitive Pig strategy, the opponent keeps rolling until the
    score meets or exceeds goal. If the opponent ever rolls a 1, the score is 0
    and the opponent loses this turn.

    Parameter goal: The target goal to hit this turn
    Precondition: goal is an int > 0
    """
    score = 0
    halted = False
    while not halted:
        roll = random.randint(1,6)
        print('Your opponent rolled a '+str(roll)+'.')
        if roll != 1:
            score = score + roll
            halted = score >= goal
        else:
            score = 0
            halted = True

    if score == 0:
        print('Your opponent busted this round.')
    else:
        print('Your opponent banked '+str(score)+' this round.')
    print()

    return score