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
pranjal_dhole
Flatland
Commits
bfd5b51c
Commit
bfd5b51c
authored
4 years ago
by
hagrid67
Browse files
Options
Downloads
Patches
Plain Diff
manually merging Adrian's changes (made by Erik) from master - forgot one
parent
9d28be8f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
flatland/core/grid/grid4_utils.py
+2
-10
2 additions, 10 deletions
flatland/core/grid/grid4_utils.py
with
2 additions
and
10 deletions
flatland/core/grid/grid4_utils.py
+
2
−
10
View file @
bfd5b51c
...
...
@@ -25,17 +25,9 @@ def get_direction(pos1: IntVector2D, pos2: IntVector2D) -> Grid4TransitionsEnum:
def
mirror
(
dir
):
return
(
dir
+
2
)
%
4
MOVEMENT_ARRAY
=
[(
-
1
,
0
),
(
0
,
1
),
(
1
,
0
),
(
0
,
-
1
)]
def
get_new_position
(
position
,
movement
):
"""
Utility function that converts a compass movement over a 2D grid to new positions (r, c).
"""
if
movement
==
Grid4TransitionsEnum
.
NORTH
:
return
(
position
[
0
]
-
1
,
position
[
1
])
elif
movement
==
Grid4TransitionsEnum
.
EAST
:
return
(
position
[
0
],
position
[
1
]
+
1
)
elif
movement
==
Grid4TransitionsEnum
.
SOUTH
:
return
(
position
[
0
]
+
1
,
position
[
1
])
elif
movement
==
Grid4TransitionsEnum
.
WEST
:
return
(
position
[
0
],
position
[
1
]
-
1
)
return
(
position
[
0
]
+
MOVEMENT_ARRAY
[
movement
][
0
],
position
[
1
]
+
MOVEMENT_ARRAY
[
movement
][
1
])
def
direction_to_point
(
pos1
:
IntVector2D
,
pos2
:
IntVector2D
)
->
Grid4TransitionsEnum
:
...
...
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