Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visualization windows remain open #7

Open
Ryandry1st opened this issue Jul 19, 2019 · 3 comments
Open

Visualization windows remain open #7

Ryandry1st opened this issue Jul 19, 2019 · 3 comments

Comments

@Ryandry1st
Copy link

I probably simply do not see the function, but there does not seem to be a way to close the visualized plots once they are open. I attempted using:
plt.close()
plt.close('all')
but neither worked. Also simply attempting to close the window by clicking had no effect. The only way I could close the windows was by closing the entire workspace/killing the process.

Let me know what the proper way is!

@junhuang-ifast
Copy link

junhuang-ifast commented Aug 29, 2019

I had the same problem here. Although the official way to close an environment was to call env.close(), or in the example dqn-cartpole.py dummy_env.close() (i assume), none of these methods worked and the window remained open.

@Ryandry1st have u solved this problem?

Otherwise it would be appreciated if anyone else knows how to solve this? Thanks ! @danaugrs

@Ryandry1st
Copy link
Author

I also tried this and found that they did not work. No I do not have a solution, as of right now I have to close the execution window, which is not reasonable. I was mostly just looking into this to check out how the library works so I have not put in serious time for solutions. It also appears that the windows task manager is unable to close the windows too, so it is unlikely that a simple script will be able to.

@junhuang-ifast
Copy link

junhuang-ifast commented Aug 30, 2019

my solution was to go into the Simulation class directly in simulation.py and add env.close() at the end of the training/test function

For example:

def test(self, max_steps, visualize=True):
		"""Test the agent on the environment."""
		self.agent.training = False

		# Create and initialize environment
		env = self.create_env()
		state = env.reset()

		for step in range(max_steps):
			if visualize: env.render()
			action = self.agent.act(state)
			next_state, reward, done, _ = env.step(action)
			state = env.reset() if done else next_state
               env.close()  <------

This closes the window after train/test completes. It's a bit of a workaround but it works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants