Mountain Car 環境をセットアップする
Gym でもっとも一般的な環境のひとつが Mountain Car です。目的は、非力な車で急な坂を登り切ることです。エンジンだけでは一気に登れないため、車は前後に走って慣性をつける必要があります。あなたの課題は、この環境を作成して初期設定することです。

この演習はコースの一部です
Pythonで学ぶGymnasiumによるReinforcement Learning
演習の手順
gymnasiumライブラリをgymとしてインポートします。- Gym ライブラリを使って Mountain Car 環境を作成し、環境IDを
MountainCar、render_modeを'rgb_array'に設定します。 seedに42を指定して環境をリセットし、車の位置と速度の2つの値を含むinitial_stateを取得します。
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
# Import the gymnasium library
____
# Create the environment
env = ____
# Get the initial state
initial_state, info = ____
position = initial_state[0]
velocity = initial_state[1]
print(f"The position of the car along the x-axis is {position} (m)")
print(f"The velocity of the car is {velocity} (m/s)")