Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Flatland
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elrichgro
Flatland
Commits
71aea64e
Commit
71aea64e
authored
5 years ago
by
maljx
Browse files
Options
Downloads
Patches
Plain Diff
complex rail gen: added extra connections
parent
417678af
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/play_model.py
+1
-1
1 addition, 1 deletion
examples/play_model.py
flatland/envs/generators.py
+22
-2
22 additions, 2 deletions
flatland/envs/generators.py
with
23 additions
and
3 deletions
examples/play_model.py
+
1
−
1
View file @
71aea64e
...
@@ -97,7 +97,7 @@ def main(render=True, delay=0.0):
...
@@ -97,7 +97,7 @@ def main(render=True, delay=0.0):
# Example generate a random rail
# Example generate a random rail
env
=
RailEnv
(
width
=
15
,
height
=
15
,
env
=
RailEnv
(
width
=
15
,
height
=
15
,
rail_generator
=
complex_rail_generator
(
nr_start_goal
=
20
,
min_dist
=
12
),
rail_generator
=
complex_rail_generator
(
nr_start_goal
=
5
,
nr_extra
=
20
,
min_dist
=
12
),
number_of_agents
=
5
)
number_of_agents
=
5
)
if
render
:
if
render
:
...
...
This diff is collapsed.
Click to expand it.
flatland/envs/generators.py
+
22
−
2
View file @
71aea64e
...
@@ -9,7 +9,7 @@ from flatland.envs.env_utils import distance_on_rail, connect_rail, get_directio
...
@@ -9,7 +9,7 @@ from flatland.envs.env_utils import distance_on_rail, connect_rail, get_directio
from
flatland.envs.env_utils
import
get_rnd_agents_pos_tgt_dir_on_rail
from
flatland.envs.env_utils
import
get_rnd_agents_pos_tgt_dir_on_rail
def
complex_rail_generator
(
nr_start_goal
=
1
,
min_dist
=
2
,
max_dist
=
99999
,
seed
=
0
):
def
complex_rail_generator
(
nr_start_goal
=
1
,
nr_extra
=
10
,
min_dist
=
2
,
max_dist
=
99999
,
seed
=
0
):
"""
"""
Parameters
Parameters
-------
-------
...
@@ -123,7 +123,27 @@ def complex_rail_generator(nr_start_goal=1, min_dist=2, max_dist=99999, seed=0):
...
@@ -123,7 +123,27 @@ def complex_rail_generator(nr_start_goal=1, min_dist=2, max_dist=99999, seed=0):
# print("failed...")
# print("failed...")
created_sanity
+=
1
created_sanity
+=
1
print
(
"
\n
> Complex Rail Gen: Created #
"
,
len
(
start_goal
),
"
pairs
"
)
# add extra connections between existing rail
created_sanity
=
0
nr_created
=
0
while
nr_created
<
nr_extra
and
created_sanity
<
sanity_max
:
all_ok
=
False
for
_
in
range
(
sanity_max
):
start
=
(
np
.
random
.
randint
(
0
,
width
),
np
.
random
.
randint
(
0
,
height
))
goal
=
(
np
.
random
.
randint
(
0
,
height
),
np
.
random
.
randint
(
0
,
height
))
# check to make sure start,goal pos are not empty
if
rail_array
[
goal
]
==
0
or
rail_array
[
start
]
==
0
:
continue
else
:
all_ok
=
True
break
if
not
all_ok
:
break
new_path
=
connect_rail
(
rail_trans
,
rail_array
,
start
,
goal
)
if
len
(
new_path
)
>=
2
:
nr_created
+=
1
print
(
"
\n
> Complex Rail Gen: Created #
"
,
len
(
start_goal
),
"
pairs and #
"
,
nr_created
,
"
extra connections
"
)
# print(start_goal)
# print(start_goal)
agents_position
=
[
sg
[
0
]
for
sg
in
start_goal
]
agents_position
=
[
sg
[
0
]
for
sg
in
start_goal
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment