Streamlit with OpenAI Gym

Hi all, just wondering if anyone here has experience integrating OpenAI Gym environments with Streamlit, specifically for visualizing/interacting with the environments.

I found an old project that seems to no longer be functional - . Wondering if anyone has a more updated repo that I could build off of. Thanks!

Hi @Brian,
I am not sure of the example you are referring to. I looked at some of the OpenAI Gym example and I could not get the animation to work in Streamlit. It seems OpenAI Gym opens a custom window and renders inside the window and, as far as I know, we don’t support that.

I tried:

import gym
env = gym.make('CartPole-v0')
for _ in range(1000):
    env.step(env.action_space.sample()) # take a random action

A possibility could be to change env.render() into something that uses a Streamlit primitive. I think it is what render_text_game in the example you posted is doing. I can see if I can get a hold of the code.