Skip to content

Commit

Permalink
Fixed missing locals declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonaba committed Jan 29, 2013
1 parent 9039524 commit 422d40c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
3 changes: 3 additions & 0 deletions jumper/core/path.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

if (...) then

-- Internalization
local abs, max = math.abs, math.max

-- Depandancies
local Heuristic = require ((...):gsub('%.path$','.heuristics'))

Expand Down
10 changes: 5 additions & 5 deletions jumper/pathfinder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ local Grid = require ("jumper.grid") -- The grid class
local Pathfinder = require ("jumper.pathfinder") -- The pathfinder lass
-- Creates a grid object
local grid = Grid(map)
local grid = Grid(map)
-- Creates a pathfinder object using Jump Point Search
local myFinder = Pathfinder('JPS', grid, walkable)
local myFinder = Pathfinder('JPS', grid, walkable)
-- Define start and goal locations coordinates
local startx, starty = 1,1
Expand Down Expand Up @@ -67,7 +67,7 @@ if (...) then
local _PATH = (...):gsub('%.pathfinder$','')
local Heap = require (_PATH .. '.core.bheap')
local Heuristic = require (_PATH .. '.core.heuristics')
local Grid = require (_PATH .. '.grid')
local Grid = require (_PATH .. '.grid')
local Path = require (_PATH .. '.core.path')

-- Is arg a grid object
Expand Down Expand Up @@ -140,7 +140,7 @@ if (...) then
--- Inits a new `pathfinder` object
-- @class function
-- @name pathfinder:new
-- @tparam string finderName the name of the `finder` (search algorithm) to be used for further searches.
-- @tparam string finderName the name of the `finder` (search algorithm) to be used for further searches.
-- Use @{pathfinder:getFinders} to get the full list of available finders.
-- @tparam grid grid a `grid` object.
-- @tparam[opt] string|int|function walkable the value for walkable nodes on the passed-in map array.
Expand Down Expand Up @@ -194,7 +194,7 @@ if (...) then

--- Gets the `walkable` value or function.
-- @class function
-- @name pathfinder:getWalkable
-- @name pathfinder:getWalkable
-- @treturn value|function the `walkable` previously set
function Pathfinder:getWalkable()
return self.walkable
Expand Down
10 changes: 5 additions & 5 deletions jumper/search/astar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if (...) then
for i = 1, #neighbours do
local neighbour = neighbours[i]
if not neighbour.closed then -- If not in closed list

local x, y = neighbour.x, neighbour.y
local dx, dy = x - node.x, y - node.y
local extraG = node.g + ((dx == 0 or dy == 0) and 1 or sqrt2) -- Evaluates the new G-cost
Expand All @@ -31,7 +31,7 @@ if (...) then
neighbour.h = neighbour.h or heuristic(d_to_end_x, d_to_end_y)
neighbour.f = neighbour.g + neighbour.h
neighbour.parent = node

if not neighbour.opened then
-- Moves it in openList
finder.openList:push(neighbour)
Expand All @@ -45,7 +45,7 @@ if (...) then
end

-- Calculates a path.
-- Returns the path from location `<startX, startY>` to location `<endX, endY>`.
-- Returns the path from location `<startX, startY>` to location `<endX, endY>`.
return function (finder, startNode, endNode, toClear, overrideHeuristic)

startNode.g, startNode.f = 0,0
Expand All @@ -59,11 +59,11 @@ if (...) then
-- Pops the lowest F-cost node, moves it in the closed list
node = finder.openList:pop()
node.closed = true
-- If the popped node is the endNode, return it
-- If the popped node is the endNode, return it
if node == endNode then
return node
end
-- otherwise, keep going A-star search from the popped node
-- otherwise, keep going A-star search from the popped node
astar_search(finder, node, endNode, toClear, overrideHeuristic)
end

Expand Down
6 changes: 3 additions & 3 deletions jumper/search/jps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@


if (...) then

-- Dependancies
local _PATH = (...):match('^(.*[%./])[^%.%/]+[%./][^%.%/]+$')
local Heuristics = require (_PATH .. '.core.heuristics')

-- Internalization
local max, abs = math.max, math.abs

-- Local helpers, these routines will stay private
-- As they are internally used by the public interface

Expand Down

0 comments on commit 422d40c

Please sign in to comment.