Fehu_envs.Random_walkSourceOne-dimensional random walk environment.
ID: RandomWalk-v0
Observation Space: Fehu.Space.Box with shape [1] in range [-10.0, 10.0]. Represents the agent's continuous position on a line.
Action Space: Fehu.Space.Discrete with 2 choices:
0: Move left (position -= 1.0)1: Move right (position += 1.0)Rewards: Negative absolute position (-|position|), encouraging the agent to stay near the origin. Terminal states at boundaries yield reward -10.0.
Episode Termination:
Rendering: ASCII visualization showing agent position ('o') on a line.
Train a simple policy to stay near the origin:
let rng = Rune.Rng.create () in
let env = Fehu_envs.Random_walk.make ~rng () in
let obs, _ = Fehu.Env.reset env () in
for _ = 1 to 100 do
let action = (* policy chooses 0 or 1 *) in
let t = Fehu.Env.step env action in
Printf.printf "Position: %.2f, Reward: %.2f\n"
(Rune.to_array t.observation).(0) t.reward
doneval reset :
'a ->
?options:'b ->
unit ->
state ->
(float, Rune.float32_elt) Rune.t * Fehu.Info.tval step :
'a ->
(Int32.t, 'b) Rune.t ->
state ->
((float, Rune.float32_elt) Rune.t, 'c, 'd) Fehu.Env.transitionval make :
rng:Rune.Rng.key ->
unit ->
(Fehu.Space.Box.element, Fehu.Space.Discrete.element, string) Fehu.Env.t