山地車¶
此環境屬於經典控制環境,其中包含有關該環境的通用資訊。
動作空間 |
|
觀測空間 |
|
匯入 |
|
描述¶
山地車 MDP 是一個確定性 MDP,其中一輛汽車隨機放置在正弦波谷底部,唯一可能的動作是對汽車施加任意方向的加速度。該 MDP 的目標是策略性地加速汽車,以達到右側山頂上的目標狀態。Gymnasium 中山地車領域有兩個版本:一個使用離散動作,一個使用連續動作。此版本使用離散動作。
此 MDP 最早出現在 Andrew Moore 的博士論文 (1990) 中
@TECHREPORT{Moore90efficientmemory-based,
author = {Andrew William Moore},
title = {Efficient Memory-based Learning for Robot Control},
institution = {University of Cambridge},
year = {1990}
}
觀測空間¶
觀測是一個形狀為 ndarray 的 (2,),其元素對應如下:
編號 |
觀測 |
最小值 |
最大值 |
單位 |
|---|---|---|---|---|
0 |
汽車沿 x 軸的位置 |
-1.2 |
0.6 |
位置 (m) |
1 |
汽車的速度 |
-0.07 |
0.07 |
速度 (v) |
動作空間¶
有 3 種離散的確定性動作
0: 向左加速
1: 不加速
2: 向右加速
轉移動力學:¶
給定一個動作,山地車遵循以下轉移動力學
velocityt+1 = velocityt + (action - 1) * force - cos(3 * positiont) * gravity
positiont+1 = positiont + velocityt+1
其中 force = 0.001,gravity = 0.0025。兩端的碰撞都是非彈性的,與牆壁碰撞後速度設定為 0。位置被限制在 [-1.2, 0.6] 範圍內,速度被限制在 [-0.07, 0.07] 範圍內。
獎勵:¶
目標是儘快到達右側山頂上的旗幟,因此智慧體在每個時間步都會被懲罰 -1 的獎勵。
起始狀態¶
汽車的位置被分配為 *[-0.6 , -0.4]* 中的均勻隨機值。汽車的起始速度始終被設定為 0。
回合結束¶
如果發生以下任一情況,回合結束
終止:汽車位置大於或等於 0.5(右側山頂上的目標位置)
截斷:回合長度為 200。
引數¶
山地車環境有兩個用於 gymnasium.make 的引數:render_mode 和 goal_velocity。在重置時,options 引數允許使用者更改用於確定新隨機狀態的邊界。
>>> import gymnasium as gym
>>> env = gym.make("MountainCar-v0", render_mode="rgb_array", goal_velocity=0.1) # default goal_velocity=0
>>> env
<TimeLimit<OrderEnforcing<PassiveEnvChecker<MountainCarEnv<MountainCar-v0>>>>>
>>> env.reset(seed=123, options={"x_init": np.pi/2, "y_init": 0.5}) # default x_init=np.pi, y_init=1.0
(array([-0.46352962, 0. ], dtype=float32), {})
版本歷史¶
v0: 初始版本釋出