#NEWLINE# def step( self , a ) : #NEWLINE# #INDENT# r = self . STEP_REWARD #NEWLINE# ns = self . state . copy ( ) #NEWLINE# if ( self . random_state . random_sample ( ) < self . NOISE ) : #NEWLINE# #INDENT# a = self . random_state . choice ( self . possibleActions ( ) ) #NEWLINE# #UNINDENT# ns = ( self . state + self . ACTIONS [ a ] ) #NEWLINE# if ( ( ns [ 0 ] < 0 ) or ( ns [ 0 ] == self . ROWS ) or ( ns [ 1 ] < 0 ) or ( ns [ 1 ] == self . COLS ) or ( self . map [ ( ns [ 0 ] , ns [ 1 ] ) ] == self . BLOCKED ) ) : #NEWLINE# #INDENT# ns = self . state . copy ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . state = ns . copy ( ) #NEWLINE# #UNINDENT# if ( self . map [ ( ns [ 0 ] , ns [ 1 ] ) ] == self . GOAL ) : #NEWLINE# #INDENT# r = self . GOAL_REWARD #NEWLINE# #UNINDENT# if ( self . map [ ( ns [ 0 ] , ns [ 1 ] ) ] == self . PIT ) : #NEWLINE# #INDENT# r = self . PIT_REWARD #NEWLINE# #UNINDENT# terminal = self . isTerminal ( ) #NEWLINE# return ( r , ns , terminal , self . possibleActions ( ) )