JonasStjerne / resilient-pathfinding

Risk-Aware Path Finding Algorithm
https://p7-xi.vercel.app
0 stars 0 forks source link

Node id increment with 100 after loading from localstorage or resetting it. #60

Open JonasStjerne opened 11 months ago

JonasStjerne commented 11 months ago

To replicate open the website, thats it 😮 You can also press the reset grid button a bunch of times if you're cool. See how the ids increment.

We would like the id to start from 0.

This happens because we use a static _id field for the number in the node class. This way the first node initialized has the id of 0. But when we receive a grid from local storage the default grid is first made and then overwritten by the retrieved grid from localstorage thereby being the second grid to get created at runtime starting the id from 100.

Link to static field: https://github.com/JonasStjerne/P7/blob/0a05d7cabb99bbbadd99f591d2cc243c4ced8422/algo/models/Node.ts#L7