Stop "Ship X is Lost" messaging, when it's not lost

Got an idea for OpenTTD? Post it here!

Moderator: OpenTTD Developers

Post Reply
unidentifiable
Engineer
Engineer
Posts: 3
Joined: 14 Sep 2020 17:22

Stop "Ship X is Lost" messaging, when it's not lost

Post by unidentifiable »

Ships keep giving me a message "Ship X is lost" and then merrily continuing on to their destination anyways. This will happen at the start of its journey on either leg of the route, ad-infinitum. The destination is further than the recommended 30 or 40 squares, but this doesn't seem to matter since the ship finds its way anyways...so why does the game tell me it's lost?

I think the "is lost" check is happening before the ship can complete its pathfinding, so it flags "I AM LOST" and then silently goes "nevermind!". But I'm also guessing the route isn't cached, since it also flags its lost state again and again and again.

Also a plea for messaging to be better. A ship (or any vehicle for that matter) without a valid destination isn't "lost" because it knows precisely that it can't get to its destination. The messaging should be "<VehicleType> X cannot reach <Destination>". "Lost" implies it is possible to achieve its destination but is unsure how.

Yes, I can add buoys. However I would rather not since they're pretty ugly strewn everywhere, especially for long sea routes on large maps, and they quickly become bothersome when assigning routes since they need to be assigned in reverse order. A route with 10 buoys between 2 stations requires 22 entries in its route list. Ugh.

If pathfinding is slow, perhaps it can just be done once and cached, or have the ship leave behind "invisible buoys" every N squares whenever it needs to recalculate a path, and then just implicitly follows the buoys. Then the path could be saved in the map rather than in RAM.

User avatar
kamnet
Moderator
Moderator
Posts: 7327
Joined: 28 Sep 2009 17:15
Location: Eastern KY
Contact:

Re: Stop "Ship X is Lost" messaging, when it's not lost

Post by kamnet »

The problem is that ocean tiles have effectively unlimited directions a ship can go. Calculating a path can eat a lot of resources. So, in fact, it is "lost" - it basically can't make a decision on what is the most optimal route to reach the destination.

Transport Tycoon Deluxe wasn't designed for large maps or large bodies of waters in mind, so the pathfinding was pretty basic and didn't have these issues. With OpenTTD it's much harder to make this work properly. Developers have slowly worked on the issue for years, but it's shown to be a rather difficult issue to fix. For example, here is a bug report from March, back before the release of OpenTTD 1.10.0, that's still being discussed: https://github.com/OpenTTD/OpenTTD/issues/8001

You can try adjusting a few of the settings in the openttd.cfg file, as noted in the bug report, but ultimately for right now the best suggestion is to continue to use the buoys to minimize the errors.

LaChupacabra
Traffic Manager
Traffic Manager
Posts: 132
Joined: 08 Nov 2019 23:54

Re: Stop "Ship X is Lost" messaging, when it's not lost

Post by LaChupacabra »

Messages about:
- change in the acceptance of the goods
- change in production volume
- arrival of the first vehicle at the station
- loss-making vehicles
- aging vehicles
- incorrect orders
- lost vehicle

If someone likes a never-ending litany of information and warnings about nothing really important, good option is to leave it on. I turned it off in the first month of the game and I have peace of mind with such problems. This information may be useful at the very beginning of the game, but later only irritates.

Interestingly, some time ago I turned on these lost vehicle warnings again because I wanted to check something and whatever I did, these warnings don't appear at all. They are in the message list, but they don't appear on the screen.
Image
I never look at such information again, even if I wanted to. ;)
Attachments
Lack of information.PNG
(593.27 KiB) Not downloaded yet
I am sorry for may English. I know is bed.

LaChupacabra
Traffic Manager
Traffic Manager
Posts: 132
Joined: 08 Nov 2019 23:54

Buoys on the way can have a significant impact on the smoothness of the game

Post by LaChupacabra »

