Transportations ideas; Horses, Minecarts,Boats

But doesn’t that work with a simple:
-place down chest
-load chest
-pick up chest and move it
-place chest down
-unload chest.

It works, but only as much as Hearthlings care about moving the chest. That always seems to take a while for me.

You don’t need to make the minecarts or wagons about pathfinding. For minecarts, you just set up a route hooked up to a storage facility and the minecarts will transfer whatever is in the storage facility to another point on the map. As such, you could do the same with a wagon or caravan, you set up a route between two storage points where it goes back and forth, and hearthlings only have to focus on bringing materials to either of the storage points.

It doesn’t matter how much you simplify minecarts. Even if you say that a minecart network only consists of two stations, which are linked directly, without more stations or junctions or anything, you will need a pathfinder simply because… when do you use a minecart, and when do you not?

Let’s imagine the following setup:

(Area A) - (Station A) - Tracks - (Area I) - Tracks - (Station B) - (Area B)

You can’t say “Take items at station A, and deliver items to station B”. Because that will lead hearthlings to pick up items at B, walk to A, and drop them again - rinse and repeat.

Even if you say “Do not take items that are from the other station”, you still have the issue of items from area B being taken to station A, then loaded onto minecarts, then dropped at station B (if, for example, all inventories in area B are full, but station A has still capacity and is the closest “inventory”).

Even if you say “Do not take items that are closer to the other station than to us”, you will end up in problem because you’re interfering with the flow of items from A to A, or I to A. Let’s say there’s an oak log in area I, close to station A. There’s a chest behind station A (from the point of view of the log) that it wants to get to - but the first valid inventory it finds is the station. The station says “Yepp, I transport oak logs”, upon which the log is transported to station B. The chest at A stays empty until the minecart network does no longer transport items (because it is, e.g. full).

This is non trivial. If you could manipulate the pathfinder (which is basically just a fancy graph consisting of nodes and edges), this would suddenly become awfully easy:

  (Resource in Area A)                                             (Chest in Area B)
     o -------------------------- [Walking, 30] -------------------------- o
      \                                                                    |
       \ [Walking, 3]                                         (Walking, 3) |
        \                                                                  |
         o ======================== [Tracks, 5] ========================== o
   (Station in Area A)                                                (Station in Area B)

In this example, the PF would find a path of length 30 by walking: ((Resource in area A), (Chest in Area B)).

However, it would also find a different path that contains more nodes, but has a length of 11 and is therefore (much) shorter: ((Resource in Area A), (Station Area A), (Station Area B), (Chest in Area B)).

Technically, the distance between the stations is the same, if not even bigger, than the walking distance. However, because this is automated, we can adjust the cost for this path and “pretend” that it’s shorter, therefore it would be preferred. If we were able to set own nodes, or at the very least own edges, with “special conditions”/“special actions” (instead of walk_path we would need to do walk_path, take_train, walk_path for example), this would become feasible.

It’s the only way it really works. Zulser did something that kind of worked, but wasn’t foolproof and suffered from the bad examples I’ve given at the top. In Zulser, conveyor belts were unidirected graphs - if you put an item onto a conveyor belt, I could exactly tell you where the item would drop off. Therefore, I did it this way: If the pathfinding found a conveyor belt, it calculated two paths: The path from this conveyor belt to the destination itself, and the path from the conveyor belt’s line dropoff point to the destination. If the latter path was shorter than the walking distance, the conveyor belt pretended to be a valid destination (technically overriding the real destination) and accepted the item. The item was taken out of circulation until it arrived at the final dropoff point, where it was re-added and then taken to the next inventory.

This was expensive, as it featured additional pathfinding tasks. I could probably have cached things, but I didn’t because back then, PF wasn’t as much of an issue, as towns in general were smaller and more limited. This solved the issue of items getting carried away by the conveyor belt needlessly and I suppose you could apply the same idea to minecarts, even extend it for multiple dropoff points - but performance-wise, I cannot really recommend it.

2 Likes