|
MrCheviot Novice
Joined: 02 Dec 2007 Posts: 42
|
Posted: Thu Mar 06, 2008 4:01 pm
Access to mapper 'pathcost' ? |
When you want to go from RoomA to RoomB, you can use a couple of commands to have the mapper give you the shortest path, e.g. %pathfrom(RoomA,RoomB). This uses the mappers internal (?) routine to figure out the path according to exits, room costs, portal costs, etc.
Is there anyway to have the mapper output the numeric cost of a path?
I know you can do %numitems(%pathexpand(%pathfrom(RoomA,RoomB))), but this will effectively assign a value of 1 to each step in the path, regardless of portal cost or room cost.
It also doesn't appear possible to traverse a list of rooms in the path using %roomcost and assembling a running total since, afaik, there's no way to have the mapper give you the RoomId's along the path - it just gives you the directions to proceed through it. ("portal|123|124|128" would be okay since you can assign any instance of portal a cost and then use %roomcost on actual nums).
I guess in my ideal world, there'd be a %pathcost(RoomA, RoomB) function, but there's not. I suppose it's possible to create a complex loop/query to disassemble the %pathfrom, get %roomcost of current room and use each exit direction in path to fetch the next RoomId via the ExitTbl. I was hoping to avoid all of that, but if that is the only/best solution, anyone have example code they might be able to share?
Thanks in advance,
-MrC |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu Mar 06, 2008 5:45 pm |
There's not. It'll perhaps be added to CMUD when its mapper is beefed up.
However, speaking theoretically, the directions and the starting room should be all you need, and you have access to both. You take the first direction in the list, find out what room's in that direction and save the number. Then you find out the room cost of that room and add it to the total. Then you take the next direction in this list and find out what room's in that direction from the current (saved) room, get the roomcost of that room, and so on and so forth until you run out of directions. I don't have any code to back this up, but it should work.
EDIT: Continued thoughts:
TotalCost=0
CurRoom=%1
#forall %pathexpand(%pathfrom(%1,%2)) {NextRoom=%roomlink(@CurRoom,%i);#add TotalCost %roomcost(@NextRoom);CurRoom=@NextRoom}
Untested and this'll be pretty slow anyway - SQL would probably be faster, but I'll leave that up to Viji. |
|
|
|
Leitia Adept
Joined: 04 May 2007 Posts: 292 Location: Boston
|
Posted: Fri Mar 07, 2008 12:06 am |
This only relates to pathcost, so I will not start a new thread. Still it is not about the question.
I find the whole path calculation amazing, I think those are called vectors, which is my limit, a supposition. I wish I knew more about that.
All I could imagine doing that way is hoping to quickly rewrite or switch certain (many certain) move cost values to effect the shortest route calculation during the game, which sounds really nasty for a dynamic need and perhaps not possible at all as I have to click those in.
Musing.
I think I can just make a representive zone of the whole world though I have not worked much with the mapper |
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|