Page 1 of 10

Jumper : 2D Pathfinder with Jump Point Search (v.1.8.1)

Posted: Fri May 25, 2012 7:51 pm
by Roland_Yonaba
Jumper

Jumper is a pathfinding library designed for grid-based games.
It is written in pure Lua and offers a wide range of search algorithms, implemented through a common interface for a convenient use.
Jumper aims to be fast, lightweight, with a focus on being easy-to-use.

Image Image
Image
Screenshot of a Demo using Kadoba's ATL(map rendering) and Jumper for pathfinding purposes.

A simple example showing how to use Jumper (v1.8.1)

Code: Select all

-- Usage Example
-- First, set a collision map
local map = {
    {0,1,0,1,0},
    {0,1,0,1,0},
    {0,1,1,1,0},
    {0,0,0,0,0},
}
-- Value for walkable tiles
local walkable = 0

-- Library setup
local Grid = require ("jumper.grid") -- The grid class
local Pathfinder = require ("jumper.pathfinder") -- The pathfinder lass

-- Creates a grid object
local grid = Grid(map) 
-- Creates a pathfinder object using Jump Point Search
local myFinder = Pathfinder(grid, 'JPS', walkable) 

-- Define start and goal locations coordinates
local startx, starty = 1,1
local endx, endy = 5,1

-- Calculates the path, and its length
local path, length = myFinder:getPath(startx, starty, endx, endy)
if path then
  print(('Path found! Length: %.2f'):format(length))
    for node, count in path:iter() do
      print(('Step: %d - x: %d - y: %d'):format(count, node.x, node.y))
    end
end

--> Output:
--> Path found! Length: 8.83
--> Step: 1 - x: 1 - y: 1
--> Step: 2 - x: 1 - y: 3
--> Step: 3 - x: 2 - y: 4
--> Step: 4 - x: 4 - y: 4
--> Step: 5 - x: 5 - y: 3
--> Step: 6 - x: 5 - y: 1
Github (Source): Jumper (current v1.8.1)
Demos (with Löve and other frameworks): Jumper-Examples
Benchmak console test app: Jumper-Benchmark
Wiki (Löve2d wiki): Jumper

Re: [Lib/Lua] Jumper : 2D Pathfinder with Jump Point Search

Posted: Sat May 26, 2012 5:45 am
by MarekkPie
Haven't tested it yet, but one thing I would suggest is rather than put the .love files in code section of the GitHub repository, use the built-in downloads section.

The demo works fine, but the test .love throws require errors for "Utils":

Code: Select all

Error: test.lua:28: module 'Utils' not found:
	no file "Utils.lua" in LOVE game directories.

	no extension "Utils" in LOVE paths.

	no field package.preload['Utils']
	no file './Utils.lua'
	no file '/usr/local/share/lua/5.1/Utils.lua'
	no file '/usr/local/share/lua/5.1/Utils/init.lua'
	no file '/usr/local/lib/lua/5.1/Utils.lua'
	no file '/usr/local/lib/lua/5.1/Utils/init.lua'
	no file '/usr/share/lua/5.1/Utils.lua'
	no file '/usr/share/lua/5.1/Utils/init.lua'
	no file './Utils.so'
	no file '/usr/local/lib/lua/5.1/Utils.so'
	no file '/usr/lib/i386-linux-gnu/lua/5.1/Utils.so'
	no file '/usr/lib/lua/5.1/Utils.so'
	no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
	[C]: in function 'require'
	test.lua:28: in main chunk
	[C]: in function 'require'
	main.lua:28: in function 'load'
	[string "boot.lua"]:378: in function <[string "boot.lua"]:373>
	[C]: in function 'xpcall'

Re: [Lib/Lua] Jumper : 2D Pathfinder with Jump Point Search

Posted: Sat May 26, 2012 11:22 am
by Roland_Yonaba
Hi MarrekPie,
Thanks for answering. I fixed the error, that was a matter of case-sentitive paths.
I also reorganized the repository, as suggested.
Thanks!

Re: [Lib/Lua] Jumper : 2D Pathfinder with Jump Point Search

Posted: Sat May 26, 2012 3:06 pm
by MarekkPie
The links in the first post still point to the old .love file locations.

Re: [Lib/Lua] Jumper : 2D Pathfinder with Jump Point Search

