• 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.
Sign in to follow this  
Followers 0
latch

Is there anything faster than A* pathing?

13 posts in this topic

If you try to do path finding on a target that's not reachable the A* algorithm iterates through every possible square in the scene, which is very slow. To solve that I use floodfill to check that the target is reachable. The floodfill checks that both start and target squares are both in the same area.

1

Share this post


Link to post
Share on other sites

Things faster than A* include, for example, summing two numbers, calculating a dot product or doing nothing at all. Most problems have many good solutions, and the best one must be picked by you depending on the specifics. And even better than a good solution is avoiding the problem altogether, which is also sometimes possible.

Edited by powly k
2

Share this post


Link to post
Share on other sites

If you try to do path finding on a target that's not reachable the A* algorithm iterates through every possible square in the scene, which is very slow. To solve that I use floodfill to check that the target is reachable. The floodfill checks that both start and target squares are both in the same area.

 I was thinking a floodfill type to determine a solution and then A* only the nodes floodfill evaluated when finding the target.

0

Share this post


Link to post
Share on other sites

If you try to do path finding on a target that's not reachable the A* algorithm iterates through every possible square in the scene, which is very slow. To solve that I use floodfill to check that the target is reachable. The floodfill checks that both start and target squares are both in the same area.

 

If your data is static enough you can just pre-calculate 'islands' so that you never do any work evaluating impossible paths.

 

For the OP, the key is really understanding your problem domain. E.g. On a simple top-down driving game, your 'pathfinding' could be as simple as caching a direction/speed vector for every point on your map. In a more general case though, A* is pretty hard to beat.

0

Share this post


Link to post
Share on other sites
A*'s strong point is that its guaranteed to give you a correct answer. 
 
as i recall, it (and its variations) and slower algo's such as Dijkstra's and breadth/depth first are the only ones guaranteed to work.
 
that floodfill trick Ed mentioned sounds like a good idea, where warranted.
 
obviously there are many things you could do (including nothing) that would run faster. but they aren't guaranteed to work, the way A* and its brethren are.
 
I recall reading an article about something called jump-A* or something like that. probably one of the speedups in the list Hodgman mentioned. there they seemed to be speeding up things by having the search "jump" across open expanses of empty map.
 
personally, i've always suspected that a pathfinding AI that modeled human behavior might be a good approach, especially in those cases where A* and its ilk have difficulties, such as very big maps, lots of units, dynamic environments, areas of the map that are hidden or unknown, limited pathfinding range, etc.  i mean think about it, when we humans want to calculate a path, we don't star making maps and lists of the room in order to figure out how to get to the fridge.  or maybe we do. what we do IS similar, in that we think in terms of the goal (range to target in A*). and then we start plotting the intervening objects.  so we don't create a whole map of the room.  our map is just us at point A, and the goal at point B, and a line connecting them. then we start adding intervening objects, and adjusting the path as needed to go around them. we add objects until all intervening objects have been added, or until we add an object that makes the goal unreachable.  
 
adding an object may cause the path to change drastically (the local maxima problem). we're 3/4 of the way to the goal, then an object comes along that means the shortest path around the objects is now going entirely the other way.  humans probably also do something like add large obstacles to the map first. for convex obstacles, this would work well. for concave we probably enclose them mentally in convex shapes and solve as usual.  and we do it at 2 levels. i'm in room or area A, the goal is in room or area B. at the low level, how do i get out of room A, and in general at the low level, navigation across a given area. then at the high level, we calculate a path through rooms or areas from area A to area B.
 
implementing the low level would be pretty easy. you already have an A* map, and a start point and a goal point. you cast a ray from start to goal. if it hits a BBox on the map, you figure out whether its shorter to go left or right. given the point of impact and the BBox location and size, this is trivial. you move your ray casting point to that corner,and record that corner as a navpoint on your calculated path. then you cast a ray from there to the goal and repeat the process until you cast a ray and reach the goal. the list of navpoints generated describes the line path around the edges of the BBox obstacles.
 
but then you still have the problem of local maxima. i'm in a room with a door to the south. my goal is to the north. any attempt to go north without leaving the room first results in a wall to the north blocking me - a dead end - i'm boxed in.   there i suppose we humans do some sort of "is the goal in my room?" check first. if the goal is not in the same "area" we are, we go to high level (room) navigation to get to the correct area, then raycast our way from the door to the goal.
 
then the question is how does the high level room navigation work?
Edited by Norman Barrows
0

Share this post


Link to post
Share on other sites

A* is really one of the fastest there are, but it can be used inefficiently, for instance imagine you have 5 actors standing more or less in the same place and they all want to go to the same destination, do you run A* for all 5 actors? if so, that is inefficient, but not because A* isn't fast enough.

Another example, imagine that in order to get from A to B you must traverse a room from one door to another walking around a table that is in between both doors, barring the prescence of a mobile obstacle, such as another actor, the path within that room will always be the same, are you running A* to find out what it is every time you need to traverse that room? also wasteful, it can be pre-computed on level design and saved into the room information.

 

There are tens or hundreds of tricks like these that improve performance without resorting to an algorithm other than A*, A* is fast enough, reliable, well known and documented and simple to implement for most (but not all) pathfinding requirements, its all about context.

Your question is "clear, concise and correct." but incomplete, why do you feel you need a faster algorithm? what are you using A* for? what is the context?

0

Share this post


Link to post
Share on other sites
I was going to note Rectangular Symmetry Reduction, but that seems to already be mentioned in the link Hodgman posted.
0

Share this post


Link to post
Share on other sites

Your question is "clear, concise and correct." but incomplete, why do you feel you need a faster algorithm? what are you using A* for? what is the context?

I'm actually not going to use it at all.

 

I was looking at another devs blog and saw he used A* in his rts so I looked it up and watched a couple videos about it and was curious how the community felt about it and if there was something more epic out there.

 

The context is a mobile tank maze game for android which is a rewrite/upgrade to my first game to bring it a bit more modern. I'm drawing 225 blocks, background, shadows,  up to 200 rounds of ammo, up to 50 rockets, all the interface buttons and displays, and tracking up to ~50 enemies

 

-on a phone or tablet.

 

Those numbers are tentitive so if all continues as it is now on my testing device, I might bump those numbers up- at least the number of enemies because at full power up, my bullets and rockets pour out of my vehicle like water and cut a smexy path of destruction. And I will need my foes to catch my wrath.

 

Screenshot here.

Edited by latch
0

Share this post


Link to post
Share on other sites

I have a grid based A* that uses an unordered list (written in C), it is the slowest implementation of A*.

 

In a 695x132 grid test grid, it takes 15138 microsseconds to find a path from the uppermost part to the bottom (running on a core 2 duo 8400, ubuntu 32 bits). Realistically, the monsters (that use the pathfinding) can only see as far as 20 cells, so this is the maximum size of a path in my game (which takes 54 microsseconds).

 

Answering your question: A* is an algorithm find the lowest cost of going from one node to another, using edges as connections, in a graph. For this problem it is the fastest algorithm you can find. The problem of pathfinding is not the same problem as the one that A* solves, it can merely be reduced to it. So you can use particular properties of the pathfinding to improve its performance (for instance, if someone asks for a very big path, you can break into multiple smaller paths, you can reuse paths for units that are close to each other, you can have a region map to instantly solve unreachable paths and many others).

 

If I were you I would try a very simple A* implemetation and see how it goes, then either try to improve it or limit the action radius of the agents.

Edited by KnolanCross
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0