'Dispenses reward based on the melodic interval just played.
Args:
action: One-hot encoding of the chosen action.
scaler: This value will be multiplied by all rewards in this function.
key: The numeric values of notes belonging to this key. Defaults to
C-major if not provided.
Returns:
Float reward value.'

def reward_preferred_intervals(self, action, scaler=5.0, key=None):

    (interval, _, _) = self.detect_sequential_interval(action, key)
    tf.logging.debug('Interval:', interval)
    if (interval == 0):
        tf.logging.debug('No    interval    or    uninteresting.')
        return 0.0
    reward = 0.0
    if (interval == rl_tuner_ops.REST_INTERVAL):
        reward = 0.05
        tf.logging.debug('Rest    interval.')
    if (interval == rl_tuner_ops.HOLD_INTERVAL):
        reward = 0.075
    if (interval == rl_tuner_ops.REST_INTERVAL_AFTER_THIRD_OR_FIFTH):
        reward = 0.15
        tf.logging.debug('Rest    interval    after    1st    or    5th.')
    if (interval == rl_tuner_ops.HOLD_INTERVAL_AFTER_THIRD_OR_FIFTH):
        reward = 0.3
    if (interval == rl_tuner_ops.SEVENTH):
        reward = (-0.3)
        tf.logging.debug('7th')
    if (interval > rl_tuner_ops.OCTAVE):
        reward = (-1.0)
        tf.logging.debug('More    than    octave.')
    if (interval == rl_tuner_ops.IN_KEY_FIFTH):
        reward = 0.1
        tf.logging.debug('In    key    5th')
    if (interval == rl_tuner_ops.IN_KEY_THIRD):
        reward = 0.15
        tf.logging.debug('In    key    3rd')
    if (interval == rl_tuner_ops.THIRD):
        reward = 0.09
        tf.logging.debug('3rd')
    if (interval == rl_tuner_ops.SECOND):
        reward = 0.08
        tf.logging.debug('2nd')
    if (interval == rl_tuner_ops.FOURTH):
        reward = 0.07
        tf.logging.debug('4th')
    if (interval == rl_tuner_ops.SIXTH):
        reward = 0.05
        tf.logging.debug('6th')
    if (interval == rl_tuner_ops.FIFTH):
        reward = 0.02
        tf.logging.debug('5th')
    tf.logging.debug('Interval    reward', (reward * scaler))
    return (reward * scaler)
