• Advertisement
Sign in to follow this  

How To Block(Cost)Cells Based on the Terrain ready for A* path finding.

This topic is 2169 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello All.

I would like to know how to work out the cost(or blocking) of each cell based on the terrain under the cell.
What I have is a grid of cells that overlay's the terrain. This I will use the A* algorithm on, but I need my cells set up based on the terrain.
I have a image that has the terrain and the grid overlyed onto the terrain with black dots to show what I mean.
Like I want the unit to walk up the ramp but not the cliff wall and on the ridge. But the ridge cell covers to whole of the top(See Image).
How to handle that sort of thing

Share this post


Link to post
Share on other sites
Advertisement
Calculate the slope between adjacent cells and then construct a formula to convert that slope into a movement cost. If the slope exceeds a certain value, the terrain is too steep and you can simply treat that cell as inaccessible.

In my current project I actually use the height difference, since the slope is deltaHeight/deltaX and deltaX is always 1 in my case. If it exceeds 1m, which corresponds to a 45 degree angle, I consider the cell to be inaccessible. Otherwise I multiply the current movement cost (calculated from factors such as the terrain underfoot) by 1 + deltaHeight. So at maximum it increases the movement cost of that tile by about 2x. That might not be realistic, but in testing its behaviour looks ok to me at the moment.

I should mention this is for creatures walking around. Slope affects vehicles much more severely I believe.

Share this post


Link to post
Share on other sites
Only one reply thanks.
You know the articles don't talk about setting up the cost and things.
rolleyes.gif

Share this post


Link to post
Share on other sites
I'm sorry but I've seen way too many people acting as if this community owes them their time. This is FREE advice you're getting here, try to respect it a bit better. One reply is better than none.

His advice is sound. There is nothing wrong with it. Perhaps if you provided a little more information about your A* implementation then people would be able to tailor their answers better to your... ability... to comprehend.

I sounds to me like you're using an A* algorithm that was coded by someone else and you don't really understand how it works.

There is a great section on pathfinding here:
http://theory.stanfo...ameProgramming/

Specifically to costs:
http://theory.stanford.edu/~amitp/GameProgramming/MovementCosts.html

This is all I needed to write any pathfinders I've ever wanted.

Share this post


Link to post
Share on other sites
firstly I would like to thank you for your time and link. As I don't have that a* link in my collection of links on a*.

And I am part of this community as well and I hope I have helped others.

and No I have not stolen some ones A* algo. This will in fact be my second A* algo, My first one only used blocking or not blocking and it was on a smaller scale then the one
I need now as my cells are larger.

And a point for you in future is not to assume things, It will just make you and me look like an ass.

Share this post


Link to post
Share on other sites
now back to the problem at hand.
See the cliff at the left top the cell covers the top and the wall of the cliff how should I handle that sort of thing besides making smaller cells.
I want the units to go up there if they need to. thanks.

Share this post


Link to post
Share on other sites

now back to the problem at hand.
See the cliff at the left top the cell covers the top and the wall of the cliff how should I handle that sort of thing besides making smaller cells.
I want the units to go up there if they need to. thanks.

If you want to deal with variable size pathfinding nodes then perhaps it's worth looking into using Quadtree nodes for pathfinding.

This isn't a completed algorithm (and it's not my video either) but this demonstrates the idea well:
[media]
[/media]

This may or may not be helpful:
http://www.stanford....pen_terrain.pdf

Essentially, from the sounds of it, you're looking for pathfinding on a variable-size grid. If not, then I can think of only two other options. Place custom nodes manually or make the grid finer.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement