Easy to use, it will make you more attractive and you feel sensual doing so.
Code: Select all
local lib = require("lib")
function isPositionOpenfunc(x, y)
-- should return true if the map position at x, y is open to walk
return map[x][y]
end
-- find me a path
local mapwidth = 10
local mapheight = 10
local start = { 1, 10 }
local goal = { 10, 1 }
path = lib:find(mapwidth, mapheight, start, goal, isPositionOpenfunc)
The path will be nil if no path was found, otherwise it contains a list of points that travel your path:
Code: Select all
if path then
for _, p in ipairs(path) do
print(p.x, p.y)
end
end