Skip to content
Snippets Groups Projects
Commit 556875b0 authored by hagrid67's avatar hagrid67
Browse files

updated import for random_rail_generator in Simple_Rendering_Demo.ipynb

parent dbe5c995
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# Plot the Env and some trees # Plot the Env and some trees
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
%load_ext autoreload %load_ext autoreload
%autoreload 2 %autoreload 2
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
import jpy_canvas import jpy_canvas
import random import random
import time import time
import sys import sys
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
# in case you need to tweak your PYTHONPATH... # in case you need to tweak your PYTHONPATH...
sys.path.append("../flatland") sys.path.append("../flatland")
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
import flatland.core.env import flatland.core.env
import flatland.utils.rendertools as rt import flatland.utils.rendertools as rt
from flatland.envs.rail_env import RailEnv, random_rail_generator from flatland.envs.rail_env import RailEnv
from flatland.envs.rail_generators import random_rail_generator
from flatland.envs.observations import TreeObsForRailEnv from flatland.envs.observations import TreeObsForRailEnv
from flatland.envs.predictions import ShortestPathPredictorForRailEnv from flatland.envs.predictions import ShortestPathPredictorForRailEnv
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
from IPython.core.display import display, HTML from IPython.core.display import display, HTML
display(HTML("<style>.container { width:90% !important; }</style>")) display(HTML("<style>.container { width:90% !important; }</style>"))
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# Generate # Generate
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
nAgents = 3 nAgents = 3
fnMethod = random_rail_generator(cell_type_relative_proportion=[1] * 11) fnMethod = random_rail_generator(cell_type_relative_proportion=[1] * 11)
env = RailEnv(width=20, env = RailEnv(width=20,
height=10, height=10,
rail_generator=fnMethod, rail_generator=fnMethod,
number_of_agents=nAgents, number_of_agents=nAgents,
obs_builder_object=TreeObsForRailEnv(max_depth=3, predictor=ShortestPathPredictorForRailEnv())) obs_builder_object=TreeObsForRailEnv(max_depth=3, predictor=ShortestPathPredictorForRailEnv()))
env.reset() env.reset()
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# Render # Render
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
oRT = rt.RenderTool(env,gl="PILSVG") oRT = rt.RenderTool(env,gl="PILSVG")
oRT.render_env(show_observations=False,show_predictions=True) oRT.render_env(show_observations=False,show_predictions=True)
img = oRT.get_image() img = oRT.get_image()
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
jpy_canvas.Canvas(img) jpy_canvas.Canvas(img)
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
oRT = rt.RenderTool(env,gl="PIL") oRT = rt.RenderTool(env,gl="PIL")
oRT.render_env(show_observations=False,show_predictions=True) oRT.render_env(show_observations=False,show_predictions=True)
img = oRT.get_image() img = oRT.get_image()
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
jpy_canvas.Canvas(img) jpy_canvas.Canvas(img)
``` ```
......
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