#NEWLINE# def step( self , action ) : #NEWLINE# #INDENT# '\n        action map:\n        0: left\n        1: down\n        2: right\n        3: up\n        :param action: should be a one-hot vector encoding the action\n        :return:\n        ' #NEWLINE# possible_next_states = self . get_possible_next_states ( self . state , action ) #NEWLINE# probs = [ x [ 1 ] for x in possible_next_states ] #NEWLINE# next_state_idx = np . random . choice ( len ( probs ) , p = probs ) #NEWLINE# next_state = possible_next_states [ next_state_idx ] [ 0 ] #NEWLINE# next_x = ( next_state / self . n_col ) #NEWLINE# next_y = ( next_state % self . n_col ) #NEWLINE# next_state_type = self . desc [ ( next_x , next_y ) ] #NEWLINE# if ( next_state_type == 'H' ) : #NEWLINE# #INDENT# done = True #NEWLINE# reward = 0 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( next_state_type in [ 'F' , 'S' ] ) : #NEWLINE# #INDENT# done = False #NEWLINE# reward = 0 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( next_state_type == 'G' ) : #NEWLINE# #INDENT# done = True #NEWLINE# reward = 1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise NotImplementedError #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# self . state = next_state #NEWLINE# return Step ( observation = self . state , reward = reward , done = done )