Until recently, I thought that placing buoys on straight sections of the route was unnecessary and would give nothing (especially on rivers where pathfinder doesn't have much choice of route). Recently, however, I did a test: I flew 1000 ships on a route of 2000 tiles with buoys by every 50 and without any buoys - the effect was more than noticeable, especially on my second, weaker computer.

With buoys - the drag was negligible.
Test 2x1k buoys - with.sav
(66.51 KiB) Downloaded 2 times
Without buoys - the game cut very hard and unpleasantly every few moments (~7 days) - it seems that pathfinder checks and sets the route for all ships at once - this is not the best solution. I think that pathfinder gets unnecessarily involved in most situations. Perhaps it happened more often before, but I think the routing frequency could be further reduced.
Test 2x1k buoys - without.sav
(59 KiB) Downloaded 2 times
Without buoys, but in canal (no chioce of path) - despite the lack of any buoy at a distance of 2,000 tiles, the smoothness of the game is fairly acceptable.
Test 2x1k buoys - without,canal.sav
(58.54 KiB) Downloaded 2 times
Last edited by LaChupacabra on 26 Sep 2020 16:50, edited 1 time in total.
I am sorry for may English. I know is bed.

LaChupacabra
Traffic Manager
Traffic Manager
Posts: 132
Joined: 08 Nov 2019 23:54

Invisible buoys - shipping lanes

Post by LaChupacabra »

unidentifiable wrote:
26 Sep 2020 04:41
If pathfinding is slow, perhaps it can just be done once and cached, or have the ship leave behind "invisible buoys"...
I think the "invisible buoys" mentioned by unidentifiable might be a very good idea. I had a similar idea, called "Shipping Lanes".
Shipping Lanes by buoy v1.png
Shipping Lanes by buoy v1.png (323.66 KiB) Viewed 356 times
I see it like this:
1. Pathfinder would create "invisible buoys" every field by setting the route.
2. Important! These invisible buoys could not be removed or built up by a player who doesn't use them - thanks to this it would be impossible to block ships routes by dishonest or inattentive players.
3. Pathfinder would no longer need to recalculate periodically - it would only do this once
3a. The only situation in which pathfinder would have to map a new route would be to remove one of the invisible buoys by their user or when new orders are set.
3b. Unused invisible buoys would automatically disappear after a certain period of time (e.g. 30 days)
4. Pathfinder could be inclined to use existing waterways - this could be due to traffic congestion on the trail
5. It is important for the pathfinder to be able to build "buoys" on the tiles half-occupied by land (route through diagonal canals and straits)
6. Invisible buoys could be... visible as delicately marked lines marking the route (similar to those on real maps) (only used buoys/lines would be visible)
7. Shipping Lines and Deep Water - pathfinder would try to avoid shallow, coastal waters if possible
8. It would also be possible to create a tool for the player to independently mark water routes (here the time for the disappearance of the buoy / trail would be extended)
9. Water routes could have two directions - pathfinder would first designate one direction, then the second adjacent to the first, and where it is too narrow: overlapping each other.
Image
9b. A simpler method of limiting the intersection of ships would be to add a rule for ships to pass buoys on the right as far as possible (right-hand traffic in waters is valid worldwide)
10. The minimum height of bridges over the waterways could be established
11. The idea of ​​Water Lines is related to another "One quay = one ship" - the port area would be a navigable zone in which ships could move freely. For a ship approaching the port, 20 tiles from the nearest quay would have a pathfinder route to a free berth. If there were no spare spaces, the ship would slow down and halt until there was room. The navigable zone (radius of ~5 tiles from the quay) could only be built by the player using the ports.
Attachments
Shipping Lanes v01.png
(38.93 KiB) Not downloaded yet
I am sorry for may English. I know is bed.

User avatar
leifbk
Chairman
Chairman
Posts: 784
Joined: 23 Dec 2013 16:33
Location: Bærum, Norway
Contact:

Re: Stop "Ship X is Lost" messaging, when it's not lost

Post by leifbk »

"There are only two hard things in Computer Science: cache invalidation and naming things." -- Phil Karlton

You can't really cache a route, because anything might happen along the way anytime. Landscaping and spawning of new industries will always necessitate immediate modification. So I suppose the only realistic option is buoys and more buoys.

I've written a simple Perl script that I'm using to place buoys evenly distanced in a straight line:

Code: Select all

#! /usr/bin/perl -w

# buoycalc.pl - Buoy Calculator

# maximum Manhattan distance between buoys
my $max = 50;

# elementary input checking: count arguments
if ($#ARGV != 3) { # if not 4 args
    $0 =~ s|.*/||; # strip path from program name
    print "$0: Calculate coordinates for buoys in a straight line between (ax,ay) and (bx,by).\n";
    print "Usage: $0 ax ay bx by\n";
    exit;
}
my ($ax, $ay, $bx, $by) = @ARGV;
my $m = abs($ax - $bx) + abs($ay - $by);
print "Manhattan distance between ($ax,$ay) and ($bx,$by): $m\n";
my $n = int($m / $max);
print "You need $n buoys.";
# number of distances between buoys and the end-points is n + 1
$n++;
my $dx = ($bx - $ax) / $n;
my $dy = ($by - $ay) / $n;
printf " (dx = %.1f, dy = %.1f)\n", $dx, $dy;
for (my $i = 1; $i < $n; $i++) {
    printf "%2d: %4d %4d\n", $i, $ax + $i * $dx, $ay + $i * $dy;
}
The nasty part is of course to locate the coordinates in the middle of the ocean with the land information tool and then place a buoy exactly there. I'd love to have the Shift-click buoy (or right-click, Ctrl-click or whatever) to show the coordinates rather than the price, which is pretty uninteresting.

Eddi
Tycoon
Tycoon
Posts: 7503
Joined: 17 Jan 2007 00:14

Re: Stop "Ship X is Lost" messaging, when it's not lost

Post by Eddi »

i'd probably drag a piece of track, it shows if you're off the straight line, and the distance dragged. then you can pres [Esc] and open the buoy placement with keyboard shortcuts, while the mouse is over the correct tile.

as for the "ship is lost" message, that probably depends on which pathfinder algorithm is selected (which might be buried deep in advanced settings)
You might not exactly be interested in Ferion, but if you are, have fun :)

