#NEWLINE# def run_episode( self , max_steps , testing ) : #NEWLINE# #INDENT# 'Run a single training episode.\n\n        The boolean terminal value returned indicates whether the\n        episode ended because the game ended or the agent died (True)\n        or because the maximum number of steps was reached (False).\n        Currently this value will be ignored.\n\n        Return: (terminal, num_steps)\n\n        ' #NEWLINE# self . _init_episode ( ) #NEWLINE# start_lives = self . ale . lives ( ) #NEWLINE# action = self . agent . start_episode ( self . get_observation ( ) ) #NEWLINE# num_steps = 0 #NEWLINE# while True : #NEWLINE# #INDENT# reward = self . _step ( self . min_action_set [ action ] ) #NEWLINE# self . terminal_lol = ( self . death_ends_episode and ( not testing ) and ( self . ale . lives ( ) < start_lives ) ) #NEWLINE# terminal = ( self . ale . game_over ( ) or self . terminal_lol ) #NEWLINE# num_steps += 1 #NEWLINE# if ( testing or ( num_steps >= max_steps ) ) : #NEWLINE# #INDENT# self . agent . end_episode ( reward , terminal ) #NEWLINE# break #NEWLINE# #UNINDENT# action = self . agent . step ( reward , self . get_observation ( ) ) #NEWLINE# #UNINDENT# return ( terminal , num_steps )