.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/demo_env/video_plot_gridworld.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_demo_env_video_plot_gridworld.py: .. _gridworld_example: ======================================================== A demo of Gridworld environment with ValueIterationAgent ======================================================== Illustration of the training and video rendering ofValueIteration Agent in Gridworld environment. .. video:: ../../video_plot_gridworld.mp4 :width: 600 .. GENERATED FROM PYTHON SOURCE LINES 13-36 .. code-block:: python3 from rlberry_scool.agents.dynprog import ValueIterationAgent from rlberry_scool.envs.finite import GridWorld env = GridWorld(7, 10, walls=((2, 2), (3, 3))) agent = ValueIterationAgent(env, gamma=0.95) info = agent.fit() print(info) env.enable_rendering() observation, info = env.reset() for tt in range(50): action = agent.policy(observation) observation, reward, terminated, truncated, info = env.step(action) done = terminated or truncated if done: # Warning: this will never happen in the present case because there is no terminal state. # See the doc of GridWorld for more informations on the default parameters of GridWorld. break # Save the video env.save_video("_video/video_plot_gridworld.mp4", framerate=10) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.000 seconds) .. _sphx_glr_download_auto_examples_demo_env_video_plot_gridworld.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: video_plot_gridworld.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: video_plot_gridworld.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_