BaşlayınÜcretsiz Başlayın

Visualizing the Mountain Car Environment

Now, you'll take a step further in your exploration of the Mountain Car environment. Visualization is a key aspect of understanding the dynamics of RL environments. You'll write a function render() that displays the current state of the environment. This function will be used later on for any environment you want to visualize.

matplotlib.pyplot and gymnasium have been imported as plt and gym.

Bu egzersiz

Reinforcement Learning with Gymnasium in Python

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Complete the render() function to visualize the environment, obtaining the environment state_image and plotting it.
  • Call the render() function to display the current state of the environment.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

env = gym.make('MountainCar', render_mode='rgb_array')
initial_state, _ = env.reset()

# Complete the render function
def render():
    state_image = ____
    ____
    plt.show()

# Call the render function    
____
Kodu Düzenle ve Çalıştır