Skip to content
Snippets Groups Projects
Commit b4ceb107 authored by u214892's avatar u214892
Browse files

k-dikjstra fix to make it deterministic

parent 0d73b7a8
No related branches found
No related tags found
No related merge requests found
...@@ -311,7 +311,8 @@ def get_k_shortest_paths(env: RailEnv, ...@@ -311,7 +311,8 @@ def get_k_shortest_paths(env: RailEnv,
count = {(r, c, d): 0 for r in range(env.height) for c in range(env.width) for d in range(4)} count = {(r, c, d): 0 for r in range(env.height) for c in range(env.width) for d in range(4)}
# B is a heap data structure containing paths # B is a heap data structure containing paths
heap: Set[Tuple[WayPoint]] = set() # N.B. use OrderedSet to make result deterministic!
heap: OrderedSet[Tuple[WayPoint]] = OrderedSet()
# insert path Ps = {s} into B with cost 0 # insert path Ps = {s} into B with cost 0
heap.add((WayPoint(source_position, source_direction),)) heap.add((WayPoint(source_position, source_direction),))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment