Currently Online

Latest Posts

Topic: Ship AI and Cargo capacity

littlekatana
Avatar
Joined: 2021-10-30, 16:43
Posts: 29
Ranking
Pry about Widelands
Posted at: 2021-11-17, 17:44

Why do I have idle ships if there are so many places waiting for goods? I can actually see there are over one hundred fish in one port, but the inns an island over need them for making meals? Am I missing something? Or do I have my economy configured wrong?

How many goods can a ship hold? Are there restrictions on type?

Do folks know any tricks for trying to funnel goods from one building directly to another building? Or is the transportation of goods up to the (widelands programming) gods?


Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 1506
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2021-11-17, 18:18

Widelands programming god who wrote the (no-longer-quite-)new shipping algorithm and redesigned the transport prioritization system answering here face-wink.png

A ship can hold 30 items by default, though the sea-based starting conditions give you a few ships with higher capacity. Every ware and every worker on a ship counts as 1 item, regardless of type.

Are your hundreds of fish waiting in the port (1st tab) or the portdock (3rd tab)? Wares/workers in the first two tabs are simply stored there because a port also acts as a normal warehouse; wares/workers in the third and fourth tab are waiting for a ship. It may be that your inns have enough stock that they aren't requesting any fish, so the wares simply sit around in a warehouse until actively requested by a building.

You can have idle ships even if a lot of stuff is being moved because my algorithm prefers to bundle several goods for the same destination in a single trip. So if there are wares waiting at A to be shipped to B and a ship is already coming to A which also has some wares loaded for B, then the goods waiting at A will be transported to B preferably via that ship, instead of calling for a idle ship even if one would be available. All such decisions are always weighted with the purpose of keeping the average – not the individual! – waiting times low and avoiding unnecessary travel times.

If you want a ware to be sent to a specific building as fast as possible, give that building the very highest priority for this ware. The highest priority means that this building's request will always be fulfilled before any other request that does not also have highest priority, regardless of everything else.

Edited: 2021-11-17, 18:19

Top Quote
kaputtnik
Avatar
Joined: 2013-02-18, 20:48
Posts: 2106
Ranking
One Elder of Players
Location: Germany
Posted at: 2021-11-17, 18:45

A request problem (again) face-smile.png

The problem is that your Inns make a request for fish, and the logic may not choose the the fish stored in your port. Instead it chooses a fish from a far away warehouse. Thus this fish takes a long time to arrive at your inn.

The same can happen wehen settling an island: In your new port you set to prefer building materials here. Then you starts building a building. A Ship arrives with building materials but they get stored in the port and not directly transported to the new construction site. So you wonder why the hell the port is full of buildings materials but those are not going to your new construction site.
The Port requests building materials to be stored here. The construction site requests building materials for the building. These are two different requests with two different destinations. So your port might get filled with building materials and the construction site might has to wait for another ship which transports the requested wares for the building.


Top Quote
littlekatana
Avatar
Joined: 2021-10-30, 16:43
Posts: 29
Ranking
Pry about Widelands
Posted at: 2021-11-18, 00:06

I see, this helps me understand. Averages make sense, also.

Is there a strategy or technique you can use to mitigate those issues? I have been trying to have supply chains all housed on the same island. And trying to prioritize good storage for things I want on the island, etc etc.


Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 1506
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2021-11-18, 09:06

The shipping algorithm is focused primarily at large setups, with many ports, lots of ships, and a medium to large amount of goods to transport. Storage optimization is often counter-productive in larger economies. You should try to avoid having ports with very little throughput – those are always penalized in favour of the main hubs. Centralizing your shipping traffic in as few ports as reasonably possible is far more efficient, provided your road network can handle the load as well.

Having a 100% complete and self-sufficient supply chain on an island is usually the most efficient solution (especially when combined with low input priority settings in the consumers, to avoid requesting wares as soon as they're available even if they're far away), but having a partial supply chain can actually be harmful because it means your colony still depends on imports but the port receives less traffic and is therefore deemed less important. Having only consumers but none of their producers on an island usually involves the least penalty, because it should generate enough traffic to give your port a higher priority. Unless of course your port already is a major hub, then you don't need to worry about increasing its importance, so coherent excerpts of complete supply chains are the most efficient way in this case.

Of course, your economy's ability to provide all buildings with inputs also plays a major role. Shortages always strongly affect the whole economy.


Top Quote
JanO
Avatar
Joined: 2015-08-02, 11:56
Posts: 176
Ranking
At home in WL-forums
Posted at: 2021-11-18, 10:23

Can the player look up if a port is a main hub or not? I guess you count the number of shipped wares per unit of time and have a number of thresholds, either static or depending on overall movement within all economies? Does the calculation take into account the particular land-based traffic of each port? So to say, if a port has high traffic within its road network (or its flag), it might gain a higher priority on seafaring as well.

Nevertheless, I would appreciate the additional possibility of user-defined static routes for ships. Like ports acting like flags and ships acting like carriers, with the difference that routes can have more than two ports (ships traveling in n-angles then). With either one or a configurable number of ships fixed per route. Combine this with a button to exclude a particular port from the pathfinding algorithm for ships and it might be possible to get effective transportation of wares on water while even reducing calculation time.


Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 1506
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2021-11-18, 11:33

There's no threshold value. Pairs of (start, end) ports are assigned a priority factor depending on how many wares are waiting at or heading towards each port, and how many ships are already sailing that route. Wares assigned to an urgent request, and wares that have been waiting for a ship for a long time, are weighted higher. Ships are assigned to port pairs in order of priority.

By "main hub", I chiefly mean how important a port is compared to other ports. A port where a lot of wares and ships arrive and leave all the time is definitely such a hub as it will always have a high priority value. If most of your ports are idle all the time and one port occasionally sends or receives a few items, then that might not what one would call a busy and important location but it's still treated as such because this port is much busier than the others.


Land-based traffic around a port is too complex a matter to give a simple yes/no answer here. We need to distinguish between the economy routing code and the ship scheduling code.

The economy routing plans out the exact route that any given ware or worker has to take from their start to their destination. It considers things such as transport time between flags and road congestion; a shipping route between two ports is treated similar to a very long road with high capacity.

The shipping algorithm is completely separate from that, and it's only task is to decide which ship should visit which ports in which order, and how many goods for which destination it picks up there. Factors it takes into account include the amount of goods waiting for shipment at a port and the amount of goods waiting to be transported to a port. So, traffic outside a port is considered by economy routing, but its effect on ship scheduling depends on how many of these goods are actually about to be shipped or have recently arrived by ship; land-only transport and permanent storage in the port warehouse don't count.


You will, most likely, not be able to define shipping routes that are globally more performant than the built-in routing algorithms. While you could use such a feature to prioritize some specific buildings, it would hurt the rest of the economy so much that in sum you lose. If you did find a way, that would simply be a sign that the algorithm should be improved.

And if you want a port to be excluded from pathfinding, just don't build it – this is like placing a hundred-tiles-long road and then complaining that wares are sent through it face-wink.png

As for calculation time, the shipping algorithm is pretty efficient; the most performance-hungry piece of code by far is the economy routing code, and as I said a pair of ports is treated just like a pair of flags connected by a road, so closing down ports reduces the complexity of this calculation by practically nothing. If anything, it might actually increase it, as land-based routing has more flags and therefore far more decisions to compute.


Top Quote
littlekatana
Avatar
Joined: 2021-10-30, 16:43
Posts: 29
Ranking
Pry about Widelands
Posted at: 2021-11-18, 16:37

JanO wrote:

Can the player look up if a port is a main hub or not? I guess you count the number of shipped wares per unit of time and have a number of thresholds, either static or depending on overall movement within all economies? Does the calculation take into account the particular land-based traffic of each port? So to say, if a port has high traffic within its road network (or its flag), it might gain a higher priority on seafaring as well.

Nevertheless, I would appreciate the additional possibility of user-defined static routes for ships. Like ports acting like flags and ships acting like carriers, with the difference that routes can have more than two ports (ships traveling in n-angles then). With either one or a configurable number of ships fixed per route. Combine this with a button to exclude a particular port from the pathfinding algorithm for ships and it might be possible to get effective transportation of wares on water while even reducing calculation time.

