JuliaReinforcementLearning / CommonRLInterface.jl

A minimal reinforcement learning environment interface with additional opt-in features.
MIT License
45 stars 1 forks source link

render(env) #21

Closed zsunberg closed 4 years ago

zsunberg commented 4 years ago

We should have a standard way of visualizing environments.

There are two ways to do visualizations in Julia - either use the built in multimedia system or have a separate visualization pop up in an external window as in openai gym.

If we hook into the multimedia system, the visualization will display nicely in jupyter notebooks, IDEs like Juno, or popup windows through, e.g. ElectronDisplay. Moreover, it will be easy to save the frames to turn them into a gif or video or analyze them later.

I think the best way to integrate RL environments into the multimedia system is with a function called render that returns an object that is displayable (i.e. an object with a lot of show methods such as a Plots.jl plot or a Compose.jl graphic or a graphic produced by Cairo, or a custom type (perhaps called something like MyEnvVisualization) with show methods implemented. Then, to display the visualization, someone would call display(render(env)).

Another option is to just have environment writers implement show for their environments directly, but I've found this is confusing, especially for people new to julia.

In order to wrap environments that call code in other languages that can pop up their own visualization windows, we may also want a different function, perhaps called render_external(env) that pops up a display window. render_external could easily be implemented with render using render_external(env) = electrondisplay(render(env)).

(Note that this is completely separate from the observation returned by step!, though they may use some of the same code if the observations are images.)

findmyway commented 4 years ago

I think the best way to integrate RL environments into the multimedia system is with a function called render that returns an object that is displayable

👍

we may also want a different function, perhaps called render_external(env) that pops up a display window.

I think there's no need to add render_external in this package, or at least make it optional.