(self, action_note)
return False
Detects whether the note played is repeating previous notes excessively.

    Args:
      action_note: An integer representing the note just played.
    Returns:
      True if the note just played is excessively repeated, False otherwise.
Detects whether the note played is repeating previous notes excessively.
Detects whether the note played is repeating previous notes excessively .
def detect_repeating_notes(self, action_note):
    """Detects whether the note played is repeating previous notes excessively.

    Args:
      action_note: An integer representing the note just played.
    Returns:
      True if the note just played is excessively repeated, False otherwise.
    """
    num_repeated = 0
    contains_held_notes = False
    contains_breaks = False

    # Note that the current action yas not yet been added to the composition
    for i in range(len(self.composition)-1, -1, -1):
      if self.composition[i] == action_note:
        num_repeated += 1
      elif self.composition[i] == NOTE_OFF:
        contains_breaks = True
      elif self.composition[i] == NO_EVENT:
        contains_held_notes = True
      else:
        break

    if action_note == NOTE_OFF and num_repeated > 1:
      return True
    elif not contains_held_notes and not contains_breaks:
      if num_repeated > 4:
        return True
    elif contains_held_notes or contains_breaks:
      if num_repeated > 6:
        return True
    else:
      if num_repeated > 8:
        return True

    return False
def detect_repeating_notes ( self , action_note ) : num_repeated = 0 contains_held_notes = False contains_breaks = False # Note that the current action yas not yet been added to the composition for i in range ( len ( self . composition ) - 1 , - 1 , - 1 ) : if self . composition [ i ] == action_note : num_repeated += 1 elif self . composition [ i ] == NOTE_OFF : contains_breaks = True elif self . composition [ i ] == NO_EVENT : contains_held_notes = True else : break if action_note == NOTE_OFF and num_repeated > 1 : return True elif not contains_held_notes and not contains_breaks : if num_repeated > 4 : return True elif contains_held_notes or contains_breaks : if num_repeated > 6 : return True else : if num_repeated > 8 : return True return False