From 13c34d6caf5339de659d01f33d984b7f2752af96 Mon Sep 17 00:00:00 2001
From: "Egli Adrian (IT-SCI-API-PFI)" <adrian.egli@sbb.ch>
Date: Mon, 27 May 2019 15:27:50 +0200
Subject: [PATCH] ...

---
 env-data/railway/example_flatland_001.pkl | Bin 0 -> 2144 bytes
 env-data/railway/example_network_003.pkl  | Bin 0 -> 250 bytes
 examples/demo.py                          |  24 +++++++++++++++-
 flatland/envs/rail_env.py                 |   4 +--
 notebooks/Editor2.ipynb                   |  33 ++++++++++++++--------
 5 files changed, 46 insertions(+), 15 deletions(-)
 create mode 100644 env-data/railway/example_flatland_001.pkl
 create mode 100644 env-data/railway/example_network_003.pkl

diff --git a/env-data/railway/example_flatland_001.pkl b/env-data/railway/example_flatland_001.pkl
new file mode 100644
index 0000000000000000000000000000000000000000..dcf8b8f51e3ce16c408c8d774bbbc7d29d6c242d
GIT binary patch
literal 2144
zcmZ`(OHLa>5S;-lu>^{Y6=e;az~TffvS3aTp(Fw}EWigqf`yl8%n_pOa)(@CZopyk
zs$W%gRok(wnV#-f@4foWJpa0Rxcl+meSYsQy7Zea52jhK|7AMb^U#J%^zlh0m<`ka
zI8;cFK{TsjUk|4*<^g7~#ts&^CU#;51;-HLJ&|}s9zUX%(hefw;ANL>320E4A~2{M
z?0Zb)Rj~O(NbBB?=qa8?Eu8w}vYVbxS@zT_VCD<y&{ZuXy_D^;3lgzis>a3A;S9DG
zL!-((o!YkFL$B0aAq5G-9Hk2<v#6}q!1of|PNOE>pwpwJ?#=LQnRC2i?xw%z(`MC<
zaALFvW3JA{rY8ni9%qXycT3ylqrb)?9{tquEGyK)IO?pFaYRHz<Dvfc?U?XMo-ZVi
z_}crhMPjZCIM{F@S(Nu7+NY~BvRaW{8+?b$b+f8Y5L$Dx7tKYmm@i`IuC#23@oMdr
z1Ry%3r1!G+Et2ykk>0c8yTo8+(WKr4;hNz%Nu-4Zs4`nM*H91NWV6M$eSX+9O4x9E
zUW^kfDww*9+UZo7vd&Ua2BzH%pDLWboXH;xIC5RCwH9W!7ZauJz|}Js3!hv9gw*6K
zwd2deD<c4_NwSsqfobxows_VksZmnrVEJY?Xeg)5VohXHWftO3+hUDl#`W96{Y;Yh
z`M!s|!BE4C((b6yK+tR|(hv~-=lbU7{rd6S<NA7i_x)`<9`^ls&~L}?1ov(`&OYG&
O5&K8|*nj#>`0GE%mI+t@

literal 0
HcmV?d00001

diff --git a/env-data/railway/example_network_003.pkl b/env-data/railway/example_network_003.pkl
new file mode 100644
index 0000000000000000000000000000000000000000..ae8a74fd50fb1936746fbc9ab852cd4350de1e40
GIT binary patch
literal 250
zcmZo(l3tXVGW8CFBm*u0lw&!|!iYdZ*i>SuV(~=iK-P_mEe5lJkpY)$JfJ4xRsnL^
n+QjtKyprPh;*!LY%;ZUvCowWIPGXXnJc)@JNQ*CnNKXI&X8SQE

literal 0
HcmV?d00001

diff --git a/examples/demo.py b/examples/demo.py
index 105396c..9abfa59 100644
--- a/examples/demo.py
+++ b/examples/demo.py
@@ -1,4 +1,5 @@
 import os
+import time
 import random
 
 import numpy as np
@@ -137,9 +138,18 @@ class Demo:
         _ = self.env.reset(False, False)
 
         for step in range(max_nbr_of_steps):
+
+            time.sleep(.1)
+
             # Action
             for iAgent in range(self.env.get_num_agents()):
                 action = 2
+
+                if True:
+                    if not ((step) % 2 == 0):
+                        if iAgent % 2 == 1:
+                            action = 0
+
                 if False:
                     agent = self.env.agents[iAgent]
                     trial = 0
@@ -150,6 +160,7 @@ class Demo:
                             break
                 action_dict.update({iAgent: action})
 
+
             self.renderer.renderEnv(show=True, action_dict=action_dict)
 
             # Environment step
@@ -180,7 +191,18 @@ if False:
     demo_002.run_demo()
     demo_002 = None
 
-demo_flatland_000 = Demo(Scenario_Generator.load_scenario('./env-data/railway/example_flatland_000.pkl'))
+    demo_flatland_000 = Demo(Scenario_Generator.load_scenario('./env-data/railway/example_flatland_000.pkl'))
+    demo_flatland_000.renderer.resize()
+    demo_flatland_000.run_demo(1800)
+    demo_flatland_000 = None
+
+    demo_flatland_000 = Demo(Scenario_Generator.load_scenario('./env-data/railway/example_flatland_001.pkl'))
+    demo_flatland_000.renderer.resize()
+    demo_flatland_000.run_demo(1800)
+    demo_flatland_000 = None
+
+
+demo_flatland_000 = Demo(Scenario_Generator.load_scenario('./env-data/railway/example_network_003.pkl'))
 demo_flatland_000.renderer.resize()
 demo_flatland_000.run_demo(1800)
 demo_flatland_000 = None
diff --git a/flatland/envs/rail_env.py b/flatland/envs/rail_env.py
index e56395f..3fa4a9c 100644
--- a/flatland/envs/rail_env.py
+++ b/flatland/envs/rail_env.py
@@ -201,8 +201,8 @@ class RailEnv(Environment):
                 continue
 
             if self.dones[iAgent]:  # this agent has already completed...
-                print("rail_env.py @", currentframe().f_back.f_lineno, " agent ", iAgent,
-                      "has already completed : why action will not be executed!!!!? ADRIAN")
+                # print("rail_env.py @", currentframe().f_back.f_lineno, " agent ", iAgent,
+                #       "has already completed : why action will not be executed!!!!? ADRIAN")
                 continue
             action = action_dict[iAgent]
 
diff --git a/notebooks/Editor2.ipynb b/notebooks/Editor2.ipynb
index 76f200e..1ed1be6 100644
--- a/notebooks/Editor2.ipynb
+++ b/notebooks/Editor2.ipynb
@@ -9,9 +9,18 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 1,
+   "execution_count": 17,
    "metadata": {},
-   "outputs": [],
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "The autoreload extension is already loaded. To reload it, use:\n",
+      "  %reload_ext autoreload\n"
+     ]
+    }
+   ],
    "source": [
     "%load_ext autoreload\n",
     "%autoreload 2"
@@ -19,7 +28,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 2,
+   "execution_count": 18,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -32,7 +41,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 3,
+   "execution_count": 19,
    "metadata": {},
    "outputs": [
     {
@@ -54,7 +63,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 4,
+   "execution_count": 20,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -63,7 +72,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 5,
+   "execution_count": 21,
    "metadata": {},
    "outputs": [
     {
@@ -98,7 +107,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 6,
+   "execution_count": 22,
    "metadata": {
     "scrolled": false
    },
@@ -106,7 +115,7 @@
     {
      "data": {
       "application/vnd.jupyter.widget-view+json": {
-       "model_id": "e86e118aa3dc4387857ec6bd80a1966b",
+       "model_id": "d412a331f4af4b61a680cc7e79265499",
        "version_major": 2,
        "version_minor": 0
       },
@@ -124,7 +133,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 7,
+   "execution_count": 23,
    "metadata": {
     "scrolled": false
    },
@@ -132,7 +141,7 @@
     {
      "data": {
       "application/vnd.jupyter.widget-view+json": {
-       "model_id": "48a4f97d8d1446f48314d9d72d733d98",
+       "model_id": "125052fec212492e96b6114be02fdce0",
        "version_major": 2,
        "version_minor": 0
       },
@@ -151,7 +160,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 8,
+   "execution_count": 24,
    "metadata": {},
    "outputs": [
     {
@@ -160,7 +169,7 @@
        "(0, 0)"
       ]
      },
-     "execution_count": 8,
+     "execution_count": 24,
      "metadata": {},
      "output_type": "execute_result"
     }
-- 
GitLab