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
68cd6d91
Commit
68cd6d91
authored
5 years ago
by
u214892
Browse files
Options
Downloads
Patches
Plain Diff
a_star with sets instead of lists: cleanup
parent
0304a317
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
+2
-13
2 additions, 13 deletions
flatland/envs/env_utils.py
with
2 additions
and
13 deletions
flatland/envs/env_utils.py
+
2
−
13
View file @
68cd6d91
...
@@ -54,7 +54,6 @@ def validate_new_transition(rail_trans, rail_array, prev_pos, current_pos, new_p
...
@@ -54,7 +54,6 @@ def validate_new_transition(rail_trans, rail_array, prev_pos, current_pos, new_p
else
:
else
:
# check if matches existing layout
# check if matches existing layout
new_trans
=
rail_trans
.
set_transition
(
new_trans
,
current_dir
,
new_dir
,
1
)
new_trans
=
rail_trans
.
set_transition
(
new_trans
,
current_dir
,
new_dir
,
1
)
# new_trans = rail_trans.set_transition(new_trans, mirror(new_dir), mirror(current_dir), 1)
else
:
else
:
# set the forward path
# set the forward path
new_trans
=
rail_trans
.
set_transition
(
new_trans
,
current_dir
,
new_dir
,
1
)
new_trans
=
rail_trans
.
set_transition
(
new_trans
,
current_dir
,
new_dir
,
1
)
...
@@ -69,7 +68,6 @@ def validate_new_transition(rail_trans, rail_array, prev_pos, current_pos, new_p
...
@@ -69,7 +68,6 @@ def validate_new_transition(rail_trans, rail_array, prev_pos, current_pos, new_p
else
:
else
:
# check if matches existing layout
# check if matches existing layout
new_trans_e
=
rail_trans
.
set_transition
(
new_trans_e
,
new_dir
,
new_dir
,
1
)
new_trans_e
=
rail_trans
.
set_transition
(
new_trans_e
,
new_dir
,
new_dir
,
1
)
# new_trans_e = rail_trans.set_transition(new_trans_e, mirror(new_dir), mirror(new_dir), 1)
if
not
rail_trans
.
is_valid
(
new_trans_e
):
if
not
rail_trans
.
is_valid
(
new_trans_e
):
return
False
return
False
...
@@ -114,12 +112,6 @@ def a_star(rail_trans, rail_array, start, end):
...
@@ -114,12 +112,6 @@ def a_star(rail_trans, rail_array, start, end):
closed_list
=
set
()
closed_list
=
set
()
open_list
.
add
(
start_node
)
open_list
.
add
(
start_node
)
# this could be optimized
def
is_node_in_list
(
node
,
the_list
):
if
node
in
the_list
:
return
node
return
None
while
len
(
open_list
)
>
0
:
while
len
(
open_list
)
>
0
:
# get node with current shortest est. path (lowest f)
# get node with current shortest est. path (lowest f)
current_node
=
None
current_node
=
None
...
@@ -169,8 +161,7 @@ def a_star(rail_trans, rail_array, start, end):
...
@@ -169,8 +161,7 @@ def a_star(rail_trans, rail_array, start, end):
# loop through children
# loop through children
for
child
in
children
:
for
child
in
children
:
# already in closed list?
# already in closed list?
closed_node
=
is_node_in_list
(
child
,
closed_list
)
if
child
in
closed_list
:
if
closed_node
is
not
None
:
continue
continue
# create the f, g, and h values
# create the f, g, and h values
...
@@ -183,9 +174,7 @@ def a_star(rail_trans, rail_array, start, end):
...
@@ -183,9 +174,7 @@ def a_star(rail_trans, rail_array, start, end):
child
.
f
=
child
.
g
+
child
.
h
child
.
f
=
child
.
g
+
child
.
h
# already in the open list?
# already in the open list?
open_node
=
is_node_in_list
(
child
,
open_list
)
if
child
in
open_list
:
if
open_node
is
not
None
:
open_node
.
update_if_better
(
child
)
continue
continue
# add the child to the open list
# add the child to the open list
...
...
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