pathfinding help

Blitz3D Forums/Blitz3D Beginners Area/pathfinding help

chwaga(Posted 2008) [#1]
Hi, i'm back, with an even more naive question than ever before!

I've tackled A* already, and failed miserably ( see below ).



I was wondering if there's any file somewhere with a simple plug-in-and-use pathfinding system. It doesn't need to be extremely fast, just usable. I want to be able to set up a grid of given dimensions, and send an object from point A to point B, A* style. It seems that all the easy ones are 3D node-based and are way too slow for an interpolated grid. A simple 2D that i could translate into 3D (relative to the terrain, or whatever) would do nicely. That or tell me what's wrong with the above code.

thanks!! (i send a thank-you-cookie-program to whoever solves either of my problems)


Ross C(Posted 2008) [#2]
You really are best learning it yourself :o) When you get it ( i swear it just CLICKS on day), you'll see it's not that hard at all. I can't be of more help though, sorry ^_^


chwaga(Posted 2008) [#3]
well, i took another shot at coding it, but I'm getting killed (on step 1 here on a MAV for doing this:

for node.nodes = each nodes
     for node.nodes = each nodes

     next
next


anybody wanna fix this for me? I'm kinda perplexed how to work around the above thing. code down below!



And Ross, I totally understand the logic of A*, just I keep screwing up on the code for it. I drew out a grid and A-starred my way from point A to point B around obstacles to prove to myself I knew it. I tend to have trouble translating logic into code when it's complex and random MAV-involving...


Naughty Alien(Posted 2008) [#4]
..have you try to setup network of nodes where each connected node is a child or parent of previous one? On that way you can simply get closest path/node to the desired location by just checking parented nodes ..thats what I did, and its really simple to use and working just fine for me..


Ross C(Posted 2008) [#5]
for node.nodes = each nodes
     for node.nodes = each nodes

     next
next


I'm certain that will fail. You have the same varaible assigned to both loops.

for node1.nodes = each nodes
     for node2.nodes = each nodes

     next
next


That should work.


andy_mc(Posted 2008) [#6]
is a node just a predefined set of coords on a map? i.e with pacman it would be all square, but with 3d maps like quake maps, would it just be the corners of rooms and doorways?


chwaga(Posted 2008) [#7]
I'll try that naughty alien, thanks (andy_mc, each node is a coordinate on a grid, I hope to just use 2D graphics and translate it into 3D using a heightmap or whatever I do)


chwaga(Posted 2008) [#8]
why do I get an error saying "Variable must be a type" on these lines:
If NodeID(n * m)\x = StartX And node\y = StartY Then NodeID(n * m)\StartNode = True
			If NodeID(n * m)\x = EndX And node\y = EndY Then NodeID(n * m)\EndNode = True


in this code:




chwaga(Posted 2008) [#9]
really guys, something like this for b3d would be FREAKING AWESOME. If you have one, find one, make one, get it to me :D

I'm about to explode, I can't reverse engineer anybody else's, I can't code my own because stupid syntax errors keep getting me and it takes about a day to figure out why for EACH, and all the good ones that are SIMPLY TOO PERFECT for my purposes are bmax!!!

GAH!!!!!!!!!!!
(I think I need to go play some TF2 to blow off some steam by blowing off some heads...)



....FYI: I've been at this for two hours straight today and gotten absolutely nowhere, I have the right, no, the DUTY to be ticked off :)


stayne(Posted 2008) [#10]
Hope this is what you're after. I'm sure it'll make sense to ya.

If NodeID(n * m)\x = StartX And NodeID(n * m)\y = StartY Then NodeID(n * m)\StartNode = True
If NodeID(n * m)\x = EndX And NodeID(n * m)\y = EndY Then NodeID(n * m)\EndNode = True



chwaga(Posted 2008) [#11]
dang, typo, I feel like an idiot now :(


chwaga(Posted 2008) [#12]
ok, bram translated this for me to b3d, and it works kinda fine. Except it's SLOW. Up to 50m/s per loop on a 256 x 192 grid. Check this out:

pathinc.bb:


test.bb:


does anybody have some ideas to speed thing along? (I need speed, at least 100 or so "dudes", 20 "dudes" is around 0.5FPS!!)


chwaga(Posted 2008) [#13]
well, I didn't quite fix the speed problem, but I made it look nonexistant. I just use an interpolation of positions, but the stupid "dudes" keep getting stuck on walls....

test.bb:




chwaga(Posted 2008) [#14]
hmm...fixed that, now I guess I just kinda...well, unless anybody can speed up the code, it's my problem now. Thanks for the help, guys!


chwaga(Posted 2008) [#15]
dun dun dun....

this doesn't plug into a 3d FPS too well, as soon as I raise the grid to 100 x 100, it's SLOW... I may have to chunk the pathfinding grids....would it be practical to give each npc a grid of it's own, and if the player invaded the grid, it would chase the player??