Live data from Hacker News

Show HN: BFS, Dijkstra and A* interactive demo made in React

github.com

11–20 of 23 posts

Re: Show HN: BFS, Dijkstra and A* interactive demo made in React

#11
I think the short summary is: Dijkstra is best when you don't know or care where you're going (there's no heuristic to tell you how close you are, or you want to know distances to all locations), but if that heuristic exists, A* is better.

I once used A* in a coding challenge for a job. Create a grid (in React) where you can place obstacles, wormholes, a start and a finish, and find the shortest route through it. The wormholes normally break A*, but I'd figured out a way to take them into account. Was a fun challenge. (Didn't take the job.)

Re: Show HN: BFS, Dijkstra and A* interactive demo made in React

#13

No discussion of A* etc is complete without a link to red blob games' interactive pages: https://www.redblobgames.com/pathfinding/a-star/introduction...

That was also my introduction to A*. Say, does anyone have insights into optimizing path finding for speed, as the map gets larger and number of entities increases?

Re: Show HN: BFS, Dijkstra and A* interactive demo made in React

#15
post #13

No discussion of A* etc is complete without a link to red blob games' interactive pages: https://www.redblobgames.com/pathfinding/a-star/introduction...

That was also my introduction to A*. Say, does anyone have insights into optimizing path finding for speed, as the map gets larger and number of entities increases?

One method is to preprocess the map, which then can greatly increase the accuracy of the A* heuristic.

https://www.redblobgames.com/pathfinding/l1-clarkson/

Re: Show HN: BFS, Dijkstra and A* interactive demo made in React

#16
post #13

No discussion of A* etc is complete without a link to red blob games' interactive pages: https://www.redblobgames.com/pathfinding/a-star/introduction...

That was also my introduction to A*. Say, does anyone have insights into optimizing path finding for speed, as the map gets larger and number of entities increases?

I would think you could do a scaling of sorts, like if your map was 100x100 you could reduce it to 10x10 with "clear", "fully blocked", and "partially blocked" based on the contents, and work a general path at that meta level first, then focus on each grid map at the full scale to navigate around local obstacles. You could do multiple scales depending on your needs and where the terrain makes sense to categorize most into clear or blocked.

Re: Show HN: BFS, Dijkstra and A* interactive demo made in React

#17
post #11

I think the short summary is: Dijkstra is best when you don't know or care where you're going (there's no heuristic to tell you how close you are, or you want to know distances to all locations), but if that heuristic exists, A* is better. I once used A* in a coding challenge for a job. Create a grid (in React) where you can place obstacles, wormholes, a start and a finish, and find the shortest route through it. The…

Yes, I would like to see more pathfinding demo talking about 0 weight link, or even negative weight (although I don't know of any pathfinding problem that would use negative weight). Floyd–Warshall is always ignored although I think it is cool. Now you can pathfind with portal :)

Re: Show HN: BFS, Dijkstra and A* interactive demo made in React

#18
Same story, made something similar in straight JavaScript while I was at school and never showed it to anyone:

https://jayd.ml/algorithms/search/ (source https://github.com/jaydenmilne/jaydenmilne.github.io/tree/ma...)

Features:

- Draw your own maze!

- Several different algorithms!

- Adjust solving speed / step algorithm!

- Bugs!

- Share your mazes in the URL (abuse link shorteners to store your data! shorturl.at/ioyT9)

I'm quite proud of how I (ab)used async/await to increase the stack size and be able to easily step and delay the algorithms without having to rewrite them to be re-entrant.

(in case you're wondering, left click to draw walls, right click to place start then end node, left click and drag on walls to go into erase mode)

Re: Show HN: BFS, Dijkstra and A* interactive demo made in React

#20
post #2

Two years ago I had to make a project about pathfinding for a university project, and I just realised I never showed it anywhere. I made this little interactive playground for various pathfinding algorithms showing how they can be seen as a general algorithm with different a different queue and different heuristic in use. The readme has some theory but the cool thing is the link to the app on netlify where you can ex…

I think you have a typo in the first introduction popup. It says BSD instead of BFS
Post reply on HN