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 Binary files /dev/null and b/env-data/railway/example_flatland_001.pkl differ 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 Binary files /dev/null and b/env-data/railway/example_network_003.pkl differ diff --git a/examples/demo.py b/examples/demo.py index 105396cf9977b3855dd39468880ad839ce41a4a0..9abfa59bd194f74a2f5ddfa4eccea6ab31bcd045 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 e56395f4220ee7b7639a7fa79df1ce88796132c5..3fa4a9cdc6c014995bc56ef07e021fc689df69a6 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 76f200ee2c87df268a39ae2bd00bfafe1ec06719..1ed1be63d11a8ad3e92454cfa3b252553a99be28 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" }