Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Ant

State and action spaces

With defaults, the 105-value observation concatenates qpos[2..] (13), all qvel (14), and the six external contact-force components for each non-world body (78), clipped to \([-1,1]\). Including root x/y adds two values; disabling contact forces removes 78. The default action has 8 actuator controls in \([-1,1]\).

Dynamics, reward, and info

For torso displacement over agent timestep \(\Delta t\), \(v_x=(x_{t+1}-x_t)/\Delta t\). With clipped full-model contact-force vector \(f_c\),

\[ r=w_fv_x+r_{healthy}-w_u\lVert u\rVert_2^2-w_c\lVert f_c\rVert_2^2. \]

Healthy means every simulator-state value is finite and root height \(z\in[z_{min},z_{max}]\). Info reports x/y position and velocity, distance from origin, and forward, control, contact, and survival reward components.

Episode end

When enabled, leaving the healthy range terminates. max_episode_steps truncates.

Configuration

AntConfig uses builders because its fields are private to the crate.

SettingDefaultMeaning
XML, frame_skipembedded model, 5Model and agent timestep
forward/control/contact weights1, 0.5, 0.0005Reward coefficients
healthy reward/range1, [0.2,1.0]Survival reward and root-height test
terminate unhealthytrueEnable health termination
contact force range[-1,1]Force clipping; fixed by the default config API
reset noise0.1Uniform qpos and Gaussian qvel noise scale
exclude root x/ytrueOmit the first two qpos entries
include contact forcestrueAppend non-world cfrc_ext
horizon1000Truncation limit

Reference: Gymnasium Ant.