Topdown Pathfinding/Enemy 'AI' that avoids walls

Hey guys, I got a bit bored and wanted to try learning something new to enhance my knowledge of JavaScript. So, I decided to program the A* pathfinding algorithm in Wick Editor for people to use and mess around with. (mainly because I’m working on a game and want enemies to avoid walls lol)

If you’re unfamiliar with the A* pathfinding algorithm, it basically finds an area with the lowest value, adds it to a list, and then loops through that list to create a path. For more information about the A* pathfinding algorithm, you can check out these two videos I watched that helped me with this project: video 1, video 2.

It took me some time to make this project, but it was definitely worth it and a lot of fun in the process. Here’s the Wick file for the pathfinding project (the code might be a bit messy, but at least it works!): A* Pathfinding.wick (By the way, if you’re getting some sort of lag, disabling the nodes and paths helps).
The goal is basically to get point A to point B

If you’d like to see it in action (more specifically an ‘enemy’ moving around), you can check out this file:A* Pathfinding demo.wick
Oh, and here is some information I found in the forums that was really helpful while I was working on this project:

By the way, please don’t steal any code, and if you plan to use this pathfinding code, at least give me some credit. (I put a lot of effort into it lol).

And another thing, this project is designed for ‘readability’ and ‘functionality,’ even though it’s a bit buggy, lol. So, you might encounter some performance issues with it. But you can always optimize it yourself. If you have any tips or anything in mind regarding the code, please let me know! :)

1 Like