Posted: Sat May 26, 2012 9:47 pm
by coffee
Roland is Jumper_(Tests).love in github updated? Either in 0.7, 0,8 and JIT screen goes blank and program hangs in distress for a long time. It's this normal? At start is already in tests?

Re: [Lib/Lua] Jumper : 2D Pathfinder with Jump Point Search

Posted: Sun May 27, 2012 8:20 am
by Roland_Yonaba
MarekkPie wrote:The links in the first post still point to the old .love file locations.
Fixed. Have you tried both *.love files, and have them worlkng properly ?
coffee wrote:Roland is Jumper_(Tests).love in github updated? Either in 0.7, 0,8 and JIT screen goes blank and program hangs in distress for a long time. It's this normal? At start is already in tests?
I fixed a small typo error since yesterday, and I checked - it was working fine. I did checked it again right know, both *.love are running fine. I can't figure out a possible reason for freezing, as it doesn't starts tests automatically, but it just displays a list of maps founds in the local "maps" folder (inside the app folder) in the Löve console, as shown below:

Re: [Lib/Lua] Jumper : 2D Pathfinder with Jump Point Search

Posted: Sun May 27, 2012 9:12 am
by coffee
Ah perhaps then you (trying) to assemble the list of map files in an unorthodox way so the app don't find the files? (I'm using OSX btw)
That's what I get (more the not captured rainbow "busy" cursor)
hang.png

Re: [Lib/Lua] Jumper : 2D Pathfinder with Jump Point Search

Posted: Sun May 27, 2012 7:02 pm
by Roland_Yonaba
coffee wrote:Ah perhaps then you (trying) to assemble the list of map files in an unorthodox way so the app don't find the files? (I'm using OSX btw)
Well, I'm on windows...It maybe related to that, as I'm not familiar with how Mac OSX filesystem works.
But maybe you can help me figure out..

Here is Jumper_(Tests) folder structure:
Jumper (Folder) -- Library
maps (Folder) -- contains all maps
main.lua
conf.lua
parser.lua
utils.lua
test.lua
Inside main.lua, inside love.load callback, I use this to get the whole list of maps printed:

Code: Select all

function love.load()
Utils = require('utils')
	Test = require ('test')
	local mapsFolder = 'maps/'
	local savFolder = 'Jumper/'
	love.filesystem.setIdentity(savFolder)
	print('GETTING MAPS LIST')
	local files = Utils.filter(love.filesystem.enumerate(mapsFolder),'scen')
	print(('FOUND :  %d MAPS'):format(#files))
	table.foreach(files,print) -- This will get you the whole list of maps printed.

Function Utils.filter is a custom utility I wrote.Fact is, inside "maps" folder, each map consist of two files, a *.map coupled with a *.map.scen file. Then I have to get rid of *.map.*scen files using love.filesystem.enumerate, this way:

Code: Select all

--Inside utils.lua
local instert = table.insert
local function filter(t,flag)
	local new_t = {}
	local len = #flag
	for k in pairs(t) do
		if not(t[k]:sub(-len) == flag) then
		insert(new_t,t[k])
		end
	end
	return new_t
end

return { filter = filter}
That's basically what I do in the code, as you can see, nothing "unorthodox"... It runs fine for me, an on some other PCs (yet running windows)...I don't have a Mac around, so I can't telml why could be the problem.
But you can unpack the .love file and track the bug.

Indeed, you can get the visual demo working, right ?

Re: [Lib/Lua] Jumper : 2D Pathfinder with Jump Point Search

Posted: Sun May 27, 2012 7:24 pm
by coffee
Visual demo always worked fine. :)
I commented main.lua and started uncomment till I found the problem.
when I uncommented this pure lua IO command started the white hanging problem

Code: Select all

		local l = io.read()
Maybe you can avoid it and use Love IO alternatives.
EDITED since you output to console and not to screen I went there and confirmed that initial enumeration is done.

Re: [Lib/Lua] Jumper : 2D Pathfinder with Jump Point Search

Posted: Sun May 27, 2012 7:42 pm
by Roland_Yonaba
Right... It was easy to write... But not sure to work on every platform..
I 'll have to rewrite that demo, avoiding IO for input..
Thanks for taking time to look into it, I strongly appreciate. :awesome:
Would you mind create an issue for this ?