I hope this will be handy. TLpath is a fast, efficient pathfinder which I've built to be as flexible as possible. But despite my best efforts, pathfinding isn't a simple thing, so this isn't completely a fire-and-forget solution. To implement it in a given game, you'll need to add path nodes and (likely) give it an appropriate g-function. But other than that, it should be pretty easy to get along with. It even does its work in a separate thread, so your game can continue working as normal while it finds paths for you. It comes with a simple demo showing off how fast it is and how to use it. So let's see some AI in your games!
Download: Here
Documentation/wiki: TLpath
Comments? Critique? Accolades? Need help using it? This is the place for it.
TLpath, A* pathfinding for Love
- Taehl
- Dreaming in associative arrays
- Posts: 1025
- Joined: Mon Jan 11, 2010 5:07 am
- Location: CA, USA
- Contact:
TLpath, A* pathfinding for Love
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+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: TLpath, A* pathfinding for Love
Looks interesting.
{, }Taehl wrote:Accolades?
Help us help you: attach a .love.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: TLpath, A* pathfinding for Love
When I write def I mean function.
Re: TLpath, A* pathfinding for Love
The demo doesn't work for me:
Also set[GH]function feel akward. You can serialize functions (without upvalues) using string.dump:
Edit: Wait, it worked. Then it failed on line 143 (attempt to index local 'b').
Sometimes love locks completely (deadlock somewhere?)
Code: Select all
Error: [string "main.lua"]:174: attempt to index field '?' (a nil value)
Code: Select all
function foo() print('bar') return 'baz' end
serialized = string.dump(foo) --> function bytecode
magic = loadstring(serialized)
print( magic() )
Sometimes love locks completely (deadlock somewhere?)
- Taehl
- Dreaming in associative arrays
- Posts: 1025
- Joined: Mon Jan 11, 2010 5:07 am
- Location: CA, USA
- Contact:
Re: TLpath, A* pathfinding for Love
I have a .zip instead of a .love file to make it that much easier to open up and get the files from - it's not a game in and of itself.
I have no idea what your problems are from, vrld. I don't experience those. I've updated the download, which may help. set[GH]function are for convenience. If you don't want to use them, you can go rewrite the gScore and hScore functions in TLpath.lua (lines 78 and 80).
I have no idea what your problems are from, vrld. I don't experience those. I've updated the download, which may help. set[GH]function are for convenience. If you don't want to use them, you can go rewrite the gScore and hScore functions in TLpath.lua (lines 78 and 80).
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+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Re: TLpath, A* pathfinding for Love
That fixed it.Taehl wrote:I've updated the download, which may help.
They would be more convenient if I could pass true lua functions instead of strings, possibly alongside with some custom data:Taehl wrote:set[GH]function are for convenience.
Code: Select all
TLpath.setGfunction(function(a,b, my_data)
local function reachable() ... stuff with my_data ... end
return reachable() and math.abs(b.x - a.x) + math.abs(b.y - a.y)
end, walls)
Re: TLpath, A* pathfinding for Love
Straight into my game whenever vrld's suggestion gets added. Well done.
- ishkabible
- Party member
- Posts: 241
- Joined: Sat Oct 23, 2010 7:34 pm
- Location: Kansas USA
Re: TLpath, A* pathfinding for Love
can you make a Dijkstra's path finding option? i have an un-encapsulated implementation if you want to look at it. it names nodes by string and lets you build your network. with a bit of modification to the NewNode function it could store whatever data it needed(like coordinates). the benefit of Dijkstra's algorithm here is you don't need a uniform plane for it to work. say you want to put a few rocks in the way, no biggy you simply wont put a node there.
- Attachments
-
- DijtrasAlgorithim.lua
- (2.88 KiB) Downloaded 382 times
- Taehl
- Dreaming in associative arrays
- Posts: 1025
- Joined: Mon Jan 11, 2010 5:07 am
- Location: CA, USA
- Contact:
Re: TLpath, A* pathfinding for Love
I'd love to offer that, but you can only send strings and numbers (and maybe bools?) to threads, and the resulting functions would have to have the right name or else it wouldn't work. The best I can do is send code as a string and execute it on the other side.vrld wrote:They would be more convenient if I could pass true lua functions instead of strings, possibly alongside with some custom data:
I don't see why you can't do that in A*? My demo only uses a grid for half of the maps just to show it can be done. Technically you don't even need to place and g-score nodes by coordinates, if you have a different method.ishkabible wrote:it names nodes by string and lets you build your network. with a bit of modification to the NewNode function it could store whatever data it needed(like coordinates). the benefit of Dijkstra's algorithm here is you don't need a uniform plane for it to work. say you want to put a few rocks in the way, no biggy you simply wont put a node there.
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+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Re: TLpath, A* pathfinding for Love
Taehl wrote:I'd love to offer that, but you can only send strings and numbers (and maybe bools?) to threads, and the resulting functions would have to have the right name or else it wouldn't work.
vrld wrote:You can serialize functions (without upvalues) using string.dump:Code: Select all
function foo() print('bar') return 'baz' end serialized = string.dump(foo) --> function bytecode magic = loadstring(serialized) print( magic() )
Who is online
Users browsing this forum: No registered users and 222 guests