import csv
import random


GRAPH = {
'C': [
['D', 2],
['Dm', 2],
['E', 4],
['Em', 1],
['A', 3],
['Am', 0],
],
'D': [
['C', 2],
['Dm', 3],
['E', 2],
['Em', 1],
['A', 1],
['Am', 2],
],
'Dm': [
['C', 2],
['D', 3],
['Em', 2],
['A', 4],
['Am', 1],
],
'E': [
['C', 4],
['D', 2],
['Em', 3],
['A', 1],
['Am', 4],
],
'Em': [
['C', 1],
['D', 1],
['Dm', 2],
['E', 3],
['A', 2],
['Am', 1],
],
'A': [
['C', 3],
['D', 1],
['Dm', 4],
['E', 1],
['Em', 2],
['Am', 3],
],
'Am': [
['C', 0],
['D', 2],
['Dm', 1],
['E', 4],
['Em', 1],
['A', 3],
]
}

BUTTONS = {
'Dm': 1,
'Em': 2,
'Esus': 3,
'E': 4,
'F': 5,
'G': 6,
'C/G': 7,
'E/G#': 8,
'Am': 9,
'C/A': 10,
'Dm/A': 11,
'D/A': 12,
'A': 13,
'B/A': 14,
'C': 15,
'D': 16,
}

def generate_chord_sequence(length = 4):
    first_chords = GRAPH.keys()
    sequence = [random.choice(first_chords)]


    for i in xrange(length - 1):
        sequence.append(random.choice(GRAPH[sequence[-1]])[0])

    return sequence



if __name__ == '__main__':
    sequence = generate_chord_sequence()
    print sequence
    for chord in sequence:
        print BUTTONS[chord],
    print

Изменить пасту