Game mechanics
(→Smooth Economy Rules: Adding special cases section) 
m (mph to kmish/h conversion is mph*1.6 not mph/1.6) 

(15 intermediate revisions by 6 users not shown)  
Line 6:  Line 6:  
it=Meccaniche di gioco  it=Meccaniche di gioco  
nl=Spelmechanisme  nl=Spelmechanisme  
+  pl=Mechanika gry  
ru=Игровая механика  ru=Игровая механика  
language_page=en  language_page=en  
Line 24:  Line 25:  
Number of companyowned vehicles that turned profit last year>=1200 points for 0 vehicles100 points for at least 120 vehicles0 to 10%  Number of companyowned vehicles that turned profit last year>=1200 points for 0 vehicles100 points for at least 120 vehicles0 to 10%  
    
−  Number of recentlyserved station parts company owns>=800 points for 0 parts100 points for at least 80 parts0 to 10%  +  Number of recentlyserved station parts that the company owns>=800 points for 0 parts100 points for at least 80 parts0 to 10% 
    
Lowest profit of vehicles at least two years old>=£10,0000 points for loss or £0100 points for at least £10,0000 to 10%  Lowest profit of vehicles at least two years old>=£10,0000 points for loss or £0100 points for at least £10,0000 to 10%  
    
−  Lowest quarterly revenue earned in past 3 years>=£50k0 points for £050 points for at least £50k0 to 5%  +  Lowest quarterly revenue earned in the past 3 years>=£50k0 points for £050 points for at least £50k0 to 5% 
    
−  Highest quarterly revenue earned in past 3 years>=£100k0 points for £0100 points for at least £100k0 to 10%  +  Highest quarterly revenue earned in the past 3 years>=£100k0 points for £0100 points for at least £100k0 to 10% 
    
−  Units of cargo delivered in past year>=40,0000 points for 0 units400 points for at least 40,000 units0 to 40%  +  Units of cargo delivered in the past year>=40,0000 points for 0 units400 points for at least 40,000 units0 to 40% 
    
−  Number of types of cargo delivered in past quarter>=80 points for 0 cargotypes50 points for at least 8 cargotypes 0 to 5%  +  Number of types of cargo delivered in the past quarter>=80 points for 0 cargotypes50 points for at least 8 cargotypes 0 to 5% 
    
