-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNotesAndThoughts.txt
More file actions
26 lines (22 loc) · 2.46 KB
/
NotesAndThoughts.txt
File metadata and controls
26 lines (22 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
stuff about other pathfinding visualizers I dont like:
- Web-based visualizers:
- Spaces between divs allow for you to click between the divs and then dragging no longer creates obstacles. Annoying glitch.
- On all visualizers I found, if you click and hold to draw obstacles, move cursor out of div field, release mouse, then drag mouse back into div field, you are still drawing even though your mouse button is released.
- Visualizers made in java:
- Not easily accessible from any computer, since you have to download the jar file to run it.
What I want to make:
- Web-based visualizer (for easy accessibility)
- No space between tiles (no annoying misclicks possible)
- Stop drawing when you release mouse OR your cursor exits the draw area to prevent drawing when you don't want to be drawing
Problems/Solutions
- Animation/setTimeout not working properly
- Solution: Had to reset the "isVisited" values of all the nodes since the dijkstra algorithm set the visited parameter of visited nodes to true, so when the animation went to set them, they were already true, hence no animation, they appeared instantly.
- Dijkstra's algorithm wouldn't work after clearing the grid
- Problem: the code I went off of from https://github.com/clementmihailescu/Pathfinding-Visualizer-Tutorial/blob/master/src/algorithms/dijkstra.js had "currentNode !== null" as the condition for the while loop in the "getNodesInShortestPathOrder" function, which caused my program to jump back and forth between two nodes indefinitely for some reason
- Solution: I changed that line to be "currentNode !== START_NODE" so that when the path reached the start node, it would terminate.
- Drawing the start node while hovering was too slow
- Problem: I tried drawing the start node under your cursor before you placed it so it would appear you were dragging and dropping it, but re-drawing the entire canvas was too expensive and made the program run very slow
- Solution: Instead of re-drawing the entire canvas each time, I only updated it when the cursor changed cells, and I made the new cell green and the old cell white. Huge increase in performance.
- Weird coordinate errors on grid
- Problem: Some elements were had mirrored coordinates on the grid, or had different coordinates in calculation than graphically
- Solution: I ran into problems trying to convert between (x, y) and (row, col) constantly since they are flipped, so I converted everything to use (row, col).