■ in the A * Method Summary
Summary of the * Method
Okay, now When you pass ever Solution Interpretation have been by gone, Let I'm our lay a step-by-step approach in the same place:
Okay, now so you had gone through the explanation, let's lay out of the step-by-step method all in one place:
Add Start Party Block (or Section point) to the open list.
Add the starting square (or node) to the open list.
repeat the following Operation :
Repeat the following:
A) Find the box that opens the minimum F value on the list . We will make this as the current square block .
-
Look for the lowest F cost square on the open list. We refer to this as the current square
b) switch to the closed list.
-
Switch it to the closed list.
c) for each of the 8 blocks of the current block ...
c) For each of the 8 squares adjacent to this current square ...
If you do not can go , or if it's off closed 's name single , ignore it. No , please do the following .
If it's not walkable or if it's on the closed list, ignore it. Otherwise do the following.
if not list, add it to the open list. Make the current party block become this Party Span style= "Font-family:simsun" > block father . record block f , G and H .
If it isn ' t on the open list, add it to the open list. Make the current square the parent of this square. Record the F, G, and H costs of the square.
ifin theOpen the list,Check, seeita path,theSquareBlockis aNo Yesbetter, the use ofGvaluemadeto bemeasure. The LowerGvaluemeans theitis a better path. If it isthis,putthe parent of the squareChangeCurrent PartyBlock, and re-CountCounting PartyBlockof theGvalueand theFvalue. If you keep open list sortFvalue,because of thisChangeyou may need tore-savelist.
If it is in the open list already, check to see if this path to that square are better, using G cost as the measure. A lower G cost means the This is a better path. If So, change the parent of the square to the current square, and recalculate the G and F scores of the square. If you is keeping your open list sorted by F score, you may need to resort the list to account for the change.
D) When you stop:
d) Stop When:
MeshMarkSquareBlockadd to Offclosedlist, initcase, the path has beenbywasfound(Seenote below), orunable to find the targetMarkSquareBlock, and the open list is empty. In theitThe path does not exist in the case.
ADD the target square to the closed list, in which case the path have been found (see note below), or Fail to find the Targ Et square, and the open list is empty. In this case, the there is no path.
Save the path. go back from the target Square block and move from each square block to its parent until you reach the start side block . This is your path.
Save the path. Working backwards from the target square, go from each square to its parent square until you reach the starting square. That is your path.
Note: In earlier versions of thein the article, someone builtdiscussion, when the eyeMarkSquareBlock(orSectionpoint) hasbyAddto the open list, not offclosedlist, you can stop. thisdone would be faster, and it almostTotalis goingGiveyour shortest path, but notTotalis so. somecase,thisdo cancan produce differenceswhen moving from the secondMovingto the last oneSectionpoint to the last (eyeMark)SectionPointof theshippedMovingcost can becan have obviousChangeof-For example,asFruitCrossing the Riverin thetwo xSectionPoint ofRoomthe case.
Note:in earlier versions of this article, it is suggested that you can stop when the target square (or node) has been ad Ded to the open list, rather than the closed list. Doing this'll be faster and it'll almost always give you the shortest path, but don't always. Situations where doing this could make a difference is when the movement cost-to-move from the second to the last node to The last (target) node can vary significantly – as in the case of a river crossing between and nodes, for example.
■ Little Growl
Small Rant
PleaseOriginalForgivemy ownQuestionsoutsidewords, butvalueto point out is that when you're on the InternetReadof theAPath Search, and in eachClass Forumon the variousduring discussion, you even, eryou'll see someone mention some generationsCodeis notA. theinAto use the method, you need to include the abovediscussionto the element--SpecialDon'tis openListand offclosedListand path AdoptionFvalue,Gvalueand theHvalues. There are a lot of otherPath Searchalgorithm, but the otheris usuallyThinkis the best way not toA. In theitat the end of the articlehave aBleinstortdiscussion, including hisourSome of the pros and cons cite a lot of articles. Have awhenalternatives are better in some cases, but youshould beunderstand that you areintoin. Okay,it's cool.. Back toTopic.
Forgive me for digressing, but it's worth pointing out if you read various discussions of a * pathfinding on the We B and in assorted forums, you'll occasionally see someone refer to certain code as a * when it isn ' t. For the * method to is used, need to include the elements just discussed above--specifically open and closed lists and path scoring using F, G, and H. There was lots of other pathfinding algorithms, but those other methods was not a *, which was generally considered to be th e Best of the lot. Bryan Stout discusses many of them in the article referenced during the end of this article, including some of their pros and Cons. Sometimes alternatives is better under certain circumstances, but you should understand what is getting into. Okay, enough ranting. Back to the article.
adjourned
Re-translation of the "A * Path Search Primer" four