Logistic bot pathing improvement

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

Post Reply
Coolthulhu
Fast Inserter
Fast Inserter
Posts: 201
Joined: Thu Apr 04, 2013 9:55 am
Contact:

Logistic bot pathing improvement

Post by Coolthulhu »

Post might look a little convoluted, but it's pretty much a complete algorithm that would make bots not take breaks from their jobs just to recharge.

Current:
  • Bot picks job
  • Bot reaches low energy
  • Bot panics and runs to port
  • Bot continues job
Upgraded:
  • Bot picks job
  • Bot measures distance to target
  • If ((distance/speed)*energyConsumption>lowEnergy), does pathfinding with ports (and start and destination) as nodes
  • Repeat when destination changes
Only exception would be player character (only moving destination). That would have to be recalculated once in a while. For cheap pathfinding, it could be even every frame (A* with 100 nodes is next to nothing) or every reached port. For more clever version, it could be recalculated if player has left range of the last roboport bot wanted to take by the time bot reaches any roboport.

Cheap pathfinding:
Each port is a node. Start and end are also nodes.
Each node has at most 8 edges - in 4 orthogonals and 4 diagonals. Edges are created by picking closest node in that direction, as long as it isn't already an endpoint of other edge.
That way all connected roboports could be reached, but the path wouldn't be optimal.

Perfect pathfinding:
Nodes the same as above.
Each port node is connected to all port nodes reachable by bot with full energy. Start and end nodes are an exception: end needs to be reachable with enough energy to reach a port from it, start can have less energy than full.

That's basically it. Even the perfect pathfinding version should be cheap enough not to be noticeable even on older computers.
There could be many easy improvements to both performance and functionality here, but I'm pretty sure even now it would be easy to implement, fast enough not to be noticed and would solve the tendency of bots with low energy to both overestimate and underestimate their capabilities (and either die in action or change direction 0.3 meters before chest).

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12888
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Logistic bot pathing improvement

Post by ssilk »

Why do you think, the current algorithm needs to be enhanced? Which reason?
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

FishSandwich
Smart Inserter
Smart Inserter
Posts: 1847
Joined: Sun Feb 23, 2014 3:37 pm
Contact:

Re: Logistic bot pathing improvement

Post by FishSandwich »

The only reason I can think to do this, is because bots waste a lot of time. But it seems that something like this would get sorted out while they do polish, which isn't an alpha thing..

Coolthulhu
Fast Inserter
Fast Inserter
Posts: 201
Joined: Thu Apr 04, 2013 9:55 am
Contact:

Re: Logistic bot pathing improvement

Post by Coolthulhu »

Bots at the moment often act stupid to the point where it looks almost like a placeholder behavior. They break to recharge 3 meters from their destination, go 50 m to roboport to recharge and once again 53 m to chest. It worked just fine when they didn't need to recharge, but then new features were added (roboports) and old behavior became kinda lacking. Bots clumping next to roboport to recharge were worked around, but a proper pathing could be an actual solution to the problem instead of just making the problem less pronounced.

For example, by implementing pathing with something like Simcity's congestion (overused nodes get penalized), you could almost entirely eliminate bots queuing up to recharge in most factories, without making them transport slower (they'd work faster in fact).

sabriath
Inserter
Inserter
Posts: 26
Joined: Fri Jan 10, 2014 6:49 pm
Contact:

Logistics Robot Pathing

Post by sabriath »

Bot sees something to do, bot goes to do it....oh crap, out of power, find nearest connection point and head that way....what was I doing? Not very fancy for "smart" entities to not look ahead of time.

My suggestion is to change the pathing mechanic of the robots slightly, to the following "flowchart":

1. Robot is assigned a task (whether it is to go pick something up, drop something off, or build/deconstruct/repair/whatever)
2. Calculate distance to task, if range is less than power usage, then affirm task and finish...otherwise
3. Calculate position 'F' on the line segment between here 'H' and task 'T' to where power fails. F = Power * PowerPerPixel * (T - H)
4. Calculate closest power station 'S' based on the eliptical focal distance between F and H, such that d(FS) + d(HS) is minimized.
5. Place the task on secondary, assign charging at that power station as the current task, affirm task and finish

If a robot finishes a task, it checks for a secondary and repeats the above steps, otherwise it places itself back in queue for another job. If at 90%+ power and task cannot be reached, it places the task back on the queue and itself back in queue for another job.

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12888
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Logistic bot pathing improvement

Post by ssilk »

I joined the above thread, cause both want essentially the same and point out about the same algorithm.
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

bobucles
Smart Inserter
Smart Inserter
Posts: 1669
Joined: Wed Jun 10, 2015 10:37 pm
Contact:

Re: Logistic bot pathing improvement

Post by bobucles »

Ain't nothing wrong with wanting smarter bots. It is a bit weird how they'll take on a job that very predictably will force them to recharge, but don't stop to recharge along the way.

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12888
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Logistic bot pathing improvement

Post by ssilk »

The devs already have such plans in their backlog. But I think not very high prioritized, cause you can live very well with the current behavior. Except when you want to transport many things at a time.
I think also that this suggestion is just one aspect of the problem. The problem is, that players tend to create too big logistic networks.

There is a suggestion called "colored logistics" or
https://forums.factorio.com/forum/vie ... =67&t=8905 Overlapping Logistic Network II
Which is eventually able to solve this problem from another aspect of view.
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

bobucles
Smart Inserter
Smart Inserter
Posts: 1669
Joined: Wed Jun 10, 2015 10:37 pm
Contact:

Re: Logistic bot pathing improvement

Post by bobucles »

players tend to create too big logistic networks.
Logistic coverage has ONE large size, so fine tuning network coverage is difficult. Bots will still rush towards tasks they can not complete, even with a modestly sized network.

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12888
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Logistic bot pathing improvement

Post by ssilk »

Therefore the linked suggestion: The bots can then prefer to make first work in the current network, before they change into another direction. It is nothing else than a localization needed.
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

Peter34
Smart Inserter
Smart Inserter
Posts: 1100
Joined: Mon Nov 10, 2014 12:44 pm
Contact:

Re: Logistic bot pathing improvement

Post by Peter34 »

bobucles wrote:Ain't nothing wrong with wanting smarter bots. It is a bit weird how they'll take on a job that very predictably will force them to recharge, but don't stop to recharge along the way.
Dumb bots are annoying.

But they're cheap to make. Each gets only one internal circuit board (either red or green one) for a brain. So should we really expect so much of such primitive bots?

Or should there be two tiers of bots, simple bots for the mid-game that are similar to the ones we have now in behaviour and in cost, and advanced bots that are for the late game but which cost much more to build in exchange for having a notably more intelligent behaviour?

The main problem with that idea is what to do with the tier 1 bots once tier 2 has been invented. I think the least bad solution is that old Factorio staple, of requiring tier 1 bots as one of the mats for crafting tier 2 bots. That way, nothing is wasted, and so players won't sit there feeling sour.

Post Reply

Return to “Ideas and Suggestions”