#NEWLINE# def learnQ( self , state , action , reward , value ) : #NEWLINE# #INDENT# old_value = self . q . get ( ( state , action ) , None ) #NEWLINE# if ( old_value is None ) : #NEWLINE# #INDENT# self . q [ ( state , action ) ] = reward #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . q [ ( state , action ) ] = ( old_value + ( self . alpha * ( value - old_value ) ) )