1. Learn
  2. /
  3. Courses
  4. /
  5. Reinforcement Learning with Gymnasium in Python

Connected

Exercise

Computing state-values for a policy

Using the same deterministic environment MyGridWorld, now you need to evaluate the effectiveness of the policy you defined in the previous exercise. You'll do this by computing the state value function for each state under this policy.

The environment has been imported as env along with the necessary variables needed (terminal_state, num_states, policy, gamma).

Instructions

100 XP
  • Complete the function compute_state_value() to compute the value for each state under the given policy.
  • Create a state_values dictionary where each key is the state, and each value is the state value.