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

Connected

Exercise

Applying Expected SARSA

Now you'll apply the Expected SARSA algorithm in a custom environment as shown below, where the goal is to let an agent navigate through a grid, aiming to reach a goal as quickly as possible. The same rules we had before apply: the agent receives a reward of +10 when reaching the diamond, -2 when passing through a mountain, and -1 for every other state.

new_cust_env.png

The environment has been imported as env.

Instructions

100 XP
  • Initialize the Q-table Q with zeros for each state-action pair.
  • Update the Q-table using the update_q_table() function.
  • Extract the policy as a dictionary from the learned Q-table.