User avatar
leifbk
Chairman
Chairman
Posts: 784
Joined: 23 Dec 2013 16:33
Location: Bærum, Norway
Contact:

Re: Stop "Ship X is Lost" messaging, when it's not lost

Post by leifbk »

Eddi wrote:
27 Sep 2020 14:38
i'd probably drag a piece of track, it shows if you're off the straight line
Those "straight lines" can only be drawn in the four cardinal directions. My script will calculate straight lines in any direction, between any two selected tiles.

Eddi
Tycoon
Tycoon
Posts: 7503
Joined: 17 Jan 2007 00:14

Re: Stop "Ship X is Lost" messaging, when it's not lost

Post by Eddi »

uhm, you can drag rails in 8 directions, and those are the only way a "straight line" can be done within the game mechanics.
You might not exactly be interested in Ferion, but if you are, have fun :)

User avatar
leifbk
Chairman
Chairman
Posts: 784
Joined: 23 Dec 2013 16:33
Location: Bærum, Norway
Contact:

Re: Stop "Ship X is Lost" messaging, when it's not lost

Post by leifbk »

Eddi wrote:
27 Sep 2020 15:08
uhm, you can drag rails in 8 directions,
Yes, 8 if you consider both ways as separate directions.
and those are the only way a "straight line" can be done within the game mechanics.
Yes and no. A ship can move along a segment horizontally, vertically, and diagonally, but it will pass two consecutive buoys regardless of this constraint. The shortest route between two points on the map will always be a straight line, and a ship will always seek to optimise the route between two points on the orders list. Maybe I'm a little obsessive about this, but it does make a difference.

Eddi
Tycoon
Tycoon
Posts: 7503
Joined: 17 Jan 2007 00:14

Re: Stop "Ship X is Lost" messaging, when it's not lost

Post by Eddi »

leifbk wrote:
27 Sep 2020 15:21
Eddi wrote:
27 Sep 2020 15:08
uhm, you can drag rails in 8 directions,
Yes, 8 if you consider both ways as separate directions.
and those are the only way a "straight line" can be done within the game mechanics.
Yes and no. A ship can move along a segment horizontally, vertically, and diagonally, but it will pass two consecutive buoys regardless of this constraint. The shortest route between two points on the map will always be a straight line, and a ship will always seek to optimise the route between two points on the orders list. Maybe I'm a little obsessive about this, but it does make a difference.
i think we need some clarification on the meaning of words here. "cardinal directions" are 90° offset from each other, like the points on a wind rose: North. South. East. West. the game knows these, and 4 other directions inbetween.

and a "straight line" is any line that has no curve in it. if a ship changes directions between any of those before-mentioned 8 directions, that's a curve.

