Solving 8x8 Frozen Lake with SARSA
In this exercise, you will apply the SARSA algorithm, incorporating the update_q_table() function you previously implemented, to learn an optimal policy for the 8x8 Frozen Lake environment. This environment is identical to the classic 4x4 one, with the only difference of being bigger. You will use the SARSA algorithm to iteratively improve the agent's policy based on the rewards received from the environment.
A Q-table Q has been initialized and pre-loaded for you, along with the update_q_table() function from the previous exercise.
Este exercício faz parte do curso
Reinforcement Learning with Gymnasium in Python
Instruções do exercício
- For each episode in the training process execute the selected
action. - Choose the
next_actionrandomly. - Update the Q-table for the given
stateandaction.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
for episode in range(num_episodes):
state, info = env.reset()
action = env.action_space.sample()
terminated = False
while not terminated:
# Execute the action
next_state, reward, terminated, truncated, info = ____
# Choose the next action randomly
next_action = ____
# Update the Q-table
____
state, action = next_state, next_action
render_policy(get_policy())