MatejSloboda / Dijkstra_map_for_Godot

MIT License
77 stars 13 forks source link

Put back id in QueuePriority #80

Closed arnaudgolfouse closed 3 years ago

arnaudgolfouse commented 3 years ago

Following this discussion if you still want it.

Interestingly, it seems the algorithm was already deterministic ! However, this is in part due to behavior of priority_queue that I am not sure is intended (see e25adbc).

I added documentation about this, so that it doesn't come as a surprise in the future.

MatejSloboda commented 3 years ago

It may have been deterministic due to a quirk of implementation of HashMap. The connections to neighboring points are visited via an iterator over a HashMap, which visits the elements in arbitrary order according to the documentation. Similarly, as you mention, PriorityQueue does not explicitly guarantee order for tied elements (at least it doesn't mention it in the documentation).

Nor is it guaranteed that the internal behavior of all of these is consistent across builds (windows vs. Linux, 64 vs 63bit). For example, user might get a desync in gamestate in multiplayer games, because server and client run on different systems and break the ties differently. I know I'm probably just excessively paranoid about this ;-D