Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local modname = minetest.get_current_modname()
- local modpath = minetest.get_modpath(modname)
- print("LOADING " .. modname .. " FROM " .. modpath)
- pos0 = {x=0, y=0, z=0}
- pos1 = {x=1, y=0, z=0}
- pos2 = {x=0, y=1, z=0}
- pos3 = {x=0, y=0, z=1}
- pos4 = {x=8, y=16 , z=32}
- function imlazy (posa, posb)
- print("First pos: " .. minetest.pos_to_string(posa) .. " Secound pos: " .. minetest.pos_to_string(posb))
- searchdist = 100 -- arbitrary, but larger than any distance needed
- --Increasing it does make it slower, and uses more ram (learned the hard/fun way.)
- max_jump = 100
- max_drop = 100
- algorithm = {"A*_noprefetch","A*","Dijkstra" --Real
- ,"Pangus","Bacon"} --Not so real
- for index,value in ipairs(algorithm) do
- print("Algorithm " .. value)
- print(dump(minetest.find_path(posa,posb,searchdist,max_jump,max_drop,value)))
- end
- end
- minetest.register_on_joinplayer(function(player)
- imlazy(pos0,pos1)
- imlazy(pos0,pos2)
- imlazy(pos0,pos3)
- imlazy(pos0,pos4)
- imlazy(pos1,pos2)
- imlazy(pos1,pos3)
- imlazy(pos1,pos4)
- imlazy(pos2,pos3)
- imlazy(pos2,pos4)
- imlazy(pos3,pos4)
- end )
- return true
- --[[minetest.find_path(pos1,pos2,searchdistance,max_jump,max_drop,algorithm)
- ^ -> table containing path
- ^ returns a table of 3d points representing a path from pos1 to pos2 or nil
- ^ pos1: start position
- ^ pos2: end position
- ^ searchdistance: number of blocks to search in each direction
- ^ max_jump: maximum height difference to consider walkable
- ^ max_drop: maximum height difference to consider droppable
- ^ algorithm: A*_noprefetch(default), A*, Dijkstra
- ]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement