Time to Reinvent the Route-Finder

Great catch! It was a bug in DijkstraCalculate. At line 70, there’s this code:

if(there ofclass K4_door){
	door = there;
	@push location; location = source;
	there = there.door_to();
	@pull location;
}

In other words, store the current value of location, set location to source, ask the door where it leads from the current location (i.e. source), then restore the original value of location.

But we don’t want to know where the door leads from source, the place our pathing began; we want to know where the door leads from obj, the room currently under consideration! From source it probably leads nowhere.

So change source to obj in line 72 and that’ll be fixed. I’ve attached an updated version.

Dijkstra Pathing-v1.i7x (11.4 KB)

4 Likes