Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Fields - New Pathfinding WIP

Author
Message
BMacZero
19
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 27th Oct 2009 03:24 Edited at: 27th Nov 2009 15:24
So before in Fields I was using a pretty standard A* routine for pathing. The problem with this routine was that it was getting kind of slow (50-100 ms for each path, and I wasn't even close to the map sizes I wanted).

I realized this was largely due to the fact that even in the large, open spaces of Fields, each A* node was a small 10x10 box, and when pathing, each unit had to go through large grids of these little boxes even if there weren't any obstacles around. So, I started trying to create a faster pathing routine that would also allow me to abandon the grid completely and allow buildings to be placed entirely freeform - any postion, any angle.

I got stuck on this a few months ago, hence the few months of silence.

But last week I had a great idea that lead to this demo:


It's similar to A*, but instead of a grid it uses the corners of each obstactle as nodes. The unit moves from corner to corner to get where it's going - after all, that's the fastest way. (It's also the fastest I've had processing-wise - less than 0.5 ms for anything you can draw on this demo.)

It has a few glitches (for example, the unit will walk straight through anything more complex than triangles and squares), but hopefully I'll be working those out soon.

Questions, comments, and advice would be great (that's why I posted it ).

RUCCUS
20
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 27th Oct 2009 03:36 Edited at: 27th Oct 2009 03:38
I actually was working on the EXACT same theory a few weeks ago but had to put it to the side for school work. I ended up realizing that if you only use the corners of an object that are convex, you get an even more direct route then including concave corners.

I was eventually hoping to devise a system that would find the corners of loaded models automatically, or at least most of the corners, but I never got that far. A quick fix would be to allow the user to place down nodes at the corners for the time being.

The beauty of it is it works in 3 dimensions as well, and like you said allows for objects of any shape and position. I was pretty excited to be working on a new AI system, but I see you'll be beating me to the punch .

Goodluck with it though.
BMacZero
19
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 27th Oct 2009 15:31
Wow, that's weird . Thanks for the advice about only convex corners. I'll be sure to do that.

You're right, it is really exciting to work on something as useful as this is .

luke810
18
Years of Service
User Offline
Joined: 4th Sep 2006
Location: United States
Posted: 31st Oct 2009 01:01
I wrote this for DarkGDK:

http://forum.thegamecreators.com/?m=forum_view&t=159743&b=8

Depending on how far you are with your system you could try implementing it in DBPro.

BMacZero
19
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 31st Oct 2009 04:12
Thanks for that, it looks quite fast also. I've got so far with this one that I think I'll probably stick with it rather than trying to convert a system I don't know, but it's good to see what other people are doing .

Login to post a reply

Server time is: 2025-08-08 06:18:56
Your offset time is: 2025-08-08 06:18:56