def render()

in ml3/envs/mountain_car.py [0:0]


    def render(self, position_list, file_path='./mountain_car.gif', mode='gif'):
        """ When the method is called it saves an animation
        of what happened until that point in the episode.
        Ideally it should be called at the end of the episode,
        and every k episodes.

        ATTENTION: It requires avconv and/or imagemagick installed.
        @param file_path: the name and path of the video file
        @param mode: the file can be saved as 'gif' or 'mp4'
        """

        # Plot init
        fig = plt.figure(figsize=(4,4))
        ax = fig.add_subplot(111, autoscale_on=False, xlim=(-1.3, 0.6), ylim=(-1.2, 1.5))
        ax.grid(False)  # disable the grid
        x_sin = np.linspace(start=-1.2, stop=0.5, num=100)
        y_sin = np.sin(3 * x_sin)
        ax.plot(x_sin, y_sin,c='black',linewidth=3)  # plot the sine wave
        ax.plot(0.50, 1.16, marker="$\u2691$", markersize=25, color='green')

        dot, = ax.plot([], [],marker="$\u25A1$",markersize=15,color='red')
        time_text = ax.text(0.05, 0.9, '', transform=ax.transAxes)
        _position_list = position_list
        _delta_t = self.delta_t

        def _init():
            dot.set_data([], [])
            time_text.set_text('')
            return dot, time_text

        def _animate(i):
            x = _position_list[i]
            y = np.sin(3 * x)
            dot.set_data(x, y)
            time_text.set_text("")
            return dot, time_text

        ani = animation.FuncAnimation(fig, _animate, np.arange(1, len(position_list)),
                                      blit=True, init_func=_init, repeat=False)

        if mode == 'gif':
            ani.save(file_path, writer='imagemagick', fps=int(1 / self.delta_t))
        elif mode == 'mp4':
            ani.save(file_path, fps=int(1 / self.delta_t), writer='avconv', codec='libx264')
        # Clear the figure
        fig.clear()
        plt.close(fig)