import math


def penalize_movement(action_log):
    """Penalizes high energy consumption. Analogy to nature: Moving costs energy, whereas staying still does not.
    Calculates relative share of 'noop' actions and uses square root as penalty factor.
    """

    # Remove fire actions from action log.
    actions_filtered = [a for a in action_log if a != 1]
    # Count number of 'noop' actions and calculate 'noop' rate.
    noop_actions = [a for a in actions_filtered if a == 0]
    noop_rate = len(noop_actions) / len(actions_filtered)
    # Calculate penalty factor as square root of ratio.
    penalty = math.sqrt(noop_rate)
    return penalty