mirror of
https://github.com/1bardesign/batteries.git
synced 2024-11-21 21:54:35 +00:00
fix linter nags
This commit is contained in:
parent
4a3740cf53
commit
5641b393e4
12
pathfind.lua
12
pathfind.lua
@ -26,7 +26,7 @@ local generate_constant = function() return 1 end
|
||||
-- can be used to speed up searches at the cost of accuracy by returning some proportion higher than the actual distance
|
||||
-- defaults to a constant value, which means the A* algorithm degrades to breadth-first search
|
||||
-- alias: h
|
||||
function pathfind(args)
|
||||
local function pathfind(args)
|
||||
local start = args.start or args.start_node
|
||||
local is_goal = args.is_goal or args.goal
|
||||
local neighbours = args.neighbours or args.generate_neighbours
|
||||
@ -70,15 +70,13 @@ function pathfind(args)
|
||||
return false
|
||||
end
|
||||
|
||||
--build up the ordering
|
||||
local path = {}
|
||||
--build up result path
|
||||
local result = {}
|
||||
while current do
|
||||
table.insert(path, 1, current)
|
||||
table.insert(result, 1, current)
|
||||
current = predecessor[current]
|
||||
end
|
||||
|
||||
--return a path
|
||||
return path
|
||||
return result
|
||||
end
|
||||
|
||||
-- Based on https://github.com/lewtds/pathfinder.lua/blob/master/pathfinder.lua
|
||||
|
Loading…
Reference in New Issue
Block a user