importgymenv=gym.make('CartPole-v0')fori_episodeinrange(20):observation=env.reset()fortinrange(100):env.render()print(observation)action=env.action_space.sample()observation,reward,done,info=env.step(action)ifdone:print("Episode finished after {} timesteps".format(t+1))breakenv.close() 当...
pythonimport gymenv = gym.make('CartPole-v0')for i_episode in range(20):observation = env.reset()for t in range(100):env.render()print(observation)action = env.action_space.sample()observation, reward, done, info = env.step(action)if done:print("Episode finished after {} timesteps"....