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

Notebook is working (Flatland3)

parent 81233c6d
No related branches found
No related tags found
No related merge requests found
%% 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>"))
```
%% Output
%% 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 sparse_rail_gen as spgen
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, bUCF=True)
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)
```
%% Output
%% Cell type:code id: tags:
``` python
dAgStateExpected = {0: (8, 5, 3), 1: (8, 6, 3)}
# {0: (7, 15, 2), 1: (6, 15, 2)}
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
```
%% Output
Expected: {0: (8, 6, 3), 1: (8, 7, 3)}
Actual: {0: (8, 6, 3), 1: (8, 7, 3)}
......
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