Qu

reset

Builtin index · Statistics & ML

result = reset(env) or env.reset()

Input: env · Output: result

What it is

No chapter describes this one yet. It exists -- the name comes from the interpreter's own table -- but the prose has not been written. That is a gap in the documentation, not in the engine.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = reset(env) or env.reset()
env —not documented yet
result —
Returns the environment env's starting state — a plain integer state index. The environment holds no live position of its own to reset; the returned index is the one to thread through your own loop.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

env = gridworld_env(4)
start = env.reset()
print("start state: {start}")

q = q_learning(env, 300, alpha = 0.3, gamma = 0.9, epsilon = 0.1, seed = 7)
s = sarsa(env, 300, alpha = 0.3, gamma = 0.9, epsilon = 0.1, seed = 7)
print("q_learning reward: early {round(mean(q.rewards[0:19]), 2)} -> late {round(mean(q.rewards[280:299]), 2)}")
print("sarsa reward:      early {round(mean(s.rewards[0:19]), 2)} -> late {round(mean(s.rewards[280:299]), 2)}")

state = env.reset()
steps = 0
done = false
while done == false and steps < 20
    action = q.predict(state)
    result = env.step(state, action)
    state = result.next_state
    steps = steps + 1
    done = result.done
end while
print("greedy policy reached the goal in {steps} steps")
output
start state: 0
q_learning reward: early -4 -> late 4.45
sarsa reward:      early -1.5 -> late 4.6
greedy policy reached the goal in 6 steps

from statistics-ml

How it works

reset(env) — callable as env.reset(). Returns the environment's starting state (a plain discrete index), not a new env — gridworld_env carries no live position to reset (see this section's own doc comment above).

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.