• 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
Eddie Watson

Modified movement cost using A*

7 posts in this topic

Hi all. I'm new to posting to the forum here but have been using the site as a reference source for answering questions for some time. Hopefully I can get some insight into this question I haven't been able to find a good answer to.

I am developing a realistic ww2 top down real time strategy. I am using A* for path finding but it's in it's simplest form. My game map consists of 10x10 "tiles" with a terrain type and height in meters. Eventually I will have 15-20 types of passable terrain and I want them to have an impact on speed along with going uphill or down hill. I know this will modify the cost from the normal straight/diagonal cost I'm using now.

My question is how much should I weight the cost without tipping the balance and losing the effect of the actual distance but enough to where it logically works to go the best path. Example around a large hill instead of up and over when moving fast. Now I'm not looking for an exact answer as I know it's all relative and a personal feel but I'd like to start in the right ballpark! :)

Thanks in advance!
1

Share this post


Link to post
Share on other sites

My suggestion would be to do the math.

 

Say you go up a rather steep hill that impedes your normal speed by 50%. Then you should add 50% to the cost of that node vs the normal unimpeded terrain cost. Same for grass, sand, snow, or whatever other terrains or factors you have in the game. Make the cost relative to the speed. As long as you are consistent in your math, it should work out just fine.

 

Also, if different unit types move at different speeds across different terrains, then the cost of each node should be different based on the AI unit that is performing the navigation. For example, say vehicle A moves faster through grass, but slower through sand, while vehicle B moves faster through sand, and slower through grass. These units should have different cost values for these terrains since the effect is different.

 

In the end it all comes down to math. Calculate the change in speed across a terrain for a particular unit, and apply the same percentage of change to the cost value.

1

Share this post


Link to post
Share on other sites

The rule is that your estimate in your A* function should always be less or equal to the actual cost. So if your fastest terrain type is road, then your estimate function could be the straight line road cost. All other terrain types would be more expensive and so your A* should return the optimal path.

1

Share this post


Link to post
Share on other sites

Yes, as others have said, you need a consistent unit to calculate all of your metrics as.  For instance, in your case you may want to have time as your metric that you want to minimize.  In which case all of your path calculations should evaluate as time that way you can compare apples to apples.  Another example could be distance as your metric where you are trying to minimize distance.  I don't think this is what you want, though.  So basically, first figure out the metric you want to minimize and then have all of your formulas calculate that metric. 

1

Share this post


Link to post
Share on other sites

OK that makes sense.  I was actually kind of thinking along those lines.  And just to clarify one issue.  The main points of movement are the center of the 10x10 tiles, so if I'm moving from lets say a grass tile to a sand tile, since I am moving 1/2 the time on grass and 1/2 the time on sand then I would weight each by 50% and then apply that to the normal movement cost?

0

Share this post


Link to post
Share on other sites

OK that makes sense.  I was actually kind of thinking along those lines.  And just to clarify one issue.  The main points of movement are the center of the 10x10 tiles, so if I'm moving from lets say a grass tile to a sand tile, since I am moving 1/2 the time on grass and 1/2 the time on sand then I would weight each by 50% and then apply that to the normal movement cost?

 

That's what I'm doing in my code and it works fine.

 

I believe that calculating the cost based purely on the second tile's cost (the destination tile of the pair) would probably be as valid since the next step is going to include another 50% of sand. Although there may be edge cases with multiple goal points to choose from where the simpler approach might be minutely wrong but it probably won't matter to anyone.

0

Share this post


Link to post
Share on other sites

Perfect well I'll be getting around the implementing this in a couple days and will check back in.

I think averaging the 2 tiles is best because, at least in my game, you can do diagonal movement, and if you just used the next tile, while the loss of accuracy would still be small, the cost of movement wouldn't balance out if you went diagonal and then straight (left, right, up, down) following the diagonal movement, and I think it would be big enough of a difference to throw off the accuracy of the path finder.

Edited by airborneinf82
0

Share this post


Link to post
Share on other sites

realistic terrain the heights are very important because they can slow/impede movement speed significantly (puting the object under fire in the open for longer - very nasty with WW2 firepower)

 

So the difficulty between the node should be relatve to the way the game mechanics work  (including uphill harder than downhill -- the edged costs being directional (dual values)

 

Some curve table based on the difference between adjacent nodes as a basic calculation method.

 

Depending on the complexity of the movement other factors like what kind of terrain it is (and if the SPECIFIC unit has any special advantage/disadvantage thru different terrain flavors)

 

You may wind up haveing multiple A* node maps for different unit types to reflect the different units abilities (insetad of having the edge costs recalculated EVERY  open node calculation.

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