def shaped_policy(p_action, p_good, denominator):
    """
    Returns the probability of an action given a state for the policy as a result of policy shaping
    :param denominator: The sum over all p_action and p_good for every action in a given state.
    """

    if denominator <= .00001:
        denominator = .00001
    if denominator >= 1000:
        denominator = 1000
    return (p_action * p_good) / denominator