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 / Pathfinding ideas

Author
Message
Kiaurutis
15
Years of Service
User Offline
Joined: 19th Jan 2011
Location: Lithuania
Posted: 14th Feb 2011 14:07 Edited at: 14th Feb 2011 14:08
i agree there is a good pathfinding routine for dungeons and other tile based games, but what about open-space rpg or rts?
Lets say i have big plain field and want to move straight from A to B avoiding few objects (just a few). Using A* would require big arrays of tiles. It won't be efficient anyway, if object can travel only 8 directions.

here are few ideas:

1) use raycasting in few directions around object: then rotate it around obstacles or when there is no obstacle rotate it towards destination point. Moreover this won't need big arrays to hold paths, no big recalculating, all the evading process real-time. This wouldn't help to evade U type obstacles coz object would get trapped inside of U, so player would have more work to control object- no "push and forget".

2)use temporarily objects to make waypoints: place long, objects-to-be-moved-width box between A and B to see if it collides. If it does make 2 boxes and place them so they touch each other but evade obstacle and so on. if there are many obstacles this would require many boxes, but it would be faster if there are few obstacles, and distances are long. It would be some kinda a 3D collision based waypoint system. it wouldn't require recalculating if none other objects collide with "path-boxes", on the other hand it wouldn't change if path is cleared.

Plz tell what u think about them, maybe some other ideas?
IMO in simple RTS game, it would be enough of 1 st idea. User shouldn't be offended by clicking mouse few times for a difficult objects movement. RTS games rely on more thinking than moving
PS there is a picture explaining what i mean. MS Paint rulez

Join The dark Side! We have cookies
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 14th Feb 2011 16:16 Edited at: 14th Feb 2011 16:17
What about taking each object, and using it's radius, or a set radius to 'eek' around the object at a number of points around.

For example, if you have an object that is 10 units wide, project 12 points around that object at 7 units radius, like a clock. Then check for collision between the player object, and each of these points until you find the closest one. You could alter the number of points - so a square obstacle could be avoided neatly. Once you have the closest point with no collision, you could go onto the next waypoint, while the player heads towards the current one.

Most RPG games these days use preset waypoints, like a path drawn on the ground, nodes, connecting lines, intersections. Take Oblivion for example. The world in Oblivion is littered with nodes, and these tell the AI how to go around obstacles, even if it's just 1 node making all the difference - the AI will go between these nodes, deciding which one to head towards next, based on what they are doing. If they are chasing the player, it might be enough to simply find out the closest node to the player, and calculate a path towards that. Or use scent - whenever the player moves onto a new node (current node is further away for example, so find next closest node) - then mark it, maybe stamp it with a time. Then monsters will be able to track the player - by simply heading towards the node with the strongest scent. This is particularly effective and realistic, as if the player crosses their own path, it's easy to pick the strongest scent, rather than following an exact path, the AI is following the scent.

The nodes are not only used for path finding though - they can tell the AI all sorts of things - like how much cover is offered at that location, is it dark there, is that area under water, what other nodes are accessible from there, what other nodes are visible from there. The trick is to optimise the checks needed, so the AI only performs them once. Maybe for each AI entity, you have an array of 32 slots, for storing the possible nodes, and the results of any AI checks.

Anyway, I'm not great at explaining these things - I think it makes better sense for you to read this article:

http://www.cgf-ai.com/docs/straatman_remco_killzone_ai.pdf

It goes into real detail and I think you'll find it most useful - I'd go as far as to advise you to print it out and digest it slowly. I found it very inspiring, and more importantly accessible - you don't need to know AI techniques or pathfinding to learn from it. When I first read it, I was like ''Wow!, makes such perfect sense!''. I was writing a FPS at the time, so you might appreciate how useful that article was to me. It's not an easy option to have to lay nodes around and organise them, but I think it's the best possible option.

Health, Ammo, and bacon and eggs!
Kiaurutis
15
Years of Service
User Offline
Joined: 19th Jan 2011
Location: Lithuania
Posted: 14th Feb 2011 19:03
Quote: "check the corresponding trajectories with (expensive) ray casts"

is raycasting "expensive"?
method of evading obstacles with raycasting still looks attractive for me, but if it uses lots of resource...

can U plz paint some scheme about clock thing? i don't really understand it...

what is written in Killzone AI tutorial, it looks similar to Pathfinding A*. For smooth moving there should be many nodes, and as i am aiming at realistic RTS with objects being small and ranges long, compared to other RTS, it would need huge quantities of nodes, and objects still can't be positioned acurately to each other. one of thing that annoys me in casual RTS games is, lets say tank fire range is 3-5 times longer than tank itself.
Maybe that what i want is unrealistic from view of programing?

Or maybe i don't understand this solution enough... how objects move between nodes? do they stop only in nodes? if not, how it is considered where to stop between nodes? can they travel only in lines between nodes? what if weapon is dropped in middle of tile, could AI player reach it by stepping out of path line? these questions aren't covered in that article... i need more knowledge

Join The dark Side! We have cookies
enderleit
19
Years of Service
User Offline
Joined: 30th May 2007
Location: Denmark
Posted: 16th Feb 2011 13:13 Edited at: 16th Feb 2011 13:14
X X X
X O X \-------- P
X X X

O = Obstacle
X = Nodes
P = Player

Think he means something like that....