the problem with "curves" in the constraints of the game geometry is, that this introduces multiple similar options. and the more options you have, the longer the pathfinder has to run to decide which one is optimal (spoiler: they're all the same, all that effort is essentially wasted).
You might not exactly be interested in Ferion, but if you are, have fun :)

User avatar
leifbk
Chairman
Chairman
Posts: 784
Joined: 23 Dec 2013 16:33
Location: Bærum, Norway
Contact:

Re: Stop "Ship X is Lost" messaging, when it's not lost

Post by leifbk »

Eddi, consider for instance three buoys on a route that goes east and a little south, say 40 tiles east and 10 tiles south. The coordinates of three consecutive buoys can be (100,100), (140,110), and (180,120). If the ship starts at (100,100) it will probably first go due east 30 tiles to (130,100). Then it will change course to go diagonally south-east until it hits the buoy at (140,110). It will keep the same diagonal course until it hits (150,120), and then proceed due east to (180,120).

This will be the absolutely shortest path between those three points game-wise. It's not a geometrically straight line, but it's not really a curve either. It's rather the game's own approximation to a straight line, defined as the shortest distance between two points.

User avatar
odisseus
Traffic Manager
Traffic Manager
Posts: 162
Joined: 01 Nov 2017 21:19

Re: Stop "Ship X is Lost" messaging, when it's not lost

Post by odisseus »

The straight path isn't always the shortest path.

Consider the situation in the attached screenshot. Both boats are the same model and have been released from the same depot at the same time.

Even though the pathfinder also thinks that the straight path is the best, a path that avoids stopping at the locks is actually better.

As a side note, some GRFs define boats that have different speed limits in the sea and in a river or canal.
Attachments
boat-race.png
(58.91 KiB) Not downloaded yet
Last edited by odisseus on 27 Sep 2020 19:45, edited 1 time in total.

Eddi
Tycoon
Tycoon
Posts: 7503
Joined: 17 Jan 2007 00:14

Re: Stop "Ship X is Lost" messaging, when it's not lost

Post by Eddi »

leifbk wrote:
27 Sep 2020 16:30
If the ship starts at (100,100) it will probably first go due east 30 tiles to (130,100). Then it will change course to go diagonally south-east until it hits the buoy at (140,110).
but you're missing the point. because it could as well go to (110,110) and then change course to (140,110). this path is the exact same length, and the pathfinder must consider both paths to decide that.

it must also check the path (101,101),(131,101),(140,110), and there are many more paths like this, which are all the same length. and this is exactly why ship pathfinding is so slow.
You might not exactly be interested in Ferion, but if you are, have fun :)

User avatar
leifbk
Chairman
Chairman
Posts: 784
Joined: 23 Dec 2013 16:33
Location: Bærum, Norway
Contact:

Re: Stop "Ship X is Lost" messaging, when it's not lost

Post by leifbk »

Eddi wrote:
27 Sep 2020 18:38
leifbk wrote:
27 Sep 2020 16:30
If the ship starts at (100,100) it will probably first go due east 30 tiles to (130,100). Then it will change course to go diagonally south-east until it hits the buoy at (140,110).
but you're missing the point. because it could as well go to (110,110) and then change course to (140,110). this path is the exact same length, and the pathfinder must consider both paths to decide that.
I'm not missing that point. There's obviously a cluster of routes which have the same distance, but the ship will usually minimise its number of turns and proceed in the same direction until it has to change it.

On the other hand, you seem to miss my point that the shortest sea route between two points will follow buoys located on a straight line, with equal distances between them. It's easy to calculate each buoy's location, as I've shown with my script above, but it's very hard to locate the coordinates in a featureless ocean and then place the buoy there. It would be of great help to have a tool tip displaying coordinates when placing a buoy.

Eddi
Tycoon
Tycoon
Posts: 7503
Joined: 17 Jan 2007 00:14

Re: Stop "Ship X is Lost" messaging, when it's not lost

Post by Eddi »

leifbk wrote:
27 Sep 2020 19:05
but it's very hard to locate the coordinates in a featureless ocean and then place the buoy there.
i already gave my answer to that. if you can't read, i can't help you. i tried.
You might not exactly be interested in Ferion, but if you are, have fun :)

Post Reply

Return to “OpenTTD Suggestions”

Who is online

Users browsing this forum: No registered users and 12 guests