Пример #1
0
    def __init__(self, wbLevers, scale, chord, duration, rhythm):

        self.desc = 'bass2'
        self.duration = duration
        self.rhythm = rhythm
        self.homeChord = chord
        self.homeScale = scale
        self.id = wbLevers['id']

        # initialize the state attributes for the bass2 layer
        self.StateAttributes = StateAttributes.StateAttributes[self.desc]
        self.numFeatures = len(self.StateAttributes)
        self.features = [i for i in range(self.numFeatures)]

        isRL = False
        if isRL:

            layerParams = None

            # initialize actions for the bass2 layer
            self.Knobs, self.Actions, self.ReverseActions = ComplexityKnobs.setKnobs(
                self.desc, wbLevers['complexity'], layerParams)
            self.numActions = len(self.Actions)
            self.defaultAction = 0  #'PLAY_HOME_NOTE'

            # Create the bass2 environment
            self.env = Environment.Bass2Environment(wbLevers['tse'],
                                                    wbLevers['phraseLength'],
                                                    scale, chord)
            # Initialize the bass2 environment variables
            self.env.InitializeEnvironment(scale)
            # self.env.printEnvironmentVariables ()

            # Initialize the RL data Structures
            self.initializeQLearningObject(0)

            self.trainedData = []

        else:
            layerParams = None
            # initialize actions for the bass2 layer
            self.Knobs, self.Actions, self.ReverseActions = ComplexityKnobs.setKnobs(
                self.desc, wbLevers['complexity'], layerParams)
            self.numActions = len(self.Actions)