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
sfwatergit
Flatland
Commits
0933d128
Commit
0933d128
authored
5 years ago
by
spmohanty
Browse files
Options
Downloads
Patches
Plain Diff
Add RailEnvTransitions as a separate derived class
parent
05f6003f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
flatland/core/transitions.py
+40
-36
40 additions, 36 deletions
flatland/core/transitions.py
with
40 additions
and
36 deletions
flatland/core/transitions.py
+
40
−
36
View file @
0933d128
...
@@ -229,46 +229,50 @@ class GridTransitions(Transitions):
...
@@ -229,46 +229,50 @@ class GridTransitions(Transitions):
return
cell_transition
return
cell_transition
"""
class
RailEnvTransitions
(
GridTransitions
):
Special case of `GridTransitions
'
over a 2D-grid, with a pre-defined set
"""
of transitions mimicking the types of real Swiss rail connections.
Special case of `GridTransitions
'
over a 2D-grid, with a pre-defined set
of transitions mimicking the types of real Swiss rail connections.
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
The possible transitions for RailEnv from a cell to its neighboring ones
The possible transitions for RailEnv from a cell to its neighboring ones
are represented over 16 bits.
are represented over 16 bits.
Whether a transition is allowed or not depends on which direction an agent
Whether a transition is allowed or not depends on which direction an agent
inside the cell is facing (0=North, 1=East, 2=South, 3=West) and which
inside the cell is facing (0=North, 1=East, 2=South, 3=West) and which
direction the agent wants to move to
direction the agent wants to move to
(North, East, South, West, relative to the cell).
(North, East, South, West, relative to the cell).
Each transition (orientation, direction) can be allowed (1) or forbidden (0).
Each transition (orientation, direction) can be allowed (1) or forbidden (0).
The 16 bits are organized in 4 blocks of 4 bits each, the direction that
The 16 bits are organized in 4 blocks of 4 bits each, the direction that
the agent is facing.
the agent is facing.
E.g., the most-significant 4-bits represent the possible movements (NESW)
E.g., the most-significant 4-bits represent the possible movements (NESW)
if the agent is facing North, etc...
if the agent is facing North, etc...
agent
'
s direction: North East South West
agent
'
s direction: North East South West
agent
'
s allowed movements: [nesw] [nesw] [nesw] [nesw]
agent
'
s allowed movements: [nesw] [nesw] [nesw] [nesw]
example: 0010 0000 1000 0000
example: 0010 0000 1000 0000
In the example, the agent can move from North to South and viceversa.
In the example, the agent can move from North to South and viceversa.
"""
"""
"""
"""
transitions[] is indexed by case type/id, and returns the 4x4-bit [NESW]
transitions[] is indexed by case type/id, and returns the 4x4-bit [NESW]
transitions available as a function of the agent
'
s orientation
transitions available as a function of the agent
'
s orientation
(north, east, south, west)
(north, east, south, west)
"""
"""
RailEnvTransitionsList
=
[
int
(
'
0000000000000000
'
,
2
),
transition_list
=
[
int
(
'
0000000000000000
'
,
2
),
int
(
'
1000000000100000
'
,
2
),
int
(
'
1000000000100000
'
,
2
),
int
(
'
1001001000100000
'
,
2
),
int
(
'
1001001000100000
'
,
2
),
int
(
'
1000010000100001
'
,
2
),
int
(
'
1000010000100001
'
,
2
),
int
(
'
1001011000100001
'
,
2
),
int
(
'
1001011000100001
'
,
2
),
int
(
'
1100110000110011
'
,
2
),
int
(
'
1100110000110011
'
,
2
),
int
(
'
0101001000000010
'
,
2
),
int
(
'
0101001000000010
'
,
2
),
int
(
'
0000000000100000
'
,
2
)]
int
(
'
0000000000100000
'
,
2
)]
RailEnvTransitions
=
GridTransitions
(
transitions
=
RailEnvTransitionsList
,
def
__init__
(
self
):
allow_diagonal_transitions
=
False
)
super
(
RailEnvTransitions
,
self
).
__init__
(
transitions
=
self
.
transition_list
,
allow_diagonal_transitions
=
False
)
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