CopyPastor

Detecting plagiarism made easy.

Score: 0.7822179794311523; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2019-06-07
by ABHINAV SAGAR

Original Post

Original - Posted on 2019-01-14
by Shrawan Agrawal



            
Present in both answers; Present only in the new answer; Present only in the old answer;

First install all dependencies-
import gym import numpy as np import matplotlib.pyplot as plt from IPython import display as ipythondisplay
Then use-
from pyvirtualdisplay import Display display = Display(visible=0, size=(400, 300)) display.start()
Finally run-
env = gym.make("CartPole-v0") env.reset() prev_screen = env.render(mode='rgb_array') plt.imshow(prev_screen)
for i in range(50): action = env.action_space.sample() obs, reward, done, info = env.step(action) screen = env.render(mode='rgb_array') plt.imshow(screen) ipythondisplay.clear_output(wait=True) ipythondisplay.display(plt.gcf())
if done: break ipythondisplay.clear_output(wait=True) env.close()
Try this :-
!apt-get install python-opengl -y !apt install xvfb -y !pip install pyvirtualdisplay !pip install piglet from pyvirtualdisplay import Display Display().start() import gym from IPython import display import matplotlib.pyplot as plt %matplotlib inline env = gym.make('CartPole-v0') env.reset() img = plt.imshow(env.render('rgb_array')) # only call this once for _ in range(40): img.set_data(env.render('rgb_array')) # just update the data display.display(plt.gcf()) display.clear_output(wait=True) action = env.action_space.sample() env.step(action)
#This worked for me so I guess it should also work for you.

        
Present in both answers; Present only in the new answer; Present only in the old answer;