LuAstar, a simple A* pathfinding class

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: LuAstar, a simple A* pathfinding class

Post by kikito »

This lib has those inconveniences (the flexibility part; I don't know about the speed) because it is coupled with a particular map implementation. As soon as you get out of those needs, it's just not flexible enough.

I'm not saying this to bash Roland; he's sharing a lib so others can use it, and that's great. I actually started doing my own A*, but doing it "the flexible way" takes some effort - I still haven't finished.

Maybe you guys want to give a look at TSerial. I just gave it a cursory look myself. At the very least it uses threads, which is something Jasoco is requesting.
When I write def I mean function.
User avatar
Taehl
Dreaming in associative arrays
Posts: 1025
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

Re: LuAstar, a simple A* pathfinding class

Post by Taehl »

I think you mean TLpath?

I will remark that my implementation, while maybe not being perfectly easy to use (I tried, though! It's a very tough problem!), is quite optimal in the path-finding itself (or so I believe).
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: LuAstar, a simple A* pathfinding class

Post by Jasoco »

I was thinking of taking the LuaStar code and dissecting it and implementing path finders into my "person" objects so the part that does the finding can be run in stages from within their update function instead of in a closed loop that pauses the code. So basically it'll be the person will just stand still while it thinks, and then will move. At least it wouldn't freeze the rest of the game for every person.

This of course means figuring out exactly how it works at the code level.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: LuAstar, a simple A* pathfinding class

Post by kikito »

Taehl wrote:I think you mean TLpath?

I will remark that my implementation, while maybe not being perfectly easy to use (I tried, though! It's a very tough problem!), is quite optimal in the path-finding itself (or so I believe).
I meant TLPath. I got distracted by the other link to TSerial, apologies.
When I write def I mean function.
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: LuAstar, a simple A* pathfinding class

Post by coffee »

Jasoco wrote:I was thinking of taking the LuaStar code and dissecting it and implementing path finders into my "person" objects so the part that does the finding can be run in stages from within their update function instead of in a closed loop that pauses the code. So basically it'll be the person will just stand still while it thinks, and then will move. At least it wouldn't freeze the rest of the game for every person.

This of course means figuring out exactly how it works at the code level.
You probably already saw this around. For sure this can help you (a lot) if you want to do it from scratch or improve one.
http://www-cs-students.stanford.edu/~am ... html#paths
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: LuAstar, a simple A* pathfinding class

Post by Nixola »

I tried to use this library to generate a tile-based map with a walkable path (tile number 2 is walkable), but I get the following error:

Code: Select all

Error: ./lib/astar.lua:39: attempt to compare number with table
stack traceback:
	./lib/astar.lua:39: in function 'inBound'
	./lib/astar.lua:233: in function 'setInitialNode'
	./lib/functions.lua:16: in function 'create'
The code in function.lua (the file that generates the error (and the map) is this:

Code: Select all

function map.create()
	for y = 1, tilemap.h do
		map[y] = {}
		for x = 1, tilemap.w do
			map[y][x] = math.random(1,5)
			if map[y][x] ~= 5 then
				map[y][x] = 1
			else map[y][x] = 2
			end
		end
	end
	astar(map)
	map.start = {math.random(tilemap.w),math.random(tilemap.h)}
	map.goal  = {math.random(tilemap.w),math.random(tilemap.h)}
	-- If I uncomment the lines below, I have the error...
	astar:setInitialNode(map.start)
	astar:setFinalNode(map.goal)
	enemies.path = astar:getPath()
	if not enemies.path then
		love.graphics.print('Loading...',0,0)
		map.recreate()
	end
	-- If I uncomment the lines above, I have the error...
end

function map.recreate()
map.create()
end
Link to the .love file: http://dl.dropbox.com/u/15081595/Doesn%27t%20work.love
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: LuAstar, a simple A* pathfinding class

Post by Roland_Yonaba »

I've been working on this one. I've re-started it from zero.
Actually I am trying trying to have Jump Point Search working.
It works fine, but there are still some odds with diagonal moves.
I'll give heads up soon.
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: LuAstar, a simple A* pathfinding class

Post by Roland_Yonaba »

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests