Skip to content

Commit c0d2293

Browse files
committed
move visualization callback to main package
1 parent 935313b commit c0d2293

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/callbacks.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,3 +302,26 @@ function reset!(p::AllRewards)
302302
end
303303
getvalue(p::AllRewards) = p.rewards
304304
export AllRewards
305+
306+
307+
"""
308+
mutable struct Visualize
309+
plot
310+
wait::Float64
311+
"""
312+
mutable struct Visualize
313+
wait::Float64
314+
end
315+
"""
316+
Visualize(; wait = .15)
317+
318+
A callback to be used in an `RLSetup` to visualize a maze during running or
319+
learning.
320+
"""
321+
Visualize(; wait = .15) = Visualize(wait)
322+
export Visualize
323+
function callback!(c::Visualize, rlsetup, s, a, r, done)
324+
plotenv(rlsetup.environment, s, a, r, done)
325+
sleep(c.wait)
326+
end
327+
plotenv(env, s, a, r, d) = warn("Visualization not implemented for environments of type $(typeof(env)).")

0 commit comments

Comments
 (0)