0

JavaでA*検索アルゴリズムを実装しようとしていますが、質問があります。

明らかに既存のパスがなくなるまで、A *ループを何回実行する必要がありますか?

例:forループがある場合; 「i」はどのくらい長くする必要がありますか?

4

2 に答える 2

2

目標を見つけずに、A* で到達できるすべてのノードを探索したら、パスがないと見なすことができます。

于 2013-02-27T13:08:01.857 に答える
1

あなたは A* を間違った方法で考えていると思います。検索するノードがなくなるまで実行します。それまでに目標に到達していない場合、道はありません。

擬似:

//Our list of still open nodes
List<Node> nodesToSearch = new List<Node>(); 
while (nodesToSearch.Count > 0)
{
   //SearchNode, if its our target we are done

   //Add reachable neighbours to the list of nodes to search. So next iteration we will continue on searching those
   //Remove current node.. since its searched
}
//If we end up here without a target there is no path. 
//That means we have searched all nodes and their neighbours etc etc etc. Without reaching the target.
于 2013-02-27T13:08:48.653 に答える