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
417f2427
Commit
417f2427
authored
5 years ago
by
spiglerg
Browse files
Options
Downloads
Patches
Plain Diff
Improved docstrings, fixed pylint.
parent
7230431b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
flatland/core/transitions.py
+27
-12
27 additions, 12 deletions
flatland/core/transitions.py
with
27 additions
and
12 deletions
flatland/core/transitions.py
+
27
−
12
View file @
417f2427
...
...
@@ -25,7 +25,7 @@ class Transitions:
Parameters
----------
cell_transition : [cell content]
The object is specific to each derived class
)
e.g., for
The object is specific to each derived class
(
e.g., for
GridTransitions, int), and is only manipulated by methods
of the Transitions derived classes.
orientation : int
...
...
@@ -50,7 +50,7 @@ class Transitions:
Parameters
----------
cell_transition : [cell-content]
The object is specific to each derived class
)
e.g., for
The object is specific to each derived class
(
e.g., for
GridTransitions, int), and is only manipulated by methods
of the Transitions derived classes.
orientation : int
...
...
@@ -79,7 +79,7 @@ class Transitions:
Parameters
----------
cell_transition : [cell-content]
The object is specific to each derived class
)
e.g., for
The object is specific to each derived class
(
e.g., for
GridTransitions, int), and is only manipulated by methods
of the Transitions derived classes.
orientation : int
...
...
@@ -111,7 +111,7 @@ class Transitions:
Parameters
----------
cell_transition : [cell-content]
The object is specific to each derived class
)
e.g., for
The object is specific to each derived class
(
e.g., for
GridTransitions, int), and is only manipulated by methods
of the Transitions derived classes.
orientation : int
...
...
@@ -195,8 +195,8 @@ class GridTransitions(Transitions):
"""
if
self
.
number_of_cell_neighbors
==
4
:
bits
=
(
cell_transition
>>
((
3
-
orientation
)
*
4
))
cell_transition
=
((
bits
>>
3
)
&
1
,
(
bits
>>
2
)
&
1
,
(
bits
>>
1
)
&
1
,
(
bits
)
&
1
)
cell_transition
=
((
bits
>>
3
)
&
1
,
(
bits
>>
2
)
&
1
,
(
bits
>>
1
)
&
1
,
(
bits
)
&
1
)
elif
self
.
number_of_cell_neighbors
==
8
:
bits
=
(
cell_transition
>>
((
7
-
orientation
)
*
8
))
cell_transition
=
(
...
...
@@ -334,14 +334,12 @@ class GridTransitions(Transitions):
cell_transition
|=
\
(
1
<<
((
self
.
number_of_cell_neighbors
-
1
-
orientation
)
*
self
.
number_of_cell_neighbors
+
(
self
.
number_of_cell_neighbors
-
1
-
direction
)))
(
self
.
number_of_cell_neighbors
-
1
-
direction
)))
else
:
cell_transition
&=
\
~
(
1
<<
((
self
.
number_of_cell_neighbors
-
1
-
orientation
)
*
self
.
number_of_cell_neighbors
+
(
self
.
number_of_cell_neighbors
-
1
-
direction
)))
(
self
.
number_of_cell_neighbors
-
1
-
direction
)))
return
cell_transition
...
...
@@ -351,6 +349,23 @@ class GridTransitions(Transitions):
rotation={0, 90, 180, 270} degrees in diagonal steps are not allowed,
or by rotation={0, 45, 90, 135, 180, 225, 270, 315} degrees if
\
they are.
Parameters
----------
cell_transition : int
16 or 64 bits used to encode the valid transitions for a cell.
rotation : int
Angle by which to clock-wise rotate the transition bits in
`cell_transition
'
by. I.e., rotation={0, 90, 180, 270} degrees in
diagonal steps are not allowed, or by
rotation={0, 45, 90, 135, 180, 225, 270, 315} degrees if they are.
Returns
-------
int
An updated bitmap that replaces the original transitions bits
with the equivalent bitmap after rotation.
"""
if
self
.
number_of_cell_neighbors
==
4
:
# Rotate the individual bits in each block
...
...
@@ -400,7 +415,7 @@ class RailEnvTransitions(GridTransitions):
--------------------------------------------------------------------------
As no diagonal transitions are allowed in the RailEnv environment, the
As no diagonal transitions are allowed in the RailEnv environment, the
possible transitions for RailEnv from a cell to its neighboring ones
are represented over 16 bits.
...
...
@@ -434,4 +449,4 @@ class RailEnvTransitions(GridTransitions):
super
(
RailEnvTransitions
,
self
).
__init__
(
transitions
=
self
.
transition_list
,
allow_diagonal_transitions
=
False
)
)
\ No newline at end of file
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