#NEWLINE# def showLearning( self , representation ) : #NEWLINE# #INDENT# '\n\n        ``xSlice`` and ``xDotSlice`` - the value of ``x`` and ``xDot``\n        respectively, associated with the plotted value function and policy\n        (which are each 2-D grids across ``theta`` and ``thetaDot``).\n\n        ' #NEWLINE# xSlice = 0.0 #NEWLINE# xDotSlice = 0.0 #NEWLINE# warnStr = ( 'WARNING: showLearning() called with 4-state cartpole; only showing slice at (x, xDot) = (%.2f, %.2f)' % ( xSlice , xDotSlice ) ) #NEWLINE# ( thetas , theta_dots ) = self . _setup_learning ( representation ) #NEWLINE# pi = np . zeros ( ( len ( theta_dots ) , len ( thetas ) ) , 'uint8' ) #NEWLINE# V = np . zeros ( ( len ( theta_dots ) , len ( thetas ) ) ) #NEWLINE# for ( row , thetaDot ) in enumerate ( theta_dots ) : #NEWLINE# #INDENT# for ( col , theta ) in enumerate ( thetas ) : #NEWLINE# #INDENT# s = np . array ( [ theta , thetaDot , xSlice , xDotSlice ] ) #NEWLINE# terminal = self . isTerminal ( s ) #NEWLINE# Qs = representation . Qs ( s , terminal ) #NEWLINE# As = self . possibleActions ( s = s ) #NEWLINE# a = np . random . choice ( As [ ( Qs . max ( ) == col ) ] ) #NEWLINE# pi [ ( row , col ) ] = a #NEWLINE# V [ ( row , col ) ] = max ( Qs ) #NEWLINE# #UNINDENT# #UNINDENT# self . _plot_policy ( pi ) #NEWLINE# plt . title ( 'Policy (Slice at x=0, xDot=0)' ) #NEWLINE# self . _plot_valfun ( V ) #NEWLINE# plt . title ( 'Value Function (Slice at x=0, xDot=0)' ) #NEWLINE# pl . draw ( )