#NEWLINE# def e_greedy( self , state , epsilon ) : #NEWLINE# #INDENT# s = Variable ( state ) #NEWLINE# q = self . q_func ( s ) #NEWLINE# q = q . data #NEWLINE# if ( np . random . rand ( ) < epsilon ) : #NEWLINE# #INDENT# index_action = np . random . randint ( 0 , self . num_of_actions ) #NEWLINE# ( print ( ' Random' ) , ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . use_gpu >= 0 ) : #NEWLINE# #INDENT# index_action = np . argmax ( q . get ( ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# index_action = np . argmax ( q ) #NEWLINE# #UNINDENT# ( print ( '#Greedy' ) , ) #NEWLINE# #UNINDENT# return ( self . index_to_action ( index_action ) , q )