Pathfinding speed test

All and any discussion and development of the Mudlet Mapper.
Post Reply
User avatar
Vadi
Posts: 4901
Joined: Sat Mar 14, 2009 3:13 pm

Pathfinding speed test

Post by Vadi »

Here's an alias I wrote to see the speed of pathfinding - it goes through all rooms in your map and tries to make a path to any other random room. In the end, it averages out the time it took for each result and gives you a number. It's ridiculously small, so pathfinding is appropriately ridiculously quick. Note that the stopwatch used has milisecond precision.
Attachments
pathfind-v3.xml.zip
(823 Bytes) Downloaded 280 times

User avatar
Vadi
Posts: 4901
Joined: Sat Mar 14, 2009 3:13 pm

Re: Pathfinding speed test

Post by Vadi »

Updated version, thanks to ace:
Code: [show] | [select all] lua
watch = watch or createStopWatch()

local rooms = getRooms()

-- create a list of rooms that have at least one normal exit
local room_list = {}
for k, v in pairs(rooms) do
  if next(getRoomExits(k)) then
    table.insert(room_list, k)
  end
end

-- create a map with every room paired up with another random room
rooms = {}
for k, v in ipairs(room_list) do
  rooms[v] = math.random(#room_list)
end

-- pathfind from every room A to a random room B
local getPath = getPath
startStopWatch(watch)
for from, to in pairs(rooms) do
  getPath(from, to)
end
local t = stopStopWatch(watch)

display("Average time to pathfind from one room to a random other: "..t/#room_list.." seconds, tested with "..#room_list.." rooms.")

Post Reply