Advertisement

A* algorithm.. Need some help in explaining :((

Started by August 20, 2000 10:19 PM
-1 comments, last by HellRiZZer 24 years, 3 months ago
Ok, how to calculate total estimated or any other costs? Like in http://www.kanding.dk/Astar.html there is an example, but how to implement it into VB or C++?? Without all those weird heuristic functions ? I think it''s like thatplease correct me if I''m wrong) All I''m dialing with walkable and non-walkable tiles. Firstly, we look all around starting position and calculate total cost like that: (Startx, starty, endx, endy,total,Found,maparray(x,y) - my map, mapway(x,y) - my temp array for variables) - variables to use ''Loading all surrounding values to temp array say,startx=3, endx=5,starty=5, endy=7 total=abs(startx-endx) + abs(starty-endy) For x=startx-1 to startx+1 for y=starty-1 to starty+1 current=abs(x-endx) + abs(y-endy) mapway(x,y)=current if currentTrue For x=startx-1 to startx+1 For y=starty-1 to starty+1 if mapway(x,y)=total then if maparray(,xy)=0 then startx=x starty=y Found=True else total=total+1 endif end if next next loop I think that this is the simplest type - but, if someone can, please reply with a better one with value because I didn''t get them. OK?? And I''ll give you the answer for the rotating algorithm - like 0 1 2 7 C 3 6 5 4 Where C is your character and what the best way to rotate him to get to any side with minimum turns. Of course, if you do know this algo, then it wouldn''t be useful for you. I did it myself, but still can''t do A* star algorithm. THANKS!!

This topic is closed to new replies.

Advertisement