The shortest distance between two points is straight line (Pathing question)

Started by AnActualDuck, November 01, 2016, 11:55:19 PM

Previous topic - Next topic

AnActualDuck

So yeah, what's the deal with pathing? Why do people rarely take a straight path? I notice frequently people will travel in an arc to get to a destination rather than going straight to it. I hope other people know what I mean. Not necessarily a perfect arc but I mean they will rarely just go in a straight line from point A to point B.

I didn't think much of it but it recently caused me some major issues when I was attempting to send some guys around a group of mechanoids and had they traveled in a straight line they'd not have been noticed, but for some reason the pathing drew a path that arced towards the mechanoids even though it was not the most efficient travel route.

I'm mostly just curious what controls pathing and why colonists don't necessarily always travel in a straight line even if that would be the shortest distance?

Bozobub

Not sure any game logic checks it for their decision-making, but did you look at the walk speeds of the surfaces in question?  Perhaps that was the fastest route?
Thanks, belgord!

AnActualDuck

You know what, I didn't even think about that. You may be correct and it's probably just that simple.

Zhentar

It's hard to explain the details of it if you aren't familiar with pathfinding algorithms, but the short version is that it intentionally doesn't try very hard to find the shortest path and strongly favors moving towards the destination, even when there are things in the way.

And to answer the question you didn't ask, try my Better Pathfinding mod here: https://ludeon.com/forums/index.php?topic=26563.0

zandadoum

Quote from: AnActualDuck on November 01, 2016, 11:55:19 PM
So yeah, what's the deal with pathing? Why do people rarely take a straight path? I notice frequently people will travel in an arc to get to a destination rather than going straight to it. I hope other people know what I mean. Not necessarily a perfect arc but I mean they will rarely just go in a straight line from point A to point B.

I didn't think much of it but it recently caused me some major issues when I was attempting to send some guys around a group of mechanoids and had they traveled in a straight line they'd not have been noticed, but for some reason the pathing drew a path that arced towards the mechanoids even though it was not the most efficient travel route.

I'm mostly just curious what controls pathing and why colonists don't necessarily always travel in a straight line even if that would be the shortest distance?

colonists use best terrain to travel. so if there is gravel at a mountain foot, they will go close to mountain instead through the middle of a swamp

ChimpX

I don't believe this is a matter of terrain type. I've been aware of this behaviour for as long as I've been playing and it drives me mildly crazy.
It's especially annoying when you go through the trouble of constructing tile roads or paths between buildings, for example,  but your colonists refuse to use them,  instead opting for slower diagonal scenic routes through your cornfields.

AnActualDuck

Quote from: Zhentar on November 02, 2016, 12:57:57 AM
It's hard to explain the details of it if you aren't familiar with pathfinding algorithms, but the short version is that it intentionally doesn't try very hard to find the shortest path and strongly favors moving towards the destination, even when there are things in the way.

And to answer the question you didn't ask, try my Better Pathfinding mod here: https://ludeon.com/forums/index.php?topic=26563.0

I'll definitely check your mod out, thanks!

Jimyoda

Quote from: ChimpX on November 02, 2016, 05:10:18 AM
It's especially annoying when you go through the trouble of constructing tile roads or paths between buildings, for example,  but your colonists refuse to use them,  instead opting for slower diagonal scenic routes through your cornfields.
Quote from: Rahjital on July 09, 2015, 03:09:55 PM
"I don't like that farmers chop people up."

Obviously she has already played Rimworld :P

Read the wiki. Edit the wiki. Let the wiki be your guide.
http://rimworldwiki.com/

Alenerel

Thats actually called desire path and the best way of designing a park or something like that is taking the shortests ways in account, instead of the "nice looking" things.

https://en.wikipedia.org/wiki/Desire_path

Jimyoda

Quote from: Rahjital on July 09, 2015, 03:09:55 PM
"I don't like that farmers chop people up."

Obviously she has already played Rimworld :P

Read the wiki. Edit the wiki. Let the wiki be your guide.
http://rimworldwiki.com/

ChimpX

