original_docstring: Policy improvement implementation (step 3 of algorithm at page 80)
  
      :return: None
      
docstring: Policy improvement implementation (step 3 of algorithm at page 80)
docstring_tokens: Policy improvement implementation ( step 3 of algorithm at page 80 )
code: def policy_improvement():
      """Policy improvement implementation (step 3 of algorithm at page 80)
  
      :return: None
      """
      policy_stable = True
      for state in STATES:
          old_action = policy[state]
  
          # get all possible actions
          x, y = state
          actions = range(-min(y, MAX_MOVE), min(x, MAX_MOVE) + 1)
  
          # list of action values
          action_values = [expected_value(values, state, action) for action in actions]
  
          # optimal action
          policy[x, y] = actions[argmax(action_values)]
  
          if old_action != policy[state]:
              policy_stable = False
  
      return policy_stable
code_tokens: def policy_improvement ( ) : policy_stable = True for state in STATES : old_action = policy [ state ] x , y = state actions = range ( - min ( y , MAX_MOVE ) , min ( x , MAX_MOVE ) + 1 ) action_values = [ expected_value ( values , state , action ) for action in actions ] policy [ x , y ] = actions [ argmax ( action_values ) ] if old_action != policy [ state ] : policy_stable = False return policy_stable
short_docstring: Policy improvement implementation (step 3 of algorithm at page 80)
short_docstring_tokens: Policy improvement implementation ( step 3 of algorithm at page 80 )
comment: """Policy improvement implementation (step 3 of algorithm at page 80)
  
      :return: None
      """$SEP$# get all possible actions$SEP$# list of action values$SEP$# optimal action