Kiaurutis
15
Years of Service
User Offline
Joined: 19th Jan 2011
Location: Lithuania
Posted: 16th Feb 2011 14:31
Quote: "Then check for collision between the player object, and each of these points until you find the closest one."


these must be objects to check collision, so i would have to make many additional collision objects for every real object. I can't imagine what Van B want to say: why do i have to find closest point? what to do when have closest point?

Join The dark Side! We have cookies
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 17th Feb 2011 16:55
OK, I have done quite a bit of research, and I'm going to base my answer on the pathfinding in StarCraft 2, because that has got to be the most beautiful pathfinding I've ever come across...

What I've found is that StarCraft 2 uses an advanced version of A* pathfindinig, called the "two-tiered A* pathfinding". What this means is you have a high-dense grid for small distances, and a low-dense grid for large pathfinding such as crossing the entire map (Two-Tiered A*).

To reduce processing for paths, the units that have a common destination are grouped together, and only follow a single path using flocking.

And there you go, hope that helps you

TheComet

Kiaurutis
15
Years of Service
User Offline
Joined: 19th Jan 2011
Location: Lithuania
Posted: 17th Feb 2011 20:31
Two-tiered A* looks like a good solution. First of all i go to learn how to make working simple A*

Noone still gave answer about ray casting: is it expensive?

Join The dark Side! We have cookies
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 18th Feb 2011 08:33
It depends on how many ray casts you do. I started a FPS ages ago, and used ray casting for the enemies - a ray to the player to check for visibility mostly, so not too many checks. My chief concern would be about how effective that would be for path finding, or even just object avoidance. Even if you got it working so the enemies walk around obstacles, they probably wouldn't look too clever doing it. It might be possible to use a hidden version of the map made from just cubes, then at least you wouldn't have to deal with complex geometry and it should be much more reliable. Maybe use that for player collision, and use the standard detail geometry for bullet collision. Ray casts are a lot 'cheaper' when you use low detail meshes.

That's why so many games have zombies in them - nobody minds if your zombies stumble about the place all stupid like.

Health, Ammo, and bacon and eggs!
Wyldhunt
16
Years of Service
User Offline
Joined: 27th Sep 2009
Location: The Dark Side
Posted: 18th Feb 2011 12:43 Edited at: 18th Feb 2011 12:54
A* help:

I've not tried these yet, but I've been meaning too. Not sure if the DLL link is even valid still...

But, here ya go. If you get them to work, let me know how it turns out.

http://forum.thegamecreators.com/?m=forum_view&t=114240&b=5
http://forum.thegamecreators.com/?m=forum_view&t=10057&b=6
EDIT:
Oh, and this may help you out:
http://www.thegamecreators.com/?m=codebase_search_global&sc=summary&te=path&ca=&la=&ma=25
Lots of good stuff in the codebase.
Kiaurutis
15
Years of Service
User Offline
Joined: 19th Jan 2011
Location: Lithuania
Posted: 18th Feb 2011 12:59 Edited at: 18th Feb 2011 20:35
I have now working code to rotate smallest angle to destination coordinates and move towards it. It works nice, but doesn't evade other objects. What i am dreaming about atm is to join my code with something like this
http://www.red3d.com/cwr/steer/Containment.html
or this
http://www.red3d.com/cwr/steer/Obstacle.html
and this
http://www.red3d.com/cwr/steer/Unaligned.html

it would look like this:



It looks quite simple. I tried to make one raycast, and it returns collision object. Now what i need is to make my box evade the object. If i use 3 rays i can know which direction to turn if collision occurs on one of side rays, but how to determine where to turn if collision happens on middle ray, or all three rays?
if i ray cast one ray at each cycle of program it would be faster, although it is more difficult to handle direction to be rotating

i use this function to move for each object:



this is the easiest case for a tank- it can rotate while not moving. there will be much more headache when i start moving wheeled vehicles, who can rotate only while moving.

By the way, this is standalone function which only needs to have vehicles parameters: object that belongs to vehicle, destination coordinates (dx,dy,dz), Speed, MaxSpeed, RotationSpeed. It can be used to travel between waypoints

[EDIT]

@Wyldhunt

I go check what your dll can do. Download link works fine

[EDIT2]

Objects intersect I need to evade objects so basic pathfinder doesn't help. Recalculating pathfinding map for each cycle depending of objects movement may be slow
but that's great dll

Join The dark Side! We have cookies
Kiaurutis
15
Years of Service
User Offline
Joined: 19th Jan 2011
Location: Lithuania
Posted: 18th Feb 2011 21:07
i tried to make Proteus's pathfinding A* to work in 3d, but that code is quite messy. I stuck in having some misunderstanding between painted tiles and my tiles-objects on 3D plain. In some coordinates both tiles move the same, but mostly painted tiles do whatever they want, ignoring 3d boxes movement



That's not a bad start anyway

I wonder why there are no (or i didn't find any) pathfinding step by step tutorials? most tutorials show the main idea of pathfinding, but not the exact procedures, functions to make it.
I can understand that proteus's functions search for a path, then store it in some variables and later show it, but have no idea how it is done.... there are lots of lines in A_star function, some of them are commented, but it looks like jungle for me and as a rule the thread is locked so i can't ask about it, author disappeared in 2008 too

Join The dark Side! We have cookies

Login to post a reply

Server time is: 2026-07-17 13:59:15
Your offset time is: 2026-07-17 13:59:15