Wayfinder, an alternate route finder package

Share your scripts and packages with other Mudlet users.
Post Reply
Smurf
Posts: 4
Joined: Sat Jul 18, 2020 1:16 pm

Wayfinder, an alternate route finder package

Post by Smurf »

I'm not happy with the built-in route finder in Mudlet, so I wrote my own.

The attached package contains one function: "findWayToRoom(sourceRoom, checkFn)".
The check function gets four arguments (distance, roomToBeChecked, roomlist, directionlist). It is responsible for saving its arguments if the room matches. It can return true (stop searching), false (continue but not through this room), nil (continue as usual) or a number (added to the distance of further ways through this room).
Return value: true if your check function ever returned "true". The room+direction lists are not returned, your checkFn is responsible for saving them if required.

So what can we do with this?
- really-shortest-route finding (Mudlet's A* algorithm doesn't understand "go 20 rooms *away* from your destination, then enter the teleport")
- way to the next XXX (bank, church, weapons store)
- even better: ways to the next five XXXes, collected all at once, then let the player click on which they want to use
- list the ten closest rooms with un-explored exits
- conditional routes (can't swim through the lake while shlepping the heavy plate mail, can't walk the narrow mountain path when severely injured)
- your imagination here.

Speed: runs through 10k rooms in a tenth of a second on my somewhat-underpowered desktop. YMMV and depends mainly on the complexity of the check function.
Attachments
Wayfinder.mpackage
(2.07 KiB) Downloaded 9 times

Post Reply