Skip to content
Snippets Groups Projects
Commit e04f9679 authored by hagrid67's avatar hagrid67
Browse files

adding flatland-animate notebook. Simple animation.

parent 991618a8
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id: tags:
# Simple Animation Demo
%% Cell type:code id: tags:
``` python
%load_ext autoreload
%autoreload 2
```
%% Cell type:code id: tags:
``` python
from flatland.utils.rendertools import RenderTool
import ipycanvas
import time
from flatland.envs.rail_env import RailEnv
from flatland.envs.rail_env import RailEnvActions as rea
from flatland.envs.persistence import RailEnvPersister
```
%% Cell type:code id: tags:
``` python
env, env_dict = RailEnvPersister.load_new("test_env_loop.pkl", load_from_package="env_data.tests")
oRT = RenderTool(env)
oRT.render_env()
image_arr = oRT.get_image()
canvas = ipycanvas.Canvas()
canvas.put_image_data(image_arr)
display(canvas)
for iEp in range(5):
env.reset(False, False, True)
env._max_episode_steps = 100
done={"__all__":False}
while not done["__all__"]:
obs, rew, done, info = env.step(action_dict_={int(0):rea.MOVE_FORWARD})
oRT.render_env()
gIm = oRT.get_image()
canvas.put_image_data(gIm)
time.sleep(0.1)
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment