• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

This topic is now archived and is closed to further replies.

BeanDog

simple pathfinding

21 posts in this topic

I''ve got an array of about 256x256, which stores, among other things, an array of bool''s that say whether or not my unit can move there. How can I make a very good pathfinder from any one spot to any other? ~BenDilts( NULL* AIexperience); Bean Dog
0

Share this post


Link to post
Share on other sites
You''ll want to look into the algorithm called A* (pronounced ''a star''). It is a farly simple yet powerful pathfinding algorithms. There are better algorithms but they are usually modifications to A*, and they are only needed for very long paths.

You can find a lot of info on A* at Amit''s Game Programming Information.

- WitchLord
0

Share this post


Link to post
Share on other sites
thanks for the tip.

a* seems way overkill for what I''m doing, though. I am doing a real time strategy game (very early in development). I just got my creatures to move correctly, but (go figure) they don''t go around stuff by themselves. So I was thinking, I could do a really simple algorithm, since my units can either go onto a space or not, and I store my terrain-blocked map squares separate from my unit-blocked ones. I could just do a search straight from the unit to the destination. If the search path hits some terrain, it SPLITS into two other searches going on simultaneously, one going left and one going right, and so on. If two paths ever cross, or a path hits where another has already gone, they will be eliminated. This will repeat until either the destination is reached by one path or all are dead-ended.

This may sound complicated, but it may be easier than it appears. This will only be done once per time that the unit is directed to a new destination, so it won''t slow down the game significantly. I''ll do a one-step-at-a-time procedure if it runs into another unit or building.

Any comments or suggestions?

~BenDilts( void );
0

Share this post


Link to post
Share on other sites
I know a MUCH BETTER algorithm then A* one....

but cant tell you much because its secret...as it will be incorporated in may new release of a RTS...

All i can tell is that is a better algorithm...(but not faster than yours...
yours above is the fastest...but also has some problems in a labirnth

I may be able to speak after game release...
0

Share this post


Link to post
Share on other sites
Well, thanks a TON for the info, retard. I was all excited that I got a message, and it was just you bragging your cajones off. Get a life.

0

Share this post


Link to post
Share on other sites
BeanDog, your search algorithm will work. I believe it is called either depth-first search or breadth-first search depending on how you implement it. I think you should go with that so that you can get on with your game, but later on I would recommend A* as I believe it is the best for what you are doing. And no it is not overkill, it can bring down the pathfinding processing time to perhaps 10% (educated guess) maybe even less. And that in turn allows your game to build intelligent paths for goals at farther distances.

- WitchLord

Edited by - WitchLord on May 19, 2000 8:11:47 PM
0

Share this post


Link to post
Share on other sites
OK, I''ve got a basic pathfinder working, but it is so SLOW! How am I going to get the more-complex a* to work if a simple approach works so slowly? How would I choose where the waypoints would be? I couldn''t use every block in a 128x128 grid!
0

Share this post


Link to post
Share on other sites
quote:
Original post by BeanDog

OK, I''ve got a basic pathfinder working, but it is so SLOW! How am I going to get the more-complex a* to work if a simple approach works so slowly? How would I choose where the waypoints would be? I couldn''t use every block in a 128x128 grid!


A* is a more complex algorithm but the complexity helps it be more efficient. As another example, bubble-sort is a ''simple'' algorithm but quicksort will beat it nearly every time. What you save on code, you lose on processing time, mainly.
0

Share this post


Link to post
Share on other sites
Perhaps I should define "slowly". I direct 50 units 100 squares accurately in about .5 seconds. That is still too slow for a real-time game.
0

Share this post


Link to post
Share on other sites
I think you should try to implement A* and see just how much faster it is.

Another way to speed up the pathfinding might be to divide you map into small areas that contain for example 8x8 squares, then you first use the pathfinding algorithm to find the way among these. After that you use the pathfinding on the squares in each of the areas to get the exact path.

- WitchLord
0

Share this post


Link to post
Share on other sites
Also, instead of trying to fulfill all pathfinding requests at once, consider doing it in 2 stages: the order to move a unit from A to B generates a Pathfinding request, which you add to a queue. Then elsewhere in your game loop, the Pathfinder picks off these requests and deals with them. You can then limit it to only dealing with 10 requests per frame, or limit it to only spending a certain number of milliseconds dealing with requests. That way, your frame rate / game speed won''t have to visibly drop. The only difference is that certain units will remain still for a little while longer, but this is rarely an issue when you have 50 moving at once.
0

Share this post


Link to post
Share on other sites
Hi

I''ve the same problem you have *g*

I have a* implemented, but it is still to slow to move ~100 untis. Putting pathfinding in a thread doesn''t work too (gameslowdown 99% (

what you have to do is ''cheating'', finding a way to speed it up.. I thougt about pre-calulated path (like aas in q3), but haven''t found a way to do it.

if you find an solution, i''d be grateful if you tell us/me how you did it )

safti@safti.de
www.safti.de
0

Share this post


Link to post
Share on other sites
You could speed it up A* by improving the efficieny of the implementation, preprocessing the seach space, and buffering paths found.

a)I dont know how you implemented it so i can''t comment, but if you search here http://www-cs-students.stanford.edu/~amitp/gameprog.html for some implentations of A* you can compare your implementations

b)You could do like one poster suggest and prune the search space down using a quad-tree approach, or if your more ambitious decompose your search space into a voronoi diagram.

c)Basiclly A* is computationally very intensive, and if you buffer paths you can take advantage of the coherency of start and goal postions. For instance if 2 entities start close to each other and their goals are close to each otehr too, you can compute A* for one, and use it for the other too. Just make sure you find the path from one''s start position to the others and the same for the goal, which should be computationlly smaller since they are closer. Depending upon your memeory liminitation, you could buffer in 100''s of paths which should give you signigicant performance improvements if there is good coherency. If not you get worse case, either way.

Good Luck

-ddn
0

Share this post


Link to post
Share on other sites
Sorry i see u got it too hard...my prev message to u...

hmmm i just wanted to say that even if i cant tell u (because of contracts...not that i dont want to )
to open ur mind to diffrent approach than A* with everybody thinks is best but is not....

Now i feel like i have to help u a little so u dont get mad at me:

whatever algorithm u use....
1.First
u can use it once to find the path then store all points in a vector then use that vector to move units until eventually a obstacle is found...in this case redo the pathfind....
2.Second
Dont do "whatever algo u use" for all units at once...better do one unit at a cycle...
so if u have 50 units unit 1 will start then next cycle unit 2 will start...u get the picture....this will make units remain a little late....but ALL Realtime games make it one way or the other...

Hope this helps
Sorry again didnt wanted to make u mad....

Bogdan
0

Share this post


Link to post
Share on other sites
Check out my pathfinding algorithm. Totally precalculated and definitely the worlds fastest pathfinding algorithm .

http://www.kolumbus.fi/hannes.k/tip2b.htm

Well my algorithm isn''t maybe simple to implement, but it''s hell fast. It takes only one memory read to move a unit one step towards it''s goal, using almost optimal path!

The idea behind it is quite simple though and needs lots of thinking still, but you might be interested. Dynamicy is a problem with this algorithm, because everything is precalculated. However, it IS possible to make dynamic parts but it needs some extra work if there are dynamic parts on the route..

The algo can also solve any maze and no matter how complex map, equally fast.

-Hans
0

Share this post


Link to post
Share on other sites
Hey,

Last year I did a project on this topic with a few friends for my course Datastructures & Algorithms II.

It features a state of the art report on holonomic motion planning with several basic algorithms.

There''s one drawback, the project is written in Dutch (sorry guys), but I''ve also added a Visual Basic program which should visualize what I do and the algorithms are open-source.

Let me know what you think about it!

******************************
Stefan Baert

On the day we create intelligence and consciousness, mankind becomes God.
On the day we create intelligence and consciousness, mankind becomes obsolete...
******************************
0

Share this post


Link to post
Share on other sites
Woops, you can access the page form my homepage of course, but here is the direct link:

http://www.softline.be/StrategicAlliance/RUG/MotionPlanning/

******************************
Stefan Baert

On the day we create intelligence and consciousness, mankind becomes God.
On the day we create intelligence and consciousness, mankind becomes obsolete...
******************************
0

Share this post


Link to post
Share on other sites
If you want to speed up A* a little, you can put a limit on the number of
precalculated waypoints that you can do. So if you have a very long path,
for example, from one side of the map to the another, the unit will precalculate
a couple waypoints, follow that path, and then precalculate another, etc..
until it reaches its target.

The only downside to this is that if you limit the number of waypoints too
much, the unit might not be able to get out of a tight space like a half
circle area.

Another speedup is limiting the number of directions that the unit can use.
16 directions is kinda slow, 8 directions is ok, but using only 4 directions
is much faster. It''s computationally less searching.
0

Share this post


Link to post
Share on other sites
OK, here''s how I do it. I have a search algorithm that goes directly toward the goal until it hits something. Then it splits up into 2 searches, going opposite directions around the obstacle. As soon as a dead end is it, that search is eliminated. This is a very fast method. When you first move a creature, I calculate the first about 50 squares in the path and store them in the creature itself. When it gets to the end of that 50, I calculate the next 50, etc until the unit gets to the destination. This is pretty darn fast, but not fast enough. I will try implementing how I will just do one per frame, but that will be a problem when the units get to the end of their 50-square process and have nowhere to go.

Thanks for all the advice, and when I have time I''ll check out your super-fast algorithm, Hans. I have a feeling it will be very memory- intensive, though, especially for large maps (256x256 and up).

~BenDilts( void );
0

Share this post


Link to post
Share on other sites
OK, I think I get the idea of the region search. Only problem is, what happens when the path from one region to another is totally blocked by dynamic units?

Also, how would you calculate the arrow paths from each region to the surrounding ones if the regions aren''t convex?

Hey! I''ve got an idea. If your map is divided into regions, you only have to store the paths to each of the SURROUNDING regions, and store the paths (in regions) for the farther paths. That way, you would have to do maybe 3 memory checks (oh darn) per iteration, but you wouldn''t have to store all 500 values for arrows, just, say, 15. that would be 256x256x15, or less than a meg, plus a little for the paths to each region, 500x500 array (for the next region to go to from one region traveling to the destination region). You get my vision?

~BenDilts( void );
0

Share this post


Link to post
Share on other sites
One way to do it would be to compute paths around obstacles as lines. Then store all the lines in a structure that has waypoints (points along the line) and connections to other lines. Then, to make something move anywhere in your world tell it to move along the lines. Doing it for all obstacles may be a bit excessive so my suggestion would be to compute the lines only around objects of a given (larger) size and use another solution for actually reaching the waypoints, because there may be a small obstacle between the thing you want to move and the nearest way-point.
0

Share this post


Link to post
Share on other sites