Current cash in bank>=£10m0 points for £050 points for at least £10m0 to 5%  Current cash in bank>=£10m0 points for £050 points for at least £10m0 to 5%  
Line 119:  Line 120:  
* Cargo has not been picked up from any of those stations in 637.5 days. [https://github.com/OpenTTD/OpenTTD/blob/1.9.2/src/station_cmd.cpp#L3300L3306]  * Cargo has not been picked up from any of those stations in 637.5 days. [https://github.com/OpenTTD/OpenTTD/blob/1.9.2/src/station_cmd.cpp#L3300L3306]  
* Station has rating less than or equal to 25% AND has more than 200 units of cargo waiting. [https://github.com/OpenTTD/OpenTTD/blob/1.9.2/src/station_cmd.cpp#L3379L3386]  * Station has rating less than or equal to 25% AND has more than 200 units of cargo waiting. [https://github.com/OpenTTD/OpenTTD/blob/1.9.2/src/station_cmd.cpp#L3379L3386]  
−  * Station has rating less than 50% AND more than 0 units of cargo waiting, happening with RANDOM PROBABILITY proportional to the station rating. I.E. if station rating is 49%, there is a ~1% chance, at 25% rating there is a ~50% chance, and at 0%  +  * Station has rating less than 50% AND has more than 0 units of cargo waiting, happening with RANDOM PROBABILITY proportional to the station rating. I.E. if station rating is 49%, there is a ~1% chance, at 25% rating there is a ~50% chance, and at 0% station rating there is a 100% chance. [https://github.com/OpenTTD/OpenTTD/blob/1.9.2/src/station_cmd.cpp#L3388L3396] 
* Station has more than 4096 units of cargo waiting. [https://github.com/OpenTTD/OpenTTD/blob/1.9.2/src/station_cmd.cpp#L3398L3411].</small>  * Station has more than 4096 units of cargo waiting. [https://github.com/OpenTTD/OpenTTD/blob/1.9.2/src/station_cmd.cpp#L3398L3411].</small>  
 More than 1500  90  35%   More than 1500  90  35%  
Line 151:  Line 152:  
Divide the total rating points by 255 to get the percent rating. The maximum possible rating is 100%.  Divide the total rating points by 255 to get the percent rating. The maximum possible rating is 100%.  
−  Every 2.5 days station ratings are computed; ratings can't change by more than 2 points (0.78%) per cycle, except due to items under "Event".  +  Every 2.5 days ([https://github.com/OpenTTD/OpenTTD/blob/0d599e155f335e922ad2be738a3ab73d1dea346b/src/date_type.h#L34 185 ticks]), station ratings are computed; ratings can't change by more than 2 points (0.78%) per cycle, except due to items under "Event". 
Events give an instant, temporary boost (or penalty) to ratings of nearby stations. The rating will gradually return to normal, following the 2 point per 2.5 days rule.  Events give an instant, temporary boost (or penalty) to ratings of nearby stations. The rating will gradually return to normal, following the 2 point per 2.5 days rule.  
Line 159:  Line 160:  
'''Note:''' The exact formula can be seen under "[https://github.com/OpenTTD/OpenTTD/blob/97c0594cedcad866bbdea8a0f86406b5c38694a3/src/station_cmd.cpp#L3262 UpdateStationRating()]" in station_cmd.cpp. This uses some values calculated in "[https://github.com/OpenTTD/OpenTTD/blob/97c0594cedcad866bbdea8a0f86406b5c38694a3/src/economy.cpp#L1595 LoadUnloadVehicle()]" in economy.cpp.  '''Note:''' The exact formula can be seen under "[https://github.com/OpenTTD/OpenTTD/blob/97c0594cedcad866bbdea8a0f86406b5c38694a3/src/station_cmd.cpp#L3262 UpdateStationRating()]" in station_cmd.cpp. This uses some values calculated in "[https://github.com/OpenTTD/OpenTTD/blob/97c0594cedcad866bbdea8a0f86406b5c38694a3/src/economy.cpp#L1595 LoadUnloadVehicle()]" in economy.cpp.  
−  '''Note:''' If the rating gets less than 50%, the station starts losing cargo.  +  '''Note:''' If the rating gets to be less than 50%, the station starts losing cargo. 
−  '''Note:''' If the amount of cargo waiting is greater than 4096 units (or 4,096,000 liters), the station also starts losing cargo.  +  '''Note:''' If the amount of cargo waiting is greater than 4096 units (or 4,096,000 liters), the station also starts losing cargo. There is a hard cap of 32,768 units of cargo that can be waiting at a station. Any more than that completely disappears every few days. [https://github.com/OpenTTD/OpenTTD/blob/97c0594cedcad866bbdea8a0f86406b5c38694a3/src/station_cmd.cpp#L3380L3393] 
==Cargo delivery to stations==  ==Cargo delivery to stations==  
−  
−  +  Goods are distributed to stations according to station rating.  
−  +  If there is only only station around, then a percentage of available goods equal to the station's rating is distributed to it every 2.5 day cycle.  
+  
+  If multiple stations are present, then goods are divided between them based on rating. If there are stations belonging to more than one company, then goods are first divided between companies according to the best station of each company: the proportion of goods allocated to a company C is equal to the best station rating of C over the sum of all best station ratings for all companies. Note that this will be equal to 100% if all stations belong to one company. Then each company's allocation is subdivided among its stations. A station S belonging to C receives a fraction of C's company allocation equal to the rating of S over the sum of the ratings of all stations belonging to C.  
==Local authority rating==  ==Local authority rating==  
Line 235:  Line 237:  
Code for town ratings is in town.h, town_cmd.c, tree_cmd.c, and road_cmd.c.  Code for town ratings is in town.h, town_cmd.c, tree_cmd.c, and road_cmd.c.  
+  ==Passenger and Mail generation==  
+  Towns and the company headquarters generate passengers and mail, while oil rigs only generate passengers.  
+  ===Town Passenger Generation===  
+  In each periodic processing (i.e. every 256 ticks), a random value 0<=X<=255 is generated for each house tile. If X isn't smaller than the population of the tile, no passengers are generated. Otherwise, X/8+1 passengers are generated (rounded down). If there is a recession going on, the number of generated passengers is halved, but this division gets rounded up instead of down. Mail generation happens in a similar manner, but with a new random value, and checking against the mail generation multiplier instead of the population. See the full list of default values for HouseProps: [https://newgrfspecs.ttwiki.net/wiki/DefaultHouseProps]  
+  ===Company Headquarters===  
+  The Company Headquarters is a unique structure that generates passengers and mail depending on it's level which is dependent on the performance rating of the company. Higher level company HQs generate more passengers and mail, the output of the headquarters is evenly distributed over all four tiles on a per tile basis as per the following formulas:  
+  
+  Passengers: 256 / 4 tiles / (6  company HQ Level (a value between 1 and 5) )  
+  
+  Mail: 196 / 4 tiles / (6  company HQ Level (a value between 1 and 5) )  
==Industry production==  ==Industry production==  
Line 317:  Line 329:  
*The chance for a production change each month is:  *The chance for a production change each month is:  
−  ** 50% for only_decrease industry to decrease (currently only Temperate terrain Oil Wells) or  +  ** 50% for <code>only_decrease</code> industry to decrease (currently only Temperate terrain Oil Wells) or 
−  ** 50% for 1/3 chance (=16.7%) that other industry (non only_decrease) changes production.  +  ** 50% for 1/3 chance (=16.7%) that other industry (non <code>only_decrease</code>) changes production. 
Line 332:  Line 344:  
====Smooth Economy Rules====  ====Smooth Economy Rules====  
+  
+  {{OutdatedDifficulty setting and Advanced setting have been replaced by Settings}}  
+  
:''Distinguish [[Advanced Settings/Economy#Enable smooth economy (more, smaller changes)Smooth economy]] (advanced setting) and [[DifficultySteady economy]] (difficulty setting)''  :''Distinguish [[Advanced Settings/Economy#Enable smooth economy (more, smaller changes)Smooth economy]] (advanced setting) and [[DifficultySteady economy]] (difficulty setting)''  
Line 345:  Line 360:  
*These two are multiplied together, i.e. 4.5% * 33% = 1.5%:  *These two are multiplied together, i.e. 4.5% * 33% = 1.5%:  
−  ** Poor service: '''1.5%''' to increase and '''3.0%''' to decrease  +  ** <code>only_decrease</code> industry: '''0%''' chance to increase and '''4.5%''' chance to decrease 
−  ** Good service: '''3.0%''' to increase and '''1.5%''' to decrease  +  ** Poor service: '''1.5%''' chance to increase and '''3.0%''' chance to decrease 
−  ** Excellent service: '''3.75%''' to increase and '''0.75%''' to decrease  +  ** Good service: '''3.0%''' chance to increase and '''1.5%''' chance to decrease 
+  ** Excellent service: '''3.75%''' chance to increase and '''0.75%''' chance to decrease  
−  *With the [[smooth economy]] option enabled, production changes per month are between 3 and 23%  +  *With the [[smooth economy]] option enabled, production changes per month are between 3% and 23% 
**Industries with very low productions, (ie. 1240 tonnes per month) will have higher changes.  **Industries with very low productions, (ie. 1240 tonnes per month) will have higher changes.  
**Primary industries produce cargo 8 or 9 times a month. Monthly production is an industries 'base value' multiplied times 8 or 9. For example, the base value for a coal mine is 15 tons, so the monthly production is 120 or 135 tons. This base value is capped at 255, so the maximum possible monthly production for any industry is 2040 or 2295. [http://www.ttforums.net/viewtopic.php?p=163733&sid=2128541ce7feb1a96a454f56152123a2#p163733 Ref]  **Primary industries produce cargo 8 or 9 times a month. Monthly production is an industries 'base value' multiplied times 8 or 9. For example, the base value for a coal mine is 15 tons, so the monthly production is 120 or 135 tons. This base value is capped at 255, so the maximum possible monthly production for any industry is 2040 or 2295. [http://www.ttforums.net/viewtopic.php?p=163733&sid=2128541ce7feb1a96a454f56152123a2#p163733 Ref]  
Line 365:  Line 381:  
(1 + (0.03  0.015) * 0.13) ^12  1 = 0.0237 or '''2.37%'''  (1 + (0.03  0.015) * 0.13) ^12  1 = 0.0237 or '''2.37%'''  
−  The coal mine will grow an average of 2.37% after the first year<br>  +  The coal mine will grow an average of 2.37% on average after the first year.<br> 
(1.0237 ^20)  1 = 59.6% after twenty years<br>  (1.0237 ^20)  1 = 59.6% after twenty years<br>  
(1.0237 ^50)  1 = 321.8% or '''3.22x''' after fifty years<br>  (1.0237 ^50)  1 = 321.8% or '''3.22x''' after fifty years<br>  
Line 372:  Line 388:  
For an industry with rating of more than 80%, there is a '''3.75%''' chance of increase and '''0.75%''' chance of decrease:<br>  For an industry with rating of more than 80%, there is a '''3.75%''' chance of increase and '''0.75%''' chance of decrease:<br>  
−  (1 + (.0375  0.0075) * .13) ^12  1 = 0.0478 or '''4.78%'''  +  (1 + (0.0375  0.0075) * 0.13) ^12  1 = 0.0478 or '''4.78%''' 
−  The industry will grow approximately 4.78% after first year<br>  +  The industry will grow approximately 4.78% on average after the first year.<br> 
(1.0478 ^20)  1 = '''2.54x''' after twenty years<br>  (1.0478 ^20)  1 = '''2.54x''' after twenty years<br>  
(1.0478 ^50)  1 = '''10.32x''' after fifty years<br>  (1.0478 ^50)  1 = '''10.32x''' after fifty years<br>  
(1.0478 ^100)  1 = '''106.62x''' after one hundred years<br>  (1.0478 ^100)  1 = '''106.62x''' after one hundred years<br>  
−  
−  However, in game you will find industries changing their production rate very randomly. It must be stressed the above examples are only true when observing many industries over the longterm; individual industries may greatly deviate from these averages. Statistically speaking, 6 out of 10 industries will not go from 100 to  +  For an industry with the <code>only_decrease</code> flag set (currently Temperate Oil Wells), there is only a '''4.5%''' chance of decrease:<br> 
+  (1 + (0  0.045) * 0.13) ^12  1 = (0.99415) ^12 1 = 0.068 or '''6.8%'''  
+  
+  The industry will shrink on average by approximately 6.8% after the first year.<br>  
+  (0.9320 ^20) = '''24.46%''' of initial production after twenty years<br>  
+  (0.9320 ^50) = '''2.96%''' of initial production after fifty years<br>  
+  
+  ln(0.5) / ln(0.99415) = 118.1 months or '''9.84 years''' is the half life of an <code>only_decrease</code> industry.<br>  
+  ln(8 / 48) / ln(0.99415) = 305.9 months or '''25.4 years''' is the mean lifetime of a temperate Oil Wells (starting at 48 oil/month).<br>  
+  ln(8 / 152) / ln(0.99415) = 501.8 months or '''41.8 years''' is the mean lifetime of a temperate Oil Wells (starting at 152 oil/month).<br>  
+  
+  
+  For good service, it takes '''29.6 years''' on average '''to double'''; with excellent service, it takes '''14.8 years'''. If in the game's time a day is 2.36 seconds, then the '''doubling time''' with good service is '''7.1 hours'''; with excellent service, the doubling time is '''3.6 hours'''. For production to go from near bottom of 100 to near maximum of 2040 or 2295 takes '''130 years''' with good service and '''65 years''' with excellent service.  
+  
+  However, in game you will find industries changing their production rate very randomly. It must be stressed the above examples are only true when observing many industries over the longterm; individual industries may greatly deviate from these averages. Statistically speaking, 6 out of 10 industries will not go from 100 to 20402295 even with the best service during 65 years. About 1 out of 9 industries will even lower their production when being served at 6080% cargo transported for 50 years.  
For more responsiveness from industries, adapt the number of wagons to industry production (for the lowest production, you should use two wagons). [Full Load] orders are usually used for such cargo trains.  For more responsiveness from industries, adapt the number of wagons to industry production (for the lowest production, you should use two wagons). [Full Load] orders are usually used for such cargo trains.  
−  '''Note:''' The exact formula can be seen under "[  +  '''Note:''' The exact formula can be seen under "[https://github.com/OpenTTD/OpenTTD/blob/master/src/industry_cmd.cpp#L2586 ChangeIndustryProduction()]" in industry_cmd.cpp. 
==Delivery payment rates==  ==Delivery payment rates==  
Line 496:  Line 525:  
==Vehicle speeds==  ==Vehicle speeds==  
−  Internally OpenTTD works with a unit called "kmish/h", which is equal to "mph  +  Internally OpenTTD works with a unit called "kmish/h", which is equal to "mph*1.6". 
The conversion factor from kmish/h to km/h is 1.00584, and the conversion factor from kmish/h to mph is 1.6.  The conversion factor from kmish/h to km/h is 1.00584, and the conversion factor from kmish/h to mph is 1.6.  
Line 653:  Line 682:  
; slope_force = weight_on_upslope * slope_steepness * 100  weight_on_downslope * slope_steepness * 100 [N]  ; slope_force = weight_on_upslope * slope_steepness * 100  weight_on_downslope * slope_steepness * 100 [N]  
; axle_friction = total_weight * 10 [N]  ; axle_friction = total_weight * 10 [N]  
−  ; rolling_friction =  +  ; rolling_friction = floor((current_speed + 512) * 15 / 512) * total_weight [N] 
; air_drag_coefficient = 14 * floor(air_drag_value * (1 + number_of_parts * 3/20)) / 1000  ; air_drag_coefficient = 14 * floor(air_drag_value * (1 + number_of_parts * 3/20)) / 1000  
; air_drag = floor(air_drag_coefficient * current_speed^2) [N]  ; air_drag = floor(air_drag_coefficient * current_speed^2) [N] 
Latest revision as of 03:31, 23 July 2020
Infrastructure
Settings
More topics
Climates · Towns · Industries · Economy · Disasters · Tips · Hidden features · Hotkeys · Console · Game mechanics · Multiplayer · Scenario editor · Online content
Here you can find information about how OpenTTD calculates ingame figures.
You always wanted to know how the stationrating was built up? How goodsdistribution works? Here you can find it!
Contents 
[edit] Company rating
Each part of the company rating is a linear function, ie. earning 50% of the target for a component will give 50% of the points allocated for that component. Where components involve monetary amounts, these are converted to the currency of the current game; internally these amounts are stored as the pound amount.
Component  Target  Points (min)  Points (max)  Percentage 

Number of companyowned vehicles that turned profit last year  >=120  0 points for 0 vehicles  100 points for at least 120 vehicles  0 to 10% 
Number of recentlyserved station parts that the company owns  >=80  0 points for 0 parts  100 points for at least 80 parts  0 to 10% 
Lowest profit of vehicles at least two years old  >=£10,000  0 points for loss or £0  100 points for at least £10,000  0 to 10% 
Lowest quarterly revenue earned in the past 3 years  >=£50k  0 points for £0  50 points for at least £50k  0 to 5% 
Highest quarterly revenue earned in the past 3 years  >=£100k  0 points for £0  100 points for at least £100k  0 to 10% 
Units of cargo delivered in the past year  >=40,000  0 points for 0 units  400 points for at least 40,000 units  0 to 40% 
Number of types of cargo delivered in the past quarter  >=8  0 points for 0 cargotypes  50 points for at least 8 cargotypes  0 to 5% 
Current cash in bank  >=£10m  0 points for £0  50 points for at least £10m  0 to 5% 
Current loan from bank  £0  0 points for >£250k  50 points for £0  0 to 5% 
Totals  0 points  1000 points  0 to 100% 


[edit] Station rating
This section shows the factors that affect the station rating. All calculations are done separately for each cargo type.
Factor  Condition  Rating points  Rating % 

Max speed of last vehicle to load cargo (to a max of 255 km/h) Divide speed by 2 if it was a road vehicle. 
Above 85 km/h (52 mph)  (Speed (km/h)  85) / 4  0% to 17% 
Age in years of last vehicle to load cargo  2  10  4% 
1  20  8%  
0  33  13%  
Days since last cargo pickup Multiply days in "Condition" column by 4 if last vehicle was a ship. (Note: If a vehicle was ready to pick up a cargo but there was no cargo, or if it was full, it is still regarded as a cargo pickup. This may be a bug.) 
30 to 52.5  25  10% 
15 to 30  50  20%  
7.5 to 15  95  37%  
less than 7.5  130  51%  
Units of cargo waiting at station Note: if cargo has been transferred to other stations, then the game MAY consider the maximum cargo waiting at any of those stations as the waiting cargo for the source station: TruncateCargo(). This is triggered when the game truncates cargo (waiting_changed = true), which occurs when any of the stations meet the following conditions:

More than 1500  90  35% 
1001 to 1500  35  14%  
601 to 1000  0  0%  
301 to 600  10  4%  
101 to 300  30  12%  
less than 100  40  16%  
Statue in town of station  Built  26  10% 
Event  Condition  Rating point change  Rating % change 
Small advertising campaign bought  Station within 10 tiles of town center  +64  +25pp 
Medium advertising campaign bought  Station within 15 tiles of town center  +112  +44pp 
Large advertising campaign bought  Station within 20 tiles of town center  +160  +63pp 
Road vehicle crashed  Station within 22 tiles of crash  160  63pp 
Train crashed  Station within 30 tiles of crash  160  63pp 
Town bribe failed  Station within town influence  255  100pp 
Divide the total rating points by 255 to get the percent rating. The maximum possible rating is 100%.
Every 2.5 days (185 ticks), station ratings are computed; ratings can't change by more than 2 points (0.78%) per cycle, except due to items under "Event". Events give an instant, temporary boost (or penalty) to ratings of nearby stations. The rating will gradually return to normal, following the 2 point per 2.5 days rule.
The amount of cargo that can be transported from an industry is fully reliant on the station rating. This means that if there is exactly one station serving an industry, on ticks when the industry produces cargo, exactly station rating % of the cargo will be moved to the station. So if the amount of cargo transported from an industry is low, it is probably because the station rating is low, too.
Note: The exact formula can be seen under "UpdateStationRating()" in station_cmd.cpp. This uses some values calculated in "LoadUnloadVehicle()" in economy.cpp.
Note: If the rating gets to be less than 50%, the station starts losing cargo.
Note: If the amount of cargo waiting is greater than 4096 units (or 4,096,000 liters), the station also starts losing cargo. There is a hard cap of 32,768 units of cargo that can be waiting at a station. Any more than that completely disappears every few days. [5]
[edit] Cargo delivery to stations
Goods are distributed to stations according to station rating.
If there is only only station around, then a percentage of available goods equal to the station's rating is distributed to it every 2.5 day cycle.
If multiple stations are present, then goods are divided between them based on rating. If there are stations belonging to more than one company, then goods are first divided between companies according to the best station of each company: the proportion of goods allocated to a company C is equal to the best station rating of C over the sum of all best station ratings for all companies. Note that this will be equal to 100% if all stations belong to one company. Then each company's allocation is subdivided among its stations. A station S belonging to C receives a fraction of C's company allocation equal to the rating of S over the sum of the ratings of all stations belonging to C.
[edit] Local authority rating
Ratings limit some player actions; they start at +500 and can change based on some actions.
Currently you can exploit the game by planting about 200 trees within a town's influence radius. You may need to clear an area first, in order to have somewhere to plant them, but planting 200 will raise even a minimum rating of 1000 to 220. If your rating is Mediocre or lower, planting 30 trees will approximately wipe out the rating penalty from building one station. Planting trees while at a rating of Very Good or better has no effect.

* "Required rating" is listed for the settings Permissive / Neutral / Hostile of 
Each month players' ratings automatically change:
 Rating goes up by 5 if it is less than 200.
 Rating goes up by 12 for each station that has transferred cargo in the last 50 days.
 Rating goes down by 15 for each station that has not transferred cargo in the last 50 days.
Example:
A player has a rating of 300, (Very Poor), 2 active stations and 1 inactive station at a town.
5pts + 2 * 12pts  15pts = 14pts points gain per month.
(200  300)pts / 14pts/mo = 8 months before the town will let him build another station.
Code for town ratings is in town.h, town_cmd.c, tree_cmd.c, and road_cmd.c.
[edit] Passenger and Mail generation
Towns and the company headquarters generate passengers and mail, while oil rigs only generate passengers.
[edit] Town Passenger Generation
In each periodic processing (i.e. every 256 ticks), a random value 0<=X<=255 is generated for each house tile. If X isn't smaller than the population of the tile, no passengers are generated. Otherwise, X/8+1 passengers are generated (rounded down). If there is a recession going on, the number of generated passengers is halved, but this division gets rounded up instead of down. Mail generation happens in a similar manner, but with a new random value, and checking against the mail generation multiplier instead of the population. See the full list of default values for HouseProps: [6]
[edit] Company Headquarters
The Company Headquarters is a unique structure that generates passengers and mail depending on it's level which is dependent on the performance rating of the company. Higher level company HQs generate more passengers and mail, the output of the headquarters is evenly distributed over all four tiles on a per tile basis as per the following formulas:
Passengers: 256 / 4 tiles / (6  company HQ Level (a value between 1 and 5) )
Mail: 196 / 4 tiles / (6  company HQ Level (a value between 1 and 5) )
[edit] Industry production
Here is how the game determines how much cargo an industry produces per month. Production of raw materials happens 8 or 9 times per month. (It happens every 256 ticks. There are 74 ticks in a day, and 28 to 31 days in a month (date_type.h). This means that only about 9% of industries will produce 9 times in a 28day February, but about 96% of industries will produce 9 times in a 31day month like March.) The production will always be a multiple of 8 or 9, unless the industry changed production during that month.
This table lists possible starting productions governed by the smooth economy patch. These numbers are multiples of 8. When the game generates a new map, each industry produced 8 times and had no production changes in the December before the game started.
Raw Material Industry  Produced Cargo  Initial production range  

Coal Mine  Coal  56 to 176  
Forest  Wood  48 to 152  
Oil Rig  Oil  56 to 176  
Farm  Grain and Livestock  40 to 112  
Copper Ore Mine  Copper Ore  56 to 112  
Oil Wells  Oil  48 to 152  
Iron Ore Mine  Iron Ore  40 to 112  
Bank (temperate)  Valuables  24 to 64  
Gold Mine  Gold  24 to 80  
Diamond Mine  Diamonds  24 to 80  
Fruit Plantation  Fruit  40 to 112  
Rubber Plantation  Rubber  40 to 112  
Water Supply  Water  48 to 152  
Farm  Maize  40 to 128  
Lumber Mill  Wood  180 or 225 (if trees available)  
Candyfloss Forest  Cotton Candy  48 to 152  
Battery Farm  Batteries  40 to 128  
Cola Wells  Cola  48 to 136  
Plastic Fountains  Plastic  56 to 160  
Bubble Generator  Bubbles  48 to 152  
Toffee Quarry  Toffee  40 to 112  
Sugar Mine  Sugar  40 to 128 
(To calculate this table, look under _origin_industry_specs in table/build_industry.h for the industry and its cargo. The sugar mine has CT_SUGAR, 11
, so the production starts at 11. Apply the formula from DoCreateNewIndustry() in industry_cmd.cpp: multiply the production by a random integer from 128 to 383, then divide by 256, rounding down. So 11 becomes 5 to 16. Finally, multiply it by 8 to get 40 to 128.)
[edit] Production change
Each month the game randomly changes some industry productions.
[edit] Default / TTDlike Economy Rules
For 256x256 tile maps there is one change per month possible (only 1 industry changes). Number scales nicely with map size since the introduction of "Daily production changes" function in trunk (r14332).
 As with smooth economy, industries produce cargo 8 or 9 times per month.
However  productions are limited to 6 production levels: lowest, lower, normal (with a new game started or a new industry built), higher, 2x higher and the highest. Production changes between these levels are either a 50% decrease (half) or a 100% increase (double).
 Examples:
 A Coal Mine: lowest (32 or 40 t per month), lower (64 or 72), normal (120 or 135), higher (240 or 270), 2x higher (480 or 540) and the highest (960 or 1080).
 A Forest: lowest (32 or 64 t per month), lower (35 or 70), normal (78 or 117), higher (208 or 260), 2x higher (416 or 468) and the highest (832 or 936).
 A Gold Mine: lowest (12 or 18 bags/month), lower (32 or 40), normal (56 or 63), higher (112 or 126), 2x higher (224 or 252) and the highest (448 or 504).
To make things simple, let's look what are the chances for 256x256 maps (max. 1 change per month = max. 1 industry per month changes production):
 The chance for a production change each month is:
 50% for
only_decrease
industry to decrease (currently only Temperate terrain Oil Wells) or  50% for 1/3 chance (=16.7%) that other industry (non
only_decrease
) changes production.
 50% for
 If a production change does occur (~16.7% chance per month):
 For an industry that has poor or no service (less than 60% of its cargo is transported): 33% chance of increase, 67% chance of decrease.
 For an industry that has good (greater than 60%) service: 67% chance of increase, 33% chance of decrease.
 There is no bonus for excellent service with default economy.
 To calculate the chance for a particular change, i.e. 50% * 1/3 * 33% = 5.56%:
 Poor service: 5.56% that 1 possible change per month is an increase and 11.12% that 1 possible change per month is a decrease.
 Good service: 11.12% that 1 possible change per month is an increase and 5.56% that 1 possible change per month is a decrease.
[edit] Smooth Economy Rules
Out of Date
This article or section is outdated. Some of its content may no longer be accurate due to changes in the latest release. Please update this article.
Difficulty setting and Advanced setting have been replaced by Settings
 Distinguish Smooth economy (advanced setting) and Steady economy (difficulty setting)
 The chance for a production change each month is 4.5%, i.e. 4.5% of producing industries from industry list change production.
 If a production change does occur:
 For an
only_decrease
industry (currently only Temperate terrain Oil Wells) 0% chance of increase, 100% chance of decrease.  For an industry that has poor or no service (less than 60% of its cargo is transported): 33% chance of increase, 67% chance of decrease.
 For an industry that has good (greater than 60%) service: 67% chance of increase, 33% chance of decrease.
 For an industry that has excellent (greater than 80%) service: 83% chance of increase, 17% chance of decrease.
 For an
 These two are multiplied together, i.e. 4.5% * 33% = 1.5%:

only_decrease
industry: 0% chance to increase and 4.5% chance to decrease  Poor service: 1.5% chance to increase and 3.0% chance to decrease
 Good service: 3.0% chance to increase and 1.5% chance to decrease
 Excellent service: 3.75% chance to increase and 0.75% chance to decrease

 With the smooth economy option enabled, production changes per month are between 3% and 23%
 Industries with very low productions, (ie. 1240 tonnes per month) will have higher changes.
 Primary industries produce cargo 8 or 9 times a month. Monthly production is an industries 'base value' multiplied times 8 or 9. For example, the base value for a coal mine is 15 tons, so the monthly production is 120 or 135 tons. This base value is capped at 255, so the maximum possible monthly production for any industry is 2040 or 2295. Ref
[edit] Special Cases
 Oil Rig passenger production is limited to 16 passengers per production event, meaning a maximum of 144 or 128 passengers per month. [7]
 Lumber Mill is technically not a producing industry and is classified as a secondary industry in the code. Four or five times a month it will search outward in a 40 by 40 area in a spiral pattern looking for a fullygrown tree to cut down. If it finds one, the tile will be demolished and 45 tons of wood will be output. This means it has a maximum production of 225 or 180 tons of wood per month, solely dependent on the availability of trees.[8]
 Temperate climate Banks never change production (except due to the 8 vs 9 production events per month).
[edit] Examples
If a coal mine has 70% of its output transported, there is a 3% chance (4.5% * 67%) of a production increase from 323% and a 1.5% chance (4.5% * 33%) of a production decrease from 323% (but 13% on average).
(1 + (0.03  0.015) * 0.13) ^12  1 = 0.0237 or 2.37%
The coal mine will grow an average of 2.37% on average after the first year.
(1.0237 ^20)  1 = 59.6% after twenty years
(1.0237 ^50)  1 = 321.8% or 3.22x after fifty years
(1.0237 ^100)  1 = 10.35x after one hundred years
For an industry with rating of more than 80%, there is a 3.75% chance of increase and 0.75% chance of decrease:
(1 + (0.0375  0.0075) * 0.13) ^12  1 = 0.0478 or 4.78%
The industry will grow approximately 4.78% on average after the first year.
(1.0478 ^20)  1 = 2.54x after twenty years
(1.0478 ^50)  1 = 10.32x after fifty years
(1.0478 ^100)  1 = 106.62x after one hundred years
For an industry with the only_decrease
flag set (currently Temperate Oil Wells), there is only a 4.5% chance of decrease:
(1 + (0  0.045) * 0.13) ^12  1 = (0.99415) ^12 1 = 0.068 or 6.8%
The industry will shrink on average by approximately 6.8% after the first year.
(0.9320 ^20) = 24.46% of initial production after twenty years
(0.9320 ^50) = 2.96% of initial production after fifty years
ln(0.5) / ln(0.99415) = 118.1 months or 9.84 years is the half life of an only_decrease
industry.
ln(8 / 48) / ln(0.99415) = 305.9 months or 25.4 years is the mean lifetime of a temperate Oil Wells (starting at 48 oil/month).
ln(8 / 152) / ln(0.99415) = 501.8 months or 41.8 years is the mean lifetime of a temperate Oil Wells (starting at 152 oil/month).
For good service, it takes 29.6 years on average to double; with excellent service, it takes 14.8 years. If in the game's time a day is 2.36 seconds, then the doubling time with good service is 7.1 hours; with excellent service, the doubling time is 3.6 hours. For production to go from near bottom of 100 to near maximum of 2040 or 2295 takes 130 years with good service and 65 years with excellent service.
However, in game you will find industries changing their production rate very randomly. It must be stressed the above examples are only true when observing many industries over the longterm; individual industries may greatly deviate from these averages. Statistically speaking, 6 out of 10 industries will not go from 100 to 20402295 even with the best service during 65 years. About 1 out of 9 industries will even lower their production when being served at 6080% cargo transported for 50 years.
For more responsiveness from industries, adapt the number of wagons to industry production (for the lowest production, you should use two wagons). [Full Load] orders are usually used for such cargo trains.
Note: The exact formula can be seen under "ChangeIndustryProduction()" in industry_cmd.cpp.
[edit] Delivery payment rates
The amount you get paid for delivering cargo is based on 4 factors: the amount of cargo you deliver, the value of the cargo, the distance you deliver it, and how ontime you deliver it.
Cargo  Units  Early Delivery Time (days) 
Late Delivery Time (days) 
Initial cargo payment (pounds) 

Passengers  Immediate  24  £39  
Valuables  Bags  1  32  £91 
Livestock  Items  4  18  £53 
Grain  Tons  4  40  £58 
Goods  Crates  5  28  £75 
Coal  Tons  7  None  £72 
Steel  Tons  7  None  £69 
Iron Ore  Tons  9  None  £62 
Wood  Tons  15  None  £61 
Oil  Kiloliters  25  None  £54 
Bags  20  90  £55  
Arctic specific  
Wheat  Tons  4  40  £58 
Paper  Tons  7  60  £66 
Gold  Bags  10  40  £71 
Food  Tons  Immediate  30  £69 
Tropical specific  
Rubber  Kiloliters  2  20  £54 
Fruit  Tons  Immediate  15  £51 
Maize  Tons  4  40  £53 
Tropical Wood  Tons  15  None  £97 
Copper Ore  Tons  12  None  £59 
Water  Kiloliters  20  80  £57 
Diamonds  Bags  10  None  £71 
Toyland specific  
Sugar  Tons  20  None  £54 
Toys  25  None  £68  
Batteries  2  30  £53  
Sweets  Tons  8  40  £75 
Toffee  Tons  14  60  £58 
Cola  Kiloliters  5  75  £59 
Candyfloss  Tons  10  25  £61 
Bubbles  20  80  £62  
Plastic  Kiloliters  30  None  £54 
Fizzy Drinks  30  50  £76 
Initial cargo payment values are for delivering 100 pieces of cargo 1 tile. Payment goes up with inflation as the game progresses.
Late delivery penalties:
 For each day after the Early Delivery time that you deliver the cargo, you are penalized 0.4%.
 For each day after the Late Delivery time that you deliver the cargo, you are penalized an additional 0.4%.
 Maximum penalty is 88%.
Examples (no inflation):
Deliver 200,000 liters of oil 20 squares in 10 days:
2 * £54 * 20 squares * 100% = £2160
Deliver 100 bags of mail 100 squares in 100 days:
£55 * 100 squares * (1  80*0.004  10*0.004) = £3520
HINT calculate easy:
Income = cargo units * cargo value * 0,4
cargo value comes from the Yaxis on the specific transported goods graph ingame
measure your real delivery time in days and plot on xaxis
This result will give you an easy estimation of your income with 5% deviation
Notes:
 The exact formula is much more complicated and slightly more accurate, due to rounding error when converting from larger discrete values. See economy.cpp (GetTransportedGoodsIncome) and Cargo income.
 Distance is measured between the namelabeled tiles of the stations, not from the industries or by vehicle distance traveled. It is computed by adding the differences in x and y tiles (manhattan distance), not straightline distance.
 Each cargo has a characteristic time at which payment is maximized, assuming you can keep it moving away from the source station at a constant speed. For a cargo with a "late delivery" penalty, this time is typically around 70 days; for one without, this is typically around 130 days.
[edit] Vehicle speeds
Internally OpenTTD works with a unit called "kmish/h", which is equal to "mph*1.6". The conversion factor from kmish/h to km/h is 1.00584, and the conversion factor from kmish/h to mph is 1.6.
A tile is, for vehicle speed purposes 664.(216) kmish, 668 km or 415 miles long. This is based on the following facts:
 A tile has 16 sub locations per X/Y axis.
 A vehicle has stores remainder of tile movement in a byte called subspeed, thus has 256 different values.
 The vehicle's (raw) speed is added to subspeed. The resulting number is divided by 256, the remainder is stored in subspeed and the vehicle is moved quotient sub locations forward. For trains and aircraft the raw speed is in kmish/h, for road vehicles/ships in 0.5 kmish/h. For trains and aircraft this step is done twice a tick, whereas ships and road vehicles do it once a tick.
 A day contains 74 ticks, and takes 24 hours.
Now assume a vehicle going 1 kmish/hour: (1 * 16 * 256) / (74 * 2) * 24 = 664.(216).
The net result is that 100 km/hour is ~3.6 tiles/day.
[edit] Aircraft
 By default aircraft fly at a quarter of their listed speed (this can be changed in advanced settings).
 Aircraft acceleration varies per aircraft, between 144 kmish/h/day and 400 kmish/h/day.
 Broken down planes fly at 320 kmish/h.
 Airport taxi speed is 150 kmish/h.
[edit] Road Vehicles
 Road vehicles accelerate at 37 kmish/h/day.
 Road vehicles go around corners at half their max speed.
 Road vehicles accelerate an additional 74 kmish/h/day downhill.
 When going uphill, road vehicles slow down 10% 4 times per tile. This balances out with acceleration at 34ish km/h for all road vehicles.
(Note: This does not apply when using the improved road vehicle acceleration model.)
[edit] Ships
 Ships accelerate at 37 kmish/h/day.
 A "stopped" ship resumes its last speed instantly.
[edit] Trains
(with the realistic train acceleration patch)
 Trains are not affected going up or down hills if they are powerful enough.
 Trains are limited to entering and exiting a depot and making 90° turns at 61 km/h.
 Trains can make one 45° turn or two 45° turns in opposite directions at a time without slowing down.
 When making two or more 45° turns in the same direction, the max speed is limited as follows:


"Curvature" means the average number of wagons of the train between turns. However, very sharp turns (curvatures 0 and 1) are not averaged out in longer trains.
 New railtypes can specify custom maximum curve speeds in the same steps as the three default types in the table.
 Tilting train gain an additional bonus of 20% on the maximum speed.
 Train acceleration and max speed are affected by engine power, maximum tractive effort (all engines and powered wagons combined), current speed, air drag, total train mass, and wagons/engines on slopes.
 Non maglev train Acceleration spreadsheet can be found on ttforums: ttforums
 Braking is twice acceleration except when entering a depot or a station.
See also: Realistic acceleration and Corners.
See ground_vehicle.cpp, aircraft_cmd.cpp, roadveh_cmd.cpp, ship_cmd.cpp, train_cmd.cpp, vechicle.cpp for code.
As of OpenTTD 1.6.1, given power in hp, max tractive effort in kN, total weight of the train in tonnes, the number train parts (engines and wagons), the air drag value of the first engine in the train (NewGRF setting, defaults to min(192,max(1,floor(2048/max_speed)))
, meaning faster trains are built more aerodynamically), the combined weight of any train parts (engines or wagons) currently on an upslope, the combined weight of any train parts (engines or wagons) currently on a downslope, the slope steepness (game setting [110], default 3), and the current speed of the train in km/h, the acceleration of a nonmaglev train can be calculated as follows:
 force = min((max_te * 1000), floor((power * 746) / (current_speed * 5/18))) [N]
 slope_force = weight_on_upslope * slope_steepness * 100  weight_on_downslope * slope_steepness * 100 [N]
 axle_friction = total_weight * 10 [N]
 rolling_friction = floor((current_speed + 512) * 15 / 512) * total_weight [N]
 air_drag_coefficient = 14 * floor(air_drag_value * (1 + number_of_parts * 3/20)) / 1000
 air_drag = floor(air_drag_coefficient * current_speed^2) [N]
 acceleration = (force  (slope_force + axle_friction + rolling_friction + air_drag)) / (total_weight * 4) [256th of a km/h per halftick]
Note: air_drag_coefficient is twice that if any part of the train is in a tunnel
Given the same values, the equilibrium speed, eg the speed the train would eventually settle on if the same conditions continued indefinitely, can be calculated as follows [Assuming a constant rolling_friction
(ie the speed stays below 512 km/h), and ignoring the flooring of force
and air_drag
to an integral value]:
 p = (slope_force + axle_friction + rolling_friction) / air_drag_coefficient
 q = (power * 746 * 18/5) / air_drag_coefficient
 C = (27/2*q + ((27/2*q)^2 + 27*p^3)^(1/2))^(1/3)
 equilibrium = min(max_speed, p/C  C/3, max(0, max_te * 1000 / air_drag_coefficient  p)^(1/2))
[edit] Town growth
See Towns#Town_Growth.