From fd1eafdafa44dc11466fa6cd2188eab17dc7e1cc Mon Sep 17 00:00:00 2001
From: "Egli Adrian (IT-SCI-API-PFI)" <adrian.egli@sbb.ch>
Date: Sat, 25 May 2019 20:22:18 +0200
Subject: [PATCH] scene more railway realistic

---
 env-data/railway/example_flatland_000.pkl | Bin 1347 -> 1345 bytes
 examples/demo.py                          |  11 ++++++++---
 flatland/utils/rendertools.py             |   2 +-
 notebooks/Editor2.ipynb                   |   4 ++--
 4 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/env-data/railway/example_flatland_000.pkl b/env-data/railway/example_flatland_000.pkl
index 229a7dc1379de670255a8b2f601fea4882fdbc19..64de2138400ee32332402e25f9eac810b5c8bfad 100644
GIT binary patch
delta 59
zcmX@ib&zYrZ{~?jLX&+NIVUSH^GsG^37Ra&#6H=cnRRkD3n!2*#Ka>wS&vzaQEc)S
P7PHAOS$HP@VDSb31-B4>

delta 86
zcmX@eb(m|zZ)PSJ=E(*ulI&uPXIU7}icOYf37;I#BC5?J2;#GNB1otRSRF_TEDO>$
Rc?*l#<ku|RlRvZg0RT7}8Uz3U

diff --git a/examples/demo.py b/examples/demo.py
index 475003c..105396c 100644
--- a/examples/demo.py
+++ b/examples/demo.py
@@ -140,9 +140,14 @@ class Demo:
             # Action
             for iAgent in range(self.env.get_num_agents()):
                 action = 2
-                agent = self.env.agents[iAgent]
-                if not self.env.check_action(agent, action)[1]:
-                   action = np.random.choice(self.action_size)
+                if False:
+                    agent = self.env.agents[iAgent]
+                    trial = 0
+                    while not self.env.check_action(agent, action)[1]:
+                        action = np.random.choice(self.action_size)
+                        trial += 1
+                        if trial > 10:
+                            break
                 action_dict.update({iAgent: action})
 
             self.renderer.renderEnv(show=True, action_dict=action_dict)
diff --git a/flatland/utils/rendertools.py b/flatland/utils/rendertools.py
index 9db3cde..c3ba40f 100644
--- a/flatland/utils/rendertools.py
+++ b/flatland/utils/rendertools.py
@@ -769,7 +769,7 @@ class RenderTool(object):
                 self.gl.setAgentAt(iAgent, *agent.position, agent.direction, new_direction, color=oColor)
             else:
                 print("invalid action - agent ", iAgent, " bend ", agent.direction, new_direction)
-                self.gl.setAgentAt(iAgent, *agent.position, agent.direction, new_direction)
+                # self.gl.setAgentAt(iAgent, *agent.position, agent.direction, new_direction)
 
         self.gl.show()
         for i in range(3):
diff --git a/notebooks/Editor2.ipynb b/notebooks/Editor2.ipynb
index bc02130..76f200e 100644
--- a/notebooks/Editor2.ipynb
+++ b/notebooks/Editor2.ipynb
@@ -106,7 +106,7 @@
     {
      "data": {
       "application/vnd.jupyter.widget-view+json": {
-       "model_id": "71dda738592e49abafe596b348dfc3a1",
+       "model_id": "e86e118aa3dc4387857ec6bd80a1966b",
        "version_major": 2,
        "version_minor": 0
       },
@@ -132,7 +132,7 @@
     {
      "data": {
       "application/vnd.jupyter.widget-view+json": {
-       "model_id": "b7c1f13e789747b5ac7b65eba3584752",
+       "model_id": "48a4f97d8d1446f48314d9d72d733d98",
        "version_major": 2,
        "version_minor": 0
       },
-- 
GitLab