{"id":8,"date":"2003-07-16T12:08:16","date_gmt":"2003-07-16T19:08:16","guid":{"rendered":"http:\/\/newsfeed.fatorcaos.com.br\/wp\/?p=8"},"modified":"2006-09-13T12:38:22","modified_gmt":"2006-09-13T19:38:22","slug":"flash-pathfinding-prototype","status":"publish","type":"post","link":"https:\/\/labs.zeh.com.br\/blog\/?p=8","title":{"rendered":"Flash pathfinding prototype"},"content":{"rendered":"<p>After all kinds of tweaking, I&#8217;ve finally finished a more or less fast and stable pathfinding algorithm in Flash. It&#8217;s a prototype (well, just a function in fact) in which you pass a map, a start point and an end point as parameters and it returns an array containing the best path between the two routes. It takes into consideration terrain costs (terrains that are &#8220;cheaper&#8221; to travel by) and, of course, walls and obstacles. You can find the function <a href=\"http:\/\/proto.layer51.com\/d.aspx?f=998\">here<\/a>, along with a syntax explanation.<\/p>\n<p>I&#8217;ve always seen pathfinding as being one of the big secrets of gaming AI. I had more or less knowledge of how it was done, but never had to implement it fully. In this case, using <a href=\"http:\/\/www.policyalmanac.org\/games\/aStarTutorial.htm\">a very simple yet complete explanation of an A* algorithm<\/a>, I was able to build a working prototype (in the old meaning of the word) in no time with cute-looking squares, and after it was complete, decided to start another version from scratch using only arrays and objects and functions and such (and that&#8217;s the version which&#8217;s linked above). It&#8217;s one of those things that, after you actually finish it, you think it&#8217;s so simple you didn&#8217;t have to spend so much time thinking on how difficult it would be to create it.<\/p>\n<p>I&#8217;ve also created a small example using a screenshot from Advance Wars, a popular GBA game and a small addiction of mine sometime ago. <a href=\"http:\/\/www.fatorcaos.com.br\/imagedisplay.php?i=data\/newastar4_1.swf&#038;pw=480&#038;ph=320&#038;bg=ffffff&#038;f=s\">In this example<\/a>, clicking a place on the map will trace the best route the soldier can use to reach that square, taking into consideration that terrains are hard to travel by, roads are easier, and forest or mountains are much more difficult. This background image was stolen <a href=\"http:\/\/www3.brinkster.com\/ircweb\/AW\/\">from this site<\/a> which hosts an Advance Wars map editor.<\/p>\n<p>I&#8217;m still optimizing the pathfinding routines; actually I&#8217;ve managed to save 80% of the execution time on the past few internal versions of the function. Suggestions would be appreciated, though.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>After all kinds of tweaking, I&#8217;ve finally finished a more or less fast and stable pathfinding algorithm in Flash. It&#8217;s a prototype (well, just a function in fact) in which you pass a map, a start point and an end point as parameters and it returns an array containing the best path between the two [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[17,2,3],"tags":[],"_links":{"self":[{"href":"https:\/\/labs.zeh.com.br\/blog\/index.php?rest_route=\/wp\/v2\/posts\/8"}],"collection":[{"href":"https:\/\/labs.zeh.com.br\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/labs.zeh.com.br\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/labs.zeh.com.br\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/labs.zeh.com.br\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8"}],"version-history":[{"count":0,"href":"https:\/\/labs.zeh.com.br\/blog\/index.php?rest_route=\/wp\/v2\/posts\/8\/revisions"}],"wp:attachment":[{"href":"https:\/\/labs.zeh.com.br\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/labs.zeh.com.br\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/labs.zeh.com.br\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}