示例#1
0
 def test_prepare_callbacks(self):
     agent = agents.PpoAgent("CartPole-v0")
     c = [plot.ToMovie(), plot.Rewards()]
     d = agent._prepare_callbacks(c, default_plots=None, default_plot_callbacks=[])
     assert isinstance(d[0], plot._PreProcess)
     assert isinstance(d[1], plot.Rewards)
     assert isinstance(d[-2], plot._PostProcess)
     assert isinstance(d[-1], plot.ToMovie)
示例#2
0
 def test_train_tomovie_with_filename(self):
     f = tempfile.NamedTemporaryFile(delete=False)
     filepath = f.name
     f.close()
     os.remove(filepath)
     assert not os.path.isfile(filepath)
     filepath += '.gif'
     agent = agents.PpoAgent("CartPole-v0")
     m = plot.ToMovie(filepath=filepath, fps=10)
     agent.train([duration._SingleIteration(), plot.Rewards(), m])
     try:
         os.remove(m.filepath)
     except:
         pass
示例#3
0
 def test_train_tomovie(self):
     agent = agents.PpoAgent("CartPole-v0")
     agent.train(
         [duration._SingleIteration(),
          plot.Rewards(),
          plot.ToMovie()])