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]