Page 1 of 1

How do costs and running costs for ships work?

Posted: 16 Mar 2017 23:22
by SimYouLater
I'm having trouble with blueFISH. Here is what I know:

The following section provides the base values.

Code: Select all

basecost {
 	PR_RUNNING_SHIP: 0;
 	PR_BUILD_VEHICLE_SHIP: 0;
}
Both values have a range between -8 and 16.

The cost_factor and running_cost_factor properties are also involved, and have a range between 0 and 255.


What is the formula used in determining the costs? Or a table of all outcomes I can refer to? Thanks in advance.

Re: How do costs and running costs for ships work?

Posted: 17 Mar 2017 17:48
by frosch
(cost_factor) * (2^basecost) * (number from https://newgrf-specs.tt-wiki.net/wiki/N ... cost_table) * inflation

Usually you only set "cost_factor". "basecost" is for difficulty/boredom settings.

Re: How do costs and running costs for ships work?

Posted: 17 Mar 2017 20:48
by SimYouLater
frosch wrote:(cost_factor) * (2^basecost) * (number from https://newgrf-specs.tt-wiki.net/wiki/N ... cost_table) * inflation

Usually you only set "cost_factor". "basecost" is for difficulty/boredom settings.
Thanks. What is the value for inflation if inflation is turned off in settings?

EDIT: I figured it out. The "inflation" rate with inflation turned off is 0.0029230769230769, in case anyone needs that information.

Re: How do costs and running costs for ships work?

Posted: 18 Mar 2017 05:09
by SimYouLater
After trying to use the formula I've been given, I've discovered that it cannot be correct.

If I am aiming for a ship cost of approximately £1,250,000 and a running cost of £73,000, the formula should work as follows...

(cost_factor) * (2^PR_BUILD_VEHICLE_SHIP) * 65000 * inflation = price
1 * 2^13 * 65000 * 0.0029230769230769 = 1556479.999999987712 (£1,556,480)

(running_cost_factor) * (2^PR_RUNNING_SHIP) * 5600 * inflation = running cost
1 * 2^12 * 5600 * 0.0029230769230769 = 67048.36923076870144 (£67,048)

...but instead I get this...
Unnamed, 1885-01-01.png
Unnamed, 1885-01-01.png (13.63 KiB) Viewed 5046 times
What gives?

Re: How do costs and running costs for ships work?

Posted: 18 Mar 2017 15:59
by frosch
I forgot some things:
* There are two advanced settings which scale construction and running cost. "Normal cost" has factor 1.
* There is always some offset to the exponent, which I believe is not listed in the wiki. In case of vehicle purchase and running cost it is -8,
* No inflation means factor "1".
* The internal currency is British pounds.

So for ship running cost with normal running cost setting and no inflation from game start, the formula is:
(cost_factor) * 2^(basecost-8) * 5600

I have no idea how you end up with 213, are you sure you set the properties to the values you meant to?
Anyway you should probably not change "basecost", but only "cost_factor".

Re: How do costs and running costs for ships work?

Posted: 18 Mar 2017 17:48
by SimYouLater
frosch wrote:I forgot some things:
* There is always some offset to the exponent, which I believe is not listed in the wiki. In case of vehicle purchase and running cost it is -8,
* No inflation means factor "1".
Ah, I see.
frosch wrote:So for ship running cost with normal running cost setting and no inflation from game start, the formula is:
(cost_factor) * 2^(basecost-8) * 5600

I have no idea how you end up with 213, are you sure you set the properties to the values you meant to?
I accidentally put a running_cost_foactor of 13. It should have been 12.
frosch wrote:Anyway you should probably not change "basecost", but only "cost_factor".
But if cost_factor is multiplied by 2^basecost, and basecost N = 1 - 8, then that should give a negative number. :?

Re: How do costs and running costs for ships work?

Posted: 18 Mar 2017 20:03
by Transportman
SimYouLater wrote: But if cost_factor is multiplied by 2^basecost, and basecost N = 1 - 8, then that should give a negative number. :?
A negative exponent means 1/(2^positive value of the exponent), not that the basecosts go negative (would make the game quite easy if that would be the case :p).

Re: How do costs and running costs for ships work?

Posted: 23 Mar 2017 02:47
by SimYouLater
Transportman wrote:
SimYouLater wrote: But if cost_factor is multiplied by 2^basecost, and basecost N = 1 - 8, then that should give a negative number. :?
A negative exponent means 1/(2^positive value of the exponent), not that the basecosts go negative (would make the game quite easy if that would be the case :p).
I have set costs and maintenance to medium. I'm trying to get a cost of 2.5 million. I've calculated that should be impossible, so I'm aiming for 2.08 million, but the numbers still don't add up.

Code: Select all

cost_factor = 1
PR_BUILD_VEHICLE_SHIP = 13
PR_BUILD_VEHICLE_SHIP - 8 = 5
2^(PR_BUILD_VEHICLE_SHIP - 8) = 32

1 * 32 = 32
1 * 32 * 65,000 = 2,080,000

inflation = 1

1 * 32 * 65,000 * 1 = 2,080,000
Instead I get this:

Re: How do costs and running costs for ships work?

Posted: 16 Nov 2019 22:45
by phobos2077
I got curious how exactly "Running costs" setting works. Reading through the engine source code I didn't find it being used directly for the final running costs calculation. But changing the setting, starting new game and comparing values I got these results:

- High is only about 12.5% higher than Medium
- Low is 25% lower than Medium

Does anyone knows how exactly this difficulty setting is implemented? I wanted to adjust running costs for my ships to make them about 50% more expensive and it seems to be not possible with how BaseCosts NewGRF does it (because bit-shift is used for multiplication, no floating point operation). I'd be great if I could just change the 12.5% increase to 50% increase on High setting if it's just some value edit in NewGRF and doesn't involve engine patching.