#NEWLINE# def reward( self , last_action ) : #NEWLINE# #INDENT# if ( self . latest_pos == None ) : #NEWLINE# #INDENT# return 0 #NEWLINE# #UNINDENT# if ( self . last_pos == None ) : #NEWLINE# #INDENT# self . last_pos = self . latest_pos #NEWLINE# return 0 #NEWLINE# #UNINDENT# r = 0 #NEWLINE# if ( last_action == 0 ) : #NEWLINE# #INDENT# moved = ( not close ( self . latest_pos , r . last_pos ) ) #NEWLINE# r = ( 1 if moved else ( - 1 ) ) #NEWLINE# #UNINDENT# self . last_pos = self . latest_pos #NEWLINE# return r