11from __future__ import annotations
22
33import heapq
4+ from typing import Optional
45
56from rcrs_core .entities .area import Area
67from rcrs_core .worldmodel .entityID import EntityID
@@ -49,10 +50,10 @@ def get_path(
4950 self , from_entity_id : EntityID , to_entity_id : EntityID
5051 ) -> list [EntityID ]:
5152 # ダイクストラ法で最短経路を計算
52- queue = []
53+ queue : list [ tuple [ float , EntityID ]] = []
5354 heapq .heappush (queue , (0 , from_entity_id ))
54- distance = {from_entity_id : 0 }
55- previous = {from_entity_id : None }
55+ distance : dict [ EntityID , float ] = {from_entity_id : 0 }
56+ previous : dict [ EntityID , Optional [ EntityID ]] = {from_entity_id : None }
5657
5758 while queue :
5859 current_distance , current_node = heapq .heappop (queue )
@@ -70,7 +71,7 @@ def get_path(
7071 heapq .heappush (queue , (new_distance , neighbor ))
7172 previous [neighbor ] = current_node
7273
73- path = []
74+ path : list [ EntityID ] = []
7475 current_node = to_entity_id
7576 while current_node is not None :
7677 path .append (current_node )
0 commit comments