original_docstring: Policy iteration implementation from RL book page 80
  
      :return: None
      
docstring: Policy iteration implementation from RL book page 80
docstring_tokens: Policy iteration implementation from RL book page 80
code: def policy_iteration():
      """Policy iteration implementation from RL book page 80
  
      :return: None
      """
      precalculate()
  
      # plotting
      fig, axes = plt.subplots(2, 3, figsize=(40, 20))
      # plt.subplots_adjust(wspace=0.1, hspace=0.2)
      axes = axes.flatten()
  
      iteration = 0
      policy_stable = False
      while not policy_stable:
          print('\r', 'policy iteration ', iteration, end='')
          # plot policy
          policy_title = r'$\pi_{}$'.format(iteration)
          heatmap(policy, policy_title, axes, iteration)
  
          # step2
          policy_evaluation()
  
          # step3
          policy_stable = policy_improvement()
  
          iteration += 1
  
      # plot values
      value_title = r'$v_{\pi_4}$'
      heatmap(values, value_title, axes, iteration)
code_tokens: def policy_iteration ( ) : precalculate ( ) fig , axes = plt . subplots ( 2 , 3 , figsize = ( 40 , 20 ) ) axes = axes . flatten ( ) iteration = 0 policy_stable = False while not policy_stable : print ( '\r' , 'policy iteration ' , iteration , end = '' ) policy_title = r'$\pi_{}$' . format ( iteration ) heatmap ( policy , policy_title , axes , iteration ) policy_evaluation ( ) policy_stable = policy_improvement ( ) iteration += 1 value_title = r'$v_{\pi_4}$' heatmap ( values , value_title , axes , iteration )
short_docstring: Policy iteration implementation from RL book page 80
short_docstring_tokens: Policy iteration implementation from RL book page 80
comment: """Policy iteration implementation from RL book page 80
  
      :return: None
      """$SEP$# plotting$SEP$# plt.subplots_adjust(wspace=0.1, hspace=0.2)$SEP$# plot policy$SEP$# step2$SEP$# step3$SEP$# plot values