Jump to content

  • Log In with Google      Sign In   
  • Create Account


Pathfinding in a TBS


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 Dragonsoulj   Crossbones+   -  Reputation: 2035

Like
0Likes
Like

Posted 07 June 2013 - 01:23 PM

So I've been trying to plan out a turn-based strategy game, and was thinking about unit movement, with suggestion options to a player and to handle a computer player's choices. I was thinking of using a simple A* method to find the shortest route to the desired space. Since a space can be advantageous or problematic, would just adding an extra variable to the heuristic help in avoiding certain regions and moving towards others? For example, assuming a unit can move say 10 spaces a turn, and units could potentially be hiding in specific terrain, a unit would want to walk around the terrain a unit can hide in (like woods), so they don't run into a dangerous space. Would just rating the movement cost higher for that space be enough?



Sponsor:

#2 Paradigm Shifter   Crossbones+   -  Reputation: 5232

Like
0Likes
Like

Posted 07 June 2013 - 01:29 PM

Probably, although they would rarely take a shortcut through such terrain then, choosing to take the long way around. If the target space is in the terrain, they will probably search a much larger number of spaces before they find the correct route as well. Maybe you want to adjust the terrain cost based on how many dangerous units are available to the opponent that can use the cover?


"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

#3 Dragonsoulj   Crossbones+   -  Reputation: 2035

Like
0Likes
Like

Posted 07 June 2013 - 01:39 PM

The current idea is I have a map that has a few terrain elements units can hide in during FoW. I'm trying to come up with a way to traverse around those spaces, instead of walking through them (walking through could trigger either a surprise attack or a full halt of the unit that is moving). Enemy unit count and units able to hide in that terrain is not known.



#4 Paradigm Shifter   Crossbones+   -  Reputation: 5232

Like
1Likes
Like

Posted 07 June 2013 - 01:48 PM

Well yeah, just give the terrain a high movement cost then, they will avoid it then if there is a less expensive route available.

 

If the goal space is inside that terrain though you probably want to reduce the movement cost penalty for the terrain of that type which is connected to the goal?


"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

#5 Dragonsoulj   Crossbones+   -  Reputation: 2035

Like
0Likes
Like

Posted 07 June 2013 - 01:59 PM

I think a function that creates a "terrain evaluation" would work for adding an additional value to the movement cost. Keep the terrain danger value but add in a negative due to it being a goal space.

 

Thanks for the advice. I'll have to see how things pan out as I go.



#6 Paradigm Shifter   Crossbones+   -  Reputation: 5232

Like
1Likes
Like

Posted 07 June 2013 - 02:27 PM

Don't reduce the value of all the terrain that is the same type as the goal though... either the terrain of the same type that is connected to the goal (floodfill), or maybe based on the distance from the goal as well, so you try to path through as little terrain of that type as possible to reach the goal.

 

Reducing just the goal space and no others is useless since if there is a finite cost the A* algorithm will find the path to the goal; it will just search more and more nodes trying to find it. You probably want to give a negligible cost to all spaces right next to the goal though so if you are right next to it in your search you go that way first.


"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

#7 Dragonsoulj   Crossbones+   -  Reputation: 2035

Like
0Likes
Like

Posted 07 June 2013 - 05:19 PM

Reducing just the goal space and no others is useless since if there is a finite cost the A* algorithm will find the path to the goal; it will just search more and more nodes trying to find it. You probably want to give a negligible cost to all spaces right next to the goal though so if you are right next to it in your search you go that way first.

 

That's a good point. I guess I wasn't thinking that part through all the way. rolleyes.gif That's why we plan things out, right?






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