I had similar thoughts. Without knowing, of course, all the internal coding of the game like Nordfriese, I figured it wouldn't work at least to the extent that the game changes significantly and becomes something more like the Patrician series.

But here's my question for Nordfriese, because the mechanics of Patrician are good, but also rely on some key differences from Widelands.

The first key difference is that in Patrician each island has a unified storage system meaning that each good placed into a port/warehouse/storage facility on a given island is automatically available at every port/warehouse/storage facility on that island (indeed, this is often true of most resource-gathering games, that resources are simply put into the general stock and not into a specific storage facility). I particularly like this because in my short time playing Widelands I have had trouble a) finding where a good is being stored (not knowing where it might have been shipped off to) in order to attempt to properly store it where it would be most effective+ and b) knowing how much of one thing I have if different bundles of things have been created and stored in different places.

The second key difference is that you can build more than one port on an island. I'm not saying that you can't do that in Widelands (I actually have no idea) but so far port placement seems to be extremely limited). In Patrician, this allows you to optimize the time it takes for one ship to travel from port to port. In Patrician the game is creating these shipping routes to make your economy work, and I say that because the extracting and manufacturing tree ratios were more transparent, i.e. the game told you how many of each building to make in order to achieve equilibrium of production.

So I just wanted to get your thought on those differences.

+this may seem like a silly thing given what you've already said above, but one example would be soldiers. If you have a concentrated front line against the enemy, it makes sense to house your soldiers in the warehouse closest to that front line in order to replenish the ranks faster and thus gain an advantage over your opponent.


Top Quote
kaputtnik
Avatar
Joined: 2013-02-18, 20:48
Posts: 2106
Ranking
One Elder of Players
Location: Germany
Posted at: 2021-11-18, 18:13

Nordfriese wrote:

You will, most likely, not be able to define shipping routes that are globally more performant than the built-in routing algorithms. While you could use such a feature to prioritize some specific buildings, it would hurt the rest of the economy so much that in sum you lose. If you did find a way, that would simply be a sign that the algorithm should be improved.

The current algorithm works perfect (nearly). The Problem is the player who do not not know how it works. He is watching the ships and wonders why the items are stored in a port but not transported to the buildings where the items are needed. Like the Fish-Inn Problem in the first post.

Most economic related things in widelands can be adjusted by the player: Give high priorities, set economy settings, cut roads and build new ones (optimizing the road network). Seafaring doesn't have any possibilities for adjusting and i think this is one of the reasons why we regularly talk about the shipping algorithm and from time to time the proposal comes up to give the player the possibility to implement user defined static routes for ships (like JanO).

From a players point of view the shipping algorithms is some times not doing the things the player expects, leaving him unsatisfied with the game. This results in a wish to manually interfere with the routing of ships.

And if you want a port to be excluded from pathfinding, just don't build it

This does not work. Recently i build a port on my main land and after a while i found another port space which was much better for my current mission. But i didn't wanted to dismantle the first built port, because on a later mission it may be a good place.

What about giving the player the possibility to 'stop' a port? Say a stopped port will not be considered for the seafaring algorithm but acts as a warehouse nevertheless. This way a player can 'stop' all ports he didn't wanted to be used leaving two ports 'open'. This is then like a static route and a player has (little) influence about where the ships go.


Top Quote
littlekatana
Avatar
Joined: 2021-10-30, 16:43
Posts: 29
Ranking
Pry about Widelands
Posted at: 2021-11-18, 18:29

kaputtnik wrote:

Most economic related things in widelands can be adjusted by the player: Give high priorities, set economy settings, cut roads and build new ones (optimizing the road network). Seafaring doesn't have any possibilities for adjusting and i think this is one of the reasons why we regularly talk about the shipping algorithm and from time to time the proposal comes up to give the player the possibility to implement user defined static routes for ships (like JanO).

From a players point of view the shipping algorithms is some times not doing the things the player expects, leaving him unsatisfied with the game. This results in a wish to manually interfere with the routing of ships.

This friend speaks my mind. It can be a bit frustrating to play a game you have little-to-no control over.

I'm having a hard time wrapping my brain around the priorities. I figure since the economy is all linked, it would be hard to decide one production facility as a priority over the others. Would it work short term to fix my fish>inn problem, but then what else suffers after a while?


Top Quote