The International Simutrans Forum

 

Author Topic: Road autobuilder is extremely wasteful  (Read 781 times)

0 Members and 1 Guest are viewing this topic.

Offline freddyhayward

  • Devotee
  • *
  • Posts: 645
  • Languages: EN
Road autobuilder is extremely wasteful
« on: December 27, 2020, 11:32:16 AM »

I created this mess by clicking once the townhall road and each attraction. The road builder supposedly checks for existing roads but I don't know why that doesn't help.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10542
  • Languages: De,EN,JP
Re: Road autobuilder is extremely wasteful
« Reply #1 on: December 27, 2020, 01:21:26 PM »
It strongly depends on the weight setting you used and wether you pressed control or not (you did not, of course).

Also curves are very expensive, so if it can save a curve, it will do a new route unless it can save 20 tiles or so. On real maps, this is leass obvios, since the topography usually determines the shape of teh roads a lot.

Offline freddyhayward

  • Devotee
  • *
  • Posts: 645
  • Languages: EN
Re: Road autobuilder is extremely wasteful
« Reply #2 on: December 27, 2020, 08:08:07 PM »
It strongly depends on the weight setting you used and wether you pressed control or not (you did not, of course).

Also curves are very expensive, so if it can save a curve, it will do a new route unless it can save 20 tiles or so. On real maps, this is leass obvios, since the topography usually determines the shape of teh roads a lot.
I'm not sure what you mean here, are you suggesting possible causes of the bug, or saying that it is not a bug?

Offline Freahk

  • Devotee
  • *
  • Posts: 1435
  • Languages: DE, EN
Re: Road autobuilder is extremely wasteful
« Reply #3 on: December 28, 2020, 01:39:28 AM »
It's not a bug, it's the way how the way constructor works.
You can configure that behavior in simuconf.
« Last Edit: December 28, 2020, 03:04:58 AM by Freahk »

Offline freddyhayward

  • Devotee
  • *
  • Posts: 645
  • Languages: EN
Re: Road autobuilder is extremely wasteful
« Reply #4 on: December 28, 2020, 02:51:02 AM »
It's not a bug, the the way how the way constructor works.
You can configure that behavior in simuconf.
Typical KDE user response ;D. But seriously, I have tried all sorts of combinations in simuconf.tab and it usually makes it worse. If the default is that bad, and it cannot easily be improved through settings, it is probably either a bug or bad design.

Offline Freahk

  • Devotee
  • *
  • Posts: 1435
  • Languages: DE, EN
Re: Road autobuilder is extremely wasteful
« Reply #5 on: December 28, 2020, 03:05:24 AM »
Typical KDE user response
actually true :D

If the default is that bad, and it cannot easily be improved through settings, it is probably either a bug or bad design.
The latter I guess

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10542
  • Languages: De,EN,JP
Re: Road autobuilder is extremely wasteful
« Reply #6 on: December 28, 2020, 05:14:46 AM »
It should make a difference, if the costs for curves are lowered. But then the first road may look weird.

Offline freddyhayward

  • Devotee
  • *
  • Posts: 645
  • Languages: EN
Re: Road autobuilder is extremely wasteful
« Reply #7 on: December 28, 2020, 05:38:00 AM »
It should make a difference, if the costs for curves are lowered. But then the first road may look weird.
This is how it looks with all curve costs halved:
« Last Edit: December 28, 2020, 05:52:46 AM by freddyhayward »

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10542
  • Languages: De,EN,JP
Re: Road autobuilder is extremely wasteful
« Reply #8 on: December 28, 2020, 06:44:34 AM »
Somehow I cannot see your image ...

Offline freddyhayward

  • Devotee
  • *
  • Posts: 645
  • Languages: EN
Re: Road autobuilder is extremely wasteful
« Reply #9 on: December 28, 2020, 09:10:10 AM »
Somehow I cannot see your image ...
maybe try this link?: https://i.imgur.com/yhsBQVR.png

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4854
  • Languages: EN, DE, AT
Re: Road autobuilder is extremely wasteful
« Reply #10 on: December 28, 2020, 09:42:02 AM »
Changing all costs by a constant factor will not change anything. You have to change the ratios of the costs to get a different output. A first step could be to lower the high costs for these advanced curve penalties.

For the way builder in the scripted AI, I implemented something that is equivalent to way_straight=8, way_curve=4.

Edit: corrected the weights
« Last Edit: December 28, 2020, 11:01:33 AM by Dwachs »

Offline freddyhayward

  • Devotee
  • *
  • Posts: 645
  • Languages: EN
Re: Road autobuilder is extremely wasteful
« Reply #11 on: December 28, 2020, 10:02:24 AM »
Changing all costs by a constant factor will not change anything. You have to change the ratios of the costs to get a different output. A first step could be to lower the high costs for these advanced curve penalties.
I did not change all costs - I changed all curve costs, so the ratio of all curves to straights decreased. Secondly, increasing all costs by a constant factor should change things in theory, because the cost of all new roads would increase relative to the cost on existing tiles:
Code: [Select]
costs = str ? 0 : s.way_count_straight;Thirdly, trying your settings (except that the minimum cost is 1, and there is no setting for an additional penalty for tiles without roads) produced a significantly worse result:

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4854
  • Languages: EN, DE, AT
Re: Road autobuilder is extremely wasteful
« Reply #12 on: December 28, 2020, 11:00:40 AM »
If way_curve is smaller than way_straight then following a curved road is cheaper then creating a new straight piece of road.

The cost of going along an existing straight road is zero. The cost of building a straight new piece of road is way_straight. The cost of changing direction then added   (way_curved). So the cost to follow an existing curve is way_curve, where the cost to build a new curve is way_straight+way_curve. The costs of all the other penalties is added on top.

One certainly has to play with these values to get visually pleasing results.

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20713
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Road autobuilder is extremely wasteful
« Reply #13 on: December 28, 2020, 01:25:33 PM »
It is probably rather harsh to call this a "bug": what is needed in order to remove these symptoms is likely to be a much more sophisticated algorithm which would take considerable work to implement. What we have at present works, albeit is somewhat suboptimal. I am sure that if someone could come up with a design to make the road building algorithm more sophisticated, it would be incorporated. Certainly, I should be happy to incorporate a more sophisticated algorithm into Extended, although ideally one would use the same algorithm in both Standard and Extended since there is no reason for this part of the code to differ, so it would be better for such a change to go into Standard first.

Offline freddyhayward

  • Devotee
  • *
  • Posts: 645
  • Languages: EN
Re: Road autobuilder is extremely wasteful
« Reply #14 on: December 28, 2020, 01:29:24 PM »
It is probably rather harsh to call this a "bug": what is needed in order to remove these symptoms is likely to be a much more sophisticated algorithm which would take considerable work to implement. What we have at present works, albeit is somewhat suboptimal. I am sure that if someone could come up with a design to make the road building algorithm more sophisticated, it would be incorporated. Certainly, I should be happy to incorporate a more sophisticated algorithm into Extended, although ideally one would use the same algorithm in both Standard and Extended since there is no reason for this part of the code to differ, so it would be better for such a change to go into Standard first.
The main relevance to extended here is the road connections automatically built for industries and attractions - this is what led me to test it in standard.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10542
  • Languages: De,EN,JP
Re: Road autobuilder is extremely wasteful
« Reply #15 on: December 28, 2020, 02:06:48 PM »
Also the building order is important. When starting at the attractions the roads are much more messier, since it tend to generate direct lines and new connections would be detours. If starting at the townhall and build first the the closest and then further out, the road layout with the same weight is much better. I could never produce the spaghetti in your images. (And this is with default weights).

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20713
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Road autobuilder is extremely wasteful
« Reply #16 on: December 28, 2020, 02:12:30 PM »
Freddy - I did suspect that that might be the case.

Prissi - interesting. I will have to see whether I can look into reversing the origin and destination pairs in Extended for the automatic industry/attraction road builder.

Offline Vladki

  • Devotee
  • *
  • Posts: 3705
    • My addons, mostly roadsigns, pak128.cs
  • Languages: EN, CS
Re: Road autobuilder is extremely wasteful
« Reply #17 on: December 28, 2020, 02:22:20 PM »
Prissi - interesting. I will have to see whether I can look into reversing the origin and destination pairs in Extended for the automatic industry/attraction road builder.
And also the order in which they are built (as Prissi said, build roads to the closest targets first)

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20713
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Road autobuilder is extremely wasteful
« Reply #18 on: December 28, 2020, 02:24:40 PM »
And also the order in which they are built (as Prissi said, build roads to the closest targets first)

There is nothing that can be done about that when industries open one by one as the game progresses.

Offline Vladki

  • Devotee
  • *
  • Posts: 3705
    • My addons, mostly roadsigns, pak128.cs
  • Languages: EN, CS
Re: Road autobuilder is extremely wasteful
« Reply #19 on: December 28, 2020, 06:12:35 PM »
Well, often a whole chain is created at once - one factory and several dozens of farms supplying it. In such case it would be worth to build the roads in proper order.