Display
DisplaySimulator
The DisplaySimulator displays each step of a simulation in real time through a multimedia display such as a Jupyter notebook or ElectronDisplay. Specifically it uses POMDPModelTools.render and the built-in Julia display function to visualize each step.
Example:
using POMDPs
using POMDPModels
using POMDPPolicies
using POMDPSimulators
using ElectronDisplay
ElectronDisplay.CONFIG.single_window = true
ds = DisplaySimulator()
m = SimpleGridWorld()
simulate(ds, m, RandomPolicy(m))POMDPSimulators.DisplaySimulator — TypeDisplaySimulator(;kwargs...)Create a simulator that displays each step of a simulation.
Given a POMDP or MDP model m, this simulator roughly works like
for step in stepthrough(m, ...)
display(render(m, step))
endKeyword Arguments
display::AbstractDisplay: the display to use for the first argument to thedisplayfunction. If this isnothing,display(...)will be called without anAbstractDisplayargument.render_kwargs::NamedTuple: keyword arguments forPOMDPModelTools.render(...)max_fps::Number=10: maximum number of frames to be displayed per second -sleepwill be used to skip extra time, so this is not designed for high precisionpredisplay::Function: function to call before every call todisplay(...). The only argument to this function will be the display (if it is specified) ornothingextra_initial::Bool=false: iftrue, display an extra step at the beginning with only elementst,sp, andbpfor POMDPs (this can be useful to see the initial state ifrenderdisplays onlyspand nots).extra_final::Bool=true: iftrue, display an extra step at the end with only elementst,done,s, andbfor POMDPs (this can be useful to see the final state ifrenderdisplays onlysand notsp`).max_steps::Integer: maximum number of steps to run forspec::NTuple{Symbol}: specification of what step elements to display (seeeachstep)rng::AbstractRNG: random number generator
See the POMDPSimulators documentation for more tips about using specific displays.
Display-specific tips
The following tips may be helpful when using particular displays.
Jupyter notebooks
By default, in a Jupyter notebook, the visualizations of all steps are displayed in the output box one after another. To make the output animated instead, where the image is overwritten at each step, one may use
DisplaySimulator(predisplay=(d)->IJulia.clear_output(true))ElectronDisplay
By default, ElectronDisplay will open a new window for each new step. To prevent this, use
ElectronDisplay.CONFIG.single_window = true