एक * खोज एल्गोरिथ्म
(से: https://en.wikipedia.org/wiki/A*_search_algorithm)
निम्नलिखित स्यूडोकोड एल्गोरिथ्म का वर्णन करता है [संदिग्ध - पर चर्चा]:
function A*(start,goal)
ClosedSet := {} // The set of nodes already evaluated.
OpenSet := {start} // The set of tentative nodes to be evaluated, initially containing the start node
Came_From := the empty map // The map of navigated nodes.
g_score := map with default value of Infinity
g_score[start] := 0 // Cost from start along best known path.
// Estimated total cost from start to goal through y.
f_score := map with default value of Infinity
f_score[start] := g_score[start] + heuristic_cost_estimate(start, goal)
while OpenSet is not empty
current := the node in OpenSet having the lowest f_score[] value
if current = goal
return reconstruct_path(Came_From, goal)
OpenSet.Remove(current)
ClosedSet.Add(current)
for each neighbor of current
if neighbor in ClosedSet
continue // Ignore the neighbor which is already evaluated.
tentative_g_score := g_score[current] + dist_between(current,neighbor) // length of this path.
if neighbor not in OpenSet // Discover a new node
OpenSet.Add(neighbor)
else if tentative_g_score >= g_score[neighbor]
continue // This is not a better path.
// This path is the best until now. Record it!
Came_From[neighbor] := current
g_score[neighbor] := tentative_g_score
f_score[neighbor] := g_score[neighbor] + heuristic_cost_estimate(neighbor, goal)
return failure
function reconstruct_path(Came_From,current)
total_path := [current]
while current in Came_From.Keys:
current := Came_From[current]
total_path.append(current)
return total_path
इसलिए, जहाँ तक मैं समझता हूं - आप अपने प्रारंभ नोड को लाल बिंदु स्थिति \ केंद्र स्थिति पर सेट कर सकते हैं, और लक्ष्य नोड x = 0 या y = 0 या x = 8 या y = 8 (आप 4 फ़ंक्शन कॉल कर सकते हैं, और न्यूनतम ले सकते हैं)
नोड के लिए ह्युरिस्टिक मूल्यों के लिए - केवल काले अवरुद्ध नोड्स को बहुत अधिक ह्युरिस्टिक मूल्यों को सेट करें, जो उन्हें पहुंचने योग्य नहीं बनाएगा, तो एल्गोरिदम उनके चारों ओर गुजर जाएगा।
स्रोत
2015-11-07 13:16:54
"पथ" का क्या गठन होता है? क्या आप कुछ उदाहरण दे सकते हैं? एक सुंदर तस्वीर सहित सवाल पर उपरोक्त। –
इसका क्या अर्थ है? गंतव्य - मैट्रिक्स की सीमा [जिसका अर्थ है x = 0 या y = 0 या x = 9 या y = 9] 9 सफल चालें? –
संपादन में उदाहरण देखें। लाल बिंदु को भूलभुलैया की सीमा पर पहुंचना है। – jpm