Jump to content

View more

Image of the Day

The night is still, but the invasion brings chaos. #screenshotsaturday #hanako #indiegame #gameart #ue4 #samurai https://t.co/cgILXuokoS
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

Sign up now

About to implement A*, have some questions and need tips :)

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 crovea   Members   


Posted 22 July 2012 - 03:39 AM

Hey! I'm in the process of creating a game engine (who isn't, amirite) for top-down sprite 2d games with alot of units. (such as moba's and RTS games, diablo and scbw was made this way more or less).

So one of the last things i need in my physics subsystem/subengine is pathfinding, where i plan to use the A* algorithm which requires a grid(?).
I plan on using a tilemap for static obstacles (some kind of map loaded from a picture, showing which parts of the map are walkable, possibly using a quadtree)
And my already existing collision detection grid for semi dynamic obstacles (such as buildings, trees, craters, etc)

As mentioned, I use a variable size grid for collision detection. I initialize the grid field size to a size that is atleast the size of the largest units collision box.

Q: Which leads me to my first question, wouldn't this kind of grid be too big to also use for pathfinding? (maps will be much larger than a screen)
Q: Also with the size of the grid fields being variable from game to game, wouldn't that result in different and sometimes bad behavior?

1. Option would be to split the grid i already have into smaller fields.

Q: But with dynamic size grids, how would i go about partitioning it?

Alternatively, if the existing grid isn't usable i see two other options:

2. Create a new grid for pathfinding with fields always of the same size. (a pretty decent chunk of memory would be required)
3. Try an approach where i dynamically build fields/nodes based on coordinates. The objects could be pulled from a pool to improve performance.

Q: Is option 2 actually feasable? or am i missing something essential from A* that makes it unreasonable.
Q: Would option 1 actually be worthwhile despite the memory cost, due to being easier/simpler/faster?

Any advice, tips or experiences are welcomed Posted Image

Edited by crovea, 22 July 2012 - 06:50 AM.

#2 IADaveMark   Moderators   


Posted 22 July 2012 - 11:49 PM

A* doesn't require a grid, per se. It requires a connected graph of nodes. Those nodes can be a grid or they can be anything arbitrary. As long as you know the edge length between them (or they are all the same), then A* works.

As for the map being too big, you can easily path through 1000x1000 grids with not too much trouble. However, that said, hierarchical approaches tend to work good for trimming the search space. You get to keep your granularity but speed up long-distance searches.
Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC

Professional consultant on game AI, mathematical modeling, simulation modeling
Co-advisor of the GDC AI Summit
Co-founder of the AI Game Programmers Guild
Author of the book, Behavioral Mathematics for Game AI

Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

#3 r1ckparker   Members   


Posted 24 July 2012 - 01:58 PM

This link helped me out when I was doing mine. There's information there on pathfinding in non-square search areas and also using waypoints instead of a grid


Here's my implementation


Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.