The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: AP on January 05, 2018, 07:48:04 PM

Title: JPS fails on some estuaries [WAS Humber keel refuses to use Medium River]
Post by: AP on January 05, 2018, 07:48:04 PM
On the current Bridgewater server game, I have several Humber Keels, which say they should be able to sail up "medium rivers", refusing to use the 'midstream medium river' to get to Christerhill Village Dock (2321,2998) from Bearidge Corner Dock (2335,2957).


I can't see anything that should prevent them using this river, every tile is navigable and there are no low bridges, so am inclining to think "bug"...


Could someone take a look and let me know what they think?

Moderator note: The title of this post has been changed for clarity.
Title: Re: Humber keel refuses to use Medium River
Post by: jamespetts on January 05, 2018, 08:06:35 PM
Have you checked the range?
Title: Re: Humber keel refuses to use Medium River
Post by: AP on January 05, 2018, 08:22:20 PM
Have you checked the range?

I hadn't, but on checking, the Keel's range is 50km, whereas the between the co-ordinates mentioned is 14 tiles in the x and 41 in the y (simplistically), at 8 tiles/km, nowhere close to the range limit.
Title: Re: Humber keel refuses to use Medium River
Post by: jamespetts on January 05, 2018, 09:00:11 PM
Are there any river rapids?
Title: Re: Humber keel refuses to use Medium River
Post by: AP on January 05, 2018, 10:21:34 PM
There are sloped river tiles, but they are tagged "navigable".
Title: Re: Humber keel refuses to use Medium River
Post by: jamespetts on January 05, 2018, 10:42:58 PM
Thank you for that. I have logged in and I can see where the issue occurs, although I am not sure what is causing it; I will have to look into this in more detail when I get home and have a chance to look into the code properly.
Title: Re: JPS fails on some estuaries [WAS Humber keel refuses to use Medium River]
Post by: jamespetts on January 08, 2018, 01:12:32 AM
Having looked into this, I have determined that this is (so far as I can tell) a fault with the JPS routefinding system for ships when coupled with one very specific sort of estuary:

(http://bridgewater-brunel.me.uk/screenshots/estuary-issue-1.png)

Because this code is common with Standard, I have moved this thread to the Standard bug reports section. My tests so far show that: (1) disabling the JPS search; and (2) deleting and re-building the estuary thus as the public player:

(http://bridgewater-brunel.me.uk/screenshots/estuary-issue-2.png)

(http://bridgewater-brunel.me.uk/screenshots/estuary-issue-3.png)

allows the boats to route past this estuary tile. Testing using breakpoints in the debugger, it seems that, with JPS enabled, the estuary tile never gets added to the list in the route finder.

I do not know the cause of or solution to this problem, since I did not write and do not fully understand the JPS system (I suspect that it is some interaction between the unusual ribis of this particular estuary and the JPS's way of not checking all directions), but I have resolved the issue on the Bridgewater-Brunel server by rebuilding the river as shown above, and confirmed that the ships do route. Incidentally, this should make the server run more responsively, since the repeated failed attempts by these boats at finding a route were taking a huge amount of CPU power.

For the purposes of Standard developers looking into fixing this: I have a saved game available (albeit an Extended saved game) showing this failure state if that would be helpful.
Title: Re: JPS fails on some estuaries [WAS Humber keel refuses to use Medium River]
Post by: DrSuperGood on January 08, 2018, 01:29:27 AM
This is a very old bug, even the old "experimental" server suffered from something like it, where cannel tiles would be ignored for path finding. Just it was trivial to fix back then as one still had access to terraform as one wanted. Standard never noticeably suffered from it as both Pak64 and Pak128 are not ship focused so ships are seldom used and certainly nowhere near as much as on the extended server.
Title: Re: JPS fails on some estuaries [WAS Humber keel refuses to use Medium River]
Post by: Dwachs on January 08, 2018, 07:35:01 AM
Will look into this when I find time.

@James: In your pictures, which of the pictures shows the faulty configuration? I suppose the first one? Is this a canal or a river? Does this only happen for generated rivers? Or does this also occur for player built canals?

I am aware that there is a route finding bug in standard, but was never able to track it down.
Title: Re: JPS fails on some estuaries [WAS Humber keel refuses to use Medium River]
Post by: jamespetts on January 08, 2018, 09:07:38 AM
Dwachs - the first picture shows the fault. It is an automatically generated river, not a canal. I have not seen the issue with canals, although there are not many on the server.
Title: Re: JPS fails on some estuaries [WAS Humber keel refuses to use Medium River]
Post by: DrSuperGood on January 08, 2018, 05:27:22 PM
Worth noting that Simutrans Extended has different water logic from Standard. Some ships cannot path over open water. Some rivers and cannels limit the sort of ships that can path over them, and not just the maximum speed of the ships. This adds more potential causes of the problem.
Title: Re: JPS fails on some estuaries [WAS Humber keel refuses to use Medium River]
Post by: jamespetts on January 08, 2018, 07:25:22 PM
Worth noting that Simutrans Extended has different water logic from Standard. Some ships cannot path over open water. Some rivers and cannels limit the sort of ships that can path over them, and not just the maximum speed of the ships. This adds more potential causes of the problem.

I did specifically check using breakpoints whether any of the Extended specific routing restrictions were activated: they were not. Also, it could not be one of these restrictions if turning of JPS solves the problem, as there is no distinction between JPS and non-JPS searches in any of the code that provides for these restrictions.
Title: Re: JPS fails on some estuaries [WAS Humber keel refuses to use Medium River]
Post by: Dwachs on January 08, 2018, 08:50:03 PM
The bug appears to be more difficult to fix than expected. Here is a supposed fix, please test it. The bug appeared also with player-built canals. The jps method was not able to turn into or behind canals.

Many thanks to James for hunting down the bug to the jps code.
Title: Re: JPS fails on some estuaries [WAS Humber keel refuses to use Medium River]
Post by: jamespetts on January 08, 2018, 09:19:20 PM
Splendid, thank you for that. I have now tested it in Extended using the original case in which this issue occurs, and I confirm that the problem can no longer be reproduced.
Title: Re: JPS fails on some estuaries [WAS Humber keel refuses to use Medium River]
Post by: Dwachs on January 09, 2018, 10:42:59 AM
This is not yet submitted to standard svn.... will do tonight.

Edit: Submitted, it is r8366.