I'米試圖執行A *搜索算法在Java中,我有一個問題:A *搜索算法確定循環變量時,不存在路徑
多少次,我需要運行一個A *循環,直到沒有明顯的路徑?
例如:如果我有一個for循環; 「我」應該增加多久?
I'米試圖執行A *搜索算法在Java中,我有一個問題:A *搜索算法確定循環變量時,不存在路徑
多少次,我需要運行一個A *循環,直到沒有明顯的路徑?
例如:如果我有一個for循環; 「我」應該增加多久?
當你探索到所有可以用A *到達的節點時,如果沒有找到目標,那麼你可以假設沒有路徑。
所以,實際上如果所有現有的節點都添加到一個閉合列表中,對吧? – user2115390 2013-02-27 13:10:30
您不能確定A *會考慮所有節點:如果沒有路徑,某些節點將不會添加到封閉列表中。你應該更好地考慮開放列表:如果它是空的,如果你沒有找到路徑,那麼就沒有路徑。 – Fitz 2013-02-27 13:15:30
我想你是在考慮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.
謝謝你,這有助於我重新調整我對這個問題的想法。 – user2115390 2013-02-27 13:15:19
42'i'應始終小於或等於42 – 2013-02-27 13:07:09
問題需要更具體的,如果人們提供幫助。你提供的信息太少,以至於你的問題真的無法回答。 – 2013-02-27 13:21:05