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
Model registry
Operate
Environments
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
yoogottamk
Flatland
Commits
9bbf2ed6
Commit
9bbf2ed6
authored
5 years ago
by
u229589
Browse files
Options
Downloads
Patches
Plain Diff
refactor from nodes to cities
parent
2fab26d2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
flatland/core/grid/grid_utils.py
+7
-5
7 additions, 5 deletions
flatland/core/grid/grid_utils.py
flatland/envs/rail_generators.py
+78
-105
78 additions, 105 deletions
flatland/envs/rail_generators.py
with
85 additions
and
110 deletions
flatland/core/grid/grid_utils.py
+
7
−
5
View file @
9bbf2ed6
...
...
@@ -2,6 +2,8 @@ from typing import Tuple, Callable, List, Type
import
numpy
as
np
from
flatland.core.grid.grid4
import
Grid4TransitionsEnum
Vector2D
:
Type
=
Tuple
[
float
,
float
]
IntVector2D
:
Type
=
Tuple
[
int
,
int
]
...
...
@@ -296,7 +298,7 @@ def distance_on_rail(pos1, pos2, metric="Euclidean"):
return
np
.
abs
(
pos1
[
0
]
-
pos2
[
0
])
+
np
.
abs
(
pos1
[
1
]
-
pos2
[
1
])
def
direction_to_
point
(
pos1
,
pos2
)
:
def
direction_to_
city
(
pos1
:
IntVector2D
,
pos2
:
IntVector2D
)
->
Grid4TransitionsEnum
:
"""
Returns the closest direction orientation of position 2 relative to position 1
:param pos1: position we are interested in
...
...
@@ -308,11 +310,11 @@ def direction_to_point(pos1, pos2):
direction
=
np
.
sign
(
diff_vec
[
axis
])
if
axis
==
0
:
if
direction
>
0
:
return
0
return
Grid4TransitionsEnum
.
NORTH
else
:
return
2
return
Grid4TransitionsEnum
.
SOUTH
else
:
if
direction
>
0
:
return
3
return
Grid4TransitionsEnum
.
WEST
else
:
return
1
return
Grid4TransitionsEnum
.
EAST
This diff is collapsed.
Click to expand it.
flatland/envs/rail_generators.py
+
78
−
105
View file @
9bbf2ed6
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