Js version A * pathfinding Algorithm

Source: Internet
Author: User

When it comes to playing games, it is essential to use the pathfinding algorithm. Generally, most of the pathfinding algorithms in the game are dominated by the * algorithm. Here, a * pathfinding program is used in js, post in 51js and blue.

The program was previously written, and has not been corrected or streamlined. We apologize for any redundancy.

Of course, this pathfinding algorithm is not optimal, like the "intersection pathfinding method" developed by magic Yu is also a medium quality product. The two have their own merits, but if the map is very large, we will be surprised by the speed of the intersection path finding method.
<Html> <pead> <title> use A * to find path... </title> </pead> <body style = "margin: 0px "> </table> set the start point and end point. <input type =" button "onclick =" setPos (); main (); this. disabled = true; "value =" find "> </body> </ptml> <xmp id = xMapData style = display: none> 25, 0; 25, 1; 25, 3; 25, 4; 25, 5;; 6, 13; 25, 13; 5, 14; 21,14; 25, 14; 5, 15; 18, 15; 19,15; hour; 25, 15; 5, 16; 11, 16; hour; 13, 16; 14,16; 15,16; 16,16; 17,16;;; 20; 21; 21; 21; 21;; 22; 22; 22; 22; 22; 22; 22; 22; 22; 22; 22; 22; 22; 22; 23;; hour; 26; 19,28; 19,29; 19,30; 19,31 </xmp> </body> </ptml> <script> a = xMapData. innerHTML. split (";") setFlag (3) for (I = 0; I
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.