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
87776b32
Commit
87776b32
authored
5 years ago
by
u214892
Browse files
Options
Downloads
Patches
Plain Diff
a_star with sets instead of lists: cleanup
parent
ab5134b2
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/envs/env_utils.py
+11
-11
11 additions, 11 deletions
flatland/envs/env_utils.py
with
11 additions
and
11 deletions
flatland/envs/env_utils.py
+
11
−
11
View file @
87776b32
...
...
@@ -108,14 +108,14 @@ def a_star(rail_trans, rail_array, start, end):
rail_shape
=
rail_array
.
shape
start_node
=
AStarNode
(
None
,
start
)
end_node
=
AStarNode
(
None
,
end
)
open_
list
=
set
()
closed_
list
=
set
()
open_
list
.
add
(
start_node
)
open_
=
set
()
closed_
=
set
()
open_
.
add
(
start_node
)
while
len
(
open_
list
)
>
0
:
while
len
(
open_
)
>
0
:
# get node with current shortest est. path (lowest f)
current_node
=
None
for
i
ndex
,
item
in
enumerate
(
open_list
)
:
for
i
tem
in
open_
:
if
current_node
is
None
:
current_node
=
item
continue
...
...
@@ -123,8 +123,8 @@ def a_star(rail_trans, rail_array, start, end):
current_node
=
item
# pop current off open list, add to closed list
open_
list
.
remove
(
current_node
)
closed_
list
.
add
(
current_node
)
open_
.
remove
(
current_node
)
closed_
.
add
(
current_node
)
# found the goal
if
current_node
==
end_node
:
...
...
@@ -161,7 +161,7 @@ def a_star(rail_trans, rail_array, start, end):
# loop through children
for
child
in
children
:
# already in closed list?
if
child
in
closed_
list
:
if
child
in
closed_
:
continue
# create the f, g, and h values
...
...
@@ -174,14 +174,14 @@ def a_star(rail_trans, rail_array, start, end):
child
.
f
=
child
.
g
+
child
.
h
# already in the open list?
if
child
in
open_
list
:
if
child
in
open_
:
continue
# add the child to the open list
open_
list
.
add
(
child
)
open_
.
add
(
child
)
# no full path found
if
len
(
open_
list
)
==
0
:
if
len
(
open_
)
==
0
:
return
[]
...
...
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