Jump to content

  • Log In with Google      Sign In   
  • Create Account


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


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
6 replies to this topic

#1 ankhd   Members   -  Reputation: 1110

Like
0Likes
Like

Posted 07 February 2012 - 11:40 PM

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

Attached Thumbnails

  • AStarGridBlocking.jpg


Sponsor:

#2 Postie   Members   -  Reputation: 865

Like
2Likes
Like

Posted 08 February 2012 - 01:21 AM

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.
Currently working on an open world survival RPG - For info check out my Development blog: ByteWrangler

#3 ankhd   Members   -  Reputation: 1110

Like
0Likes
Like

Posted 14 February 2012 - 05:48 PM

Only one reply thanks.
You know the articles don't talk about setting up the cost and things.
Posted Image

#4 TehOwn   Members   -  Reputation: 134

Like
1Likes
Like

Posted 14 February 2012 - 06:57 PM

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.

#5 ankhd   Members   -  Reputation: 1110

Like
0Likes
Like

Posted 16 February 2012 - 12:58 AM

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.

#6 ankhd   Members   -  Reputation: 1110

Like
0Likes
Like

Posted 16 February 2012 - 01:02 AM

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.

#7 TehOwn   Members   -  Reputation: 134

Like
1Likes
Like

Posted 16 February 2012 - 09:44 AM

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:
http://www.youtube.com/watch?v=95aHGzzNCY8

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.




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.



PARTNERS