The International Simutrans Forum

 

Author Topic: Searching for the formula of the speedbonus  (Read 603 times)

0 Members and 1 Guest are viewing this topic.

Offline Flemmbrav

  • Devotee
  • *
  • Posts: 215
  • PAK-DEV P192C
  • Languages: DE, EN
Searching for the formula of the speedbonus
« on: February 02, 2020, 05:32:37 PM »
Hello,
I've been doing some research on this but did not end up finding it. Would love to know how to calculate and I can't really get behind it sadly.

Offline Andarix

  • *
  • Posts: 173
  • Languages: de
Re: Searching for the formula of the speedbonus
« Reply #1 on: February 02, 2020, 06:41:51 PM »

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5670
  • Languages: EN, NO
Re: Searching for the formula of the speedbonus
« Reply #2 on: February 03, 2020, 06:59:56 AM »
The formula I've dug out of the code contains an unexplained division by three not reflected in that Excel file. Also, that Excel file doesn't explain some of the inputs to the formula, all of which are pak set dependent in one way or another. (The columns labeled income are also actually profits, since running costs are subtracted.)

Offline Leartin

  • Heir-Benevolent-Dictator-Apparent
  • Devotee
  • *
  • Posts: 1469
  • PAK-DEV P192C
  • Languages: DE, EN
Re: Searching for the formula of the speedbonus
« Reply #3 on: February 03, 2020, 07:57:56 AM »
Formula in that file: "=(1+((100*D2/Q2)-100)*(R2/1000))*(D2/100)"
D2 is max vehicle speed, Q2 the required speed of the speedbonus at vehicle introduction, and R2 the given bonus.

To go through it step by step:

Compare the speed you can reach with the speed you should reach.
Multiply by a hundred and subtract a hundred. Therefore, you get a negative value if you don't reach the required speed.
Multiply by the bonus value in promille. Therefore, the higher the bonus, the more effect.
Add one. This represents the base value that gets altered by the speedbonus.
 - so far, so good.
But why multiply by the vehicles speed/100? That would mean even if the vehicle goes faster than the speedbonus requires, as long as it goes under 100km/h, it might still gain less than the base value...

Offline Andarix

  • *
  • Posts: 173
  • Languages: de
Re: Searching for the formula of the speedbonus
« Reply #4 on: February 03, 2020, 10:20:00 AM »
The formula I've dug out of the code contains an unexplained division by three not reflected in that Excel file. ...

This is probably related to the information in the goods files. There masn specifies 3 times the price.

Offline DrSuperGood

  • Dev Team
  • Devotee
  • *
  • Posts: 2833
  • Languages: EN
Re: Searching for the formula of the speedbonus
« Reply #5 on: February 03, 2020, 10:33:26 AM »
I have mentioned it several times and the revised speed bonus dialog should make it very clear what is happening (if I ever committed it, I forget).

Speed bonus is percentage bonus income per 10% faster maximum speed than current average speed.

Say the average speed is 100 km/h, the maximum speed of the vehicle is 200 km/h and the speed bonus is 5%.

200/100 = 2: The vehicle is twice the average speed.
2 - 1 = 1: The vehicle is 100% faster than the average speed.
100 / 10 = 10: The speed bonus is multiplied by 10 times.
5 * 10 = 50: The speed bonus total is 50%.
100 + 50 = 150: The per km earned for the good is 150% of its base.
If the good is worth £1.00 per km, then it is worth £1.50 per km due to speed bonus.

This also works for negative speed bonus. The only difference is that the minimum value of a good is capped at some nominal amount (cannot go negative).
« Last Edit: February 03, 2020, 10:44:27 AM by DrSuperGood »

Offline Leartin

  • Heir-Benevolent-Dictator-Apparent
  • Devotee
  • *
  • Posts: 1469
  • PAK-DEV P192C
  • Languages: DE, EN
Re: Searching for the formula of the speedbonus
« Reply #6 on: February 03, 2020, 10:52:08 AM »
So...
V = Max speed of the vehicle
A = Base speed set for a specific year
B = Speedbonus of a good in question

((V/A)-1)*10B+100 for the value in percent?
((V/A)-1)*(B/10)+1 for the value as a multiplier?


Offline DrSuperGood

  • Dev Team
  • Devotee
  • *
  • Posts: 2833
  • Languages: EN
Re: Searching for the formula of the speedbonus
« Reply #7 on: February 03, 2020, 06:06:10 PM »
((V/A)-1)*10B+100 for the value in percent?((V/A)-1)*(B/10)+1 for the value as a multiplier?
Yes, assuming B is in %.

Offline Flemmbrav

  • Devotee
  • *
  • Posts: 215
  • PAK-DEV P192C
  • Languages: DE, EN
Re: Searching for the formula of the speedbonus
« Reply #8 on: February 05, 2020, 10:57:04 PM »
Thanks a lot for all the help!