Skip to content

Commit 7c044ca

Browse files
committed
more examples in docs
1 parent 5a9efa2 commit 7c044ca

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

docs/src/non_episodic.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,20 @@ end
2727
run(agent, env, stop_condition, hook, my_condition)
2828
```
2929

30-
We could also have made a struct to avoid the global struct.
30+
We can instead make a callable struct instead of a function to avoid the global `reset_n_step`.
31+
32+
```julia
33+
mutable struct MyCondition
34+
reset_after
35+
end
36+
37+
(c::MyCondition)(policy, env) = is_terminated(env) || c.reset_after(policy, env)
38+
39+
run(agent, env, stop_condition, hook, MyCondition(ResetAfterNSteps(10000)))
40+
```
41+
42+
A last possibility is to use an anonymous function. For example here is alternative way to implement ResetAtTerminal:
43+
44+
```julia
45+
run(agent, env, stop_condition, hook, (p,e) -> is_terminated(e))
46+
```

0 commit comments

Comments
 (0)