PathFinding.js
PathFinding.js copied to clipboard
can we run Pathfinding.js a bit more slowly?
Hi, I have a pathfinding problem to solve using A* algorithm and Best First Search and I am asked to present my answer step-by-step and then compare it to the answer Pathfinding.js would return if we ran the problem here.
The thing is that everything is being executed so quickly and I cannot understand the steps that are being done to compare them with the solutions I found running the algorithms myself.
Is it possible to add start/stop options so as to see algorithm executions step-by-step or maybe slow down time to make the steps appear more clearly?
You can use the debuggers in the modern browsers. E.g. F12 in chrome.
If you only want to show the solution maybe you can run the algorithm multiple times, and every time you can increase move up the path. Example:
- Pre-run the algorithm say from block (0,0) to (8,8)
- print/take note of all the returned blocks
- In your presentation run the algorithm once for each pre-noted block e.g first run for (0, 0), (0,1) etc....
If you want to show the whole search, you can do the same but add a console.log for the neighbours it visits, then you can run it step by step maybe with a window.setInterval