Skip to content
Snippets Groups Projects
Commit fbe4e183 authored by adrian_egli2's avatar adrian_egli2
Browse files

Jupyter notebooks are ready for flatland3.

But they should be overworked. Might just one example per use case would be much more clear. TODO - cleanup
parent 1d64d2a5
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,5 @@ simple_rendering_demo.ipynb
flatland_animate.ipynb
render_episode.ipynb
scene_editor.ipynb
test_collision.ipynb
test_saved_envs.ipynb
test_service.ipynb
%% Cell type:markdown id: tags:
# Test Collisions
A visual test of a "rear-shunt" collision, to ensure that the agent does not get marked as collided permananently.
%% Cell type:code id: tags:
``` python
%load_ext autoreload
%autoreload 2
from IPython.core import display
display.display(display.HTML("<style>.container { width:95% !important; }</style>"))
```
%% Cell type:code id: tags:
``` python
import PIL
from IPython import display
from ipycanvas import canvas
import time
```
%% Cell type:code id: tags:
``` python
from flatland.envs import malfunction_generators as malgen
from flatland.envs.agent_utils import EnvAgent
from flatland.envs import rail_generators as rail_gen
from flatland.envs import agent_chains as ac
from flatland.envs.rail_env import RailEnv, RailEnvActions
from flatland.envs.persistence import RailEnvPersister
from flatland.utils.rendertools import RenderTool
from flatland.utils import env_edit_utils as eeu
from flatland.utils import jupyter_utils as ju
```
%% Cell type:code id: tags:
``` python
env, envModel = eeu.makeTestEnv("concentric_loops", nAg=2, remove_agents_at_target=True)
behaviour = ju.ForwardWithPause(env, [ju.AgentPause(0, 12, 5)])
oEC = ju.EnvCanvas(env, behaviour)
env.reset(regenerate_rail=False)
oEC.show()
for i in range(25):
oEC.step()
oEC.render()
time.sleep(0.1)
```
%% Cell type:code id: tags:
``` python
dAgStateExpected = {0: (8, 6, 3), 1: (8, 7, 3)}
dAgState={}
for iAg, ag in enumerate(env.agents):
dAgState[iAg] = (*ag.position, ag.direction)
print("Expected:", dAgStateExpected)
print("Actual:", dAgState)
assert dAgState == dAgStateExpected
```
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