Actually my point is that the tiled path I'm referring to *is* the shortest, direct, straight-line route between points A and B, but I  see my colomists regularly wander off it, through unpaved (slower movement rate) terrain, then back onto it, meandering their way from A to B.

I've been seeing them do this even before beer and drugs were in the game, so it can't be that.

Maybe it's by design to have a certain randomness in the pathing. Still, it doesn't seem right.

AnActualDuck

Quote from: ChimpX on November 02, 2016, 10:06:22 AM
Actually my point is that the tiled path I'm referring to *is* the shortest, direct, straight-line route between points A and B, but I  see my colomists regularly wander off it, through unpaved (slower movement rate) terrain, then back onto it, meandering their way from A to B.

I've been seeing them do this even before beer and drugs were in the game, so it can't be that.

Maybe it's by design to have a certain randomness in the pathing. Still, it doesn't seem right.

I caught what you meant. Definitely check out that mod that was linked, it seems to address the issue. I haven't gotten to mess with it yet but if it works as described it should help.

ZestyLemons

Quote from: ChimpX on November 02, 2016, 10:06:22 AM
Actually my point is that the tiled path I'm referring to *is* the shortest, direct, straight-line route between points A and B, but I  see my colomists regularly wander off it, through unpaved (slower movement rate) terrain, then back onto it, meandering their way from A to B.

I've been seeing them do this even before beer and drugs were in the game, so it can't be that.

Maybe it's by design to have a certain randomness in the pathing. Still, it doesn't seem right.

Could you provide some examples of your paths? Are colonists just going for a walk, or doing work tasks?
Help out with the wiki!

Steam: http://steamcommunity.com/id/Divaya/
Wiki: http://rimworldwiki.com/wiki/User:Zesty

Feel free to contact me about wiki questions or wiki admin stuff.

Oragepoilu

Quote from: ZestyLemons on November 03, 2016, 12:50:27 AM
Quote from: ChimpX on November 02, 2016, 10:06:22 AM
Actually my point is that the tiled path I'm referring to *is* the shortest, direct, straight-line route between points A and B, but I  see my colomists regularly wander off it, through unpaved (slower movement rate) terrain, then back onto it, meandering their way from A to B.

I've been seeing them do this even before beer and drugs were in the game, so it can't be that.

Maybe it's by design to have a certain randomness in the pathing. Still, it doesn't seem right.

Could you provide some examples of your paths? Are colonists just going for a walk, or doing work tasks?

There is little point to make a screenshot, as it's really simple to see this "problem".

Tynan is also perfectly aware of this. Pawn always go for the "straight" path, and on anything but short path choice, they won't use the path you could expect.

For instance,
If you have a (B)ase, an (E)ntrance, a mountain in front of it (at some distance, say 100 tiles) and only one quick way to go trough it with a straight line from your base to this way.

BBBBB E BBBBBB
------------------
------------------
------------------
------------------
MMMM W MMMMM
-1----------------
(1) if the thing they want isn't aligned, they ignore the straight line and go in diagonal to be the CLOSER possible quickly to (2). Then the path system find they can't just keep in diagonal to reach it because of the (M)ountain, check around, find the (W)ay and go to it (in diagonal, again). In the end, they avoid using a straight line, regardless of the speed.


On a very short range, they do try to avoid being slow, but on long range as they don't "see" really far.

The mod help a lot for this, but also impact the performance. Obviously it impact a lot during raid, but as you are likely stuck with the normal speed, it's not THAT much a big deal.

bclewis

Quote from: Zhentar on November 02, 2016, 12:57:57 AM
It's hard to explain the details of it if you aren't familiar with pathfinding algorithms, but the short version is that it intentionally doesn't try very hard to find the shortest path and strongly favors moving towards the destination, even when there are things in the way.

And to answer the question you didn't ask, try my Better Pathfinding mod here: https://ludeon.com/forums/index.php?topic=26563.0

Does your mod use standard Dijkstra algorithm?  If so I'll definitely consider checking it out although I resist modding.  The default pathfinding in this game is one of the few things that seriously bugs me.