Converting reliability to breakdowns per year

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
User avatar
Simons Mith
Transport Coordinator
Transport Coordinator
Posts: 326
Joined: 14 Jan 2010 23:45

Converting reliability to breakdowns per year

Post by Simons Mith »

I wanted to write a journey calculator that took a vehicle's expected breakdown rate into account, but I can't find any concrete information about how the reliability score actually generates the chance of a breakdown. Say you have a vehicle with a 98% reliability score. Say it stays at 98% for the duration of the test. Does that mean it spends 2% of its time broken down? i.e. 7.3 days per year on average?

Does every vehicle make a breakdown roll every day? Every 2.5 days? Every week?

If you turn on reduced breakdowns, how much is the reduction? Half?

I also know vehicle reliability scores can drop at varying rates according to the intent of the newGRF designer. What are the min, max and common 'decay rates' used?

How much does rates increase once a vehicle is overdue for service? Older than its maximum age?

Similarly, how do reliability scores change for prototypes, very new vehicle models, very old vehicle models and obsolete models?


For example, with some guessed numbers plugged in:

A new vehicle model appears as a prototype with a reliability score of 62% and an operating life of 18 years.
Its reliability score rises 1% per month for its preview period, eventually reaching 74%, at which point it is released.
It reliability score continues to rise at 1% per month for two years after its release, eventually reaching 98%.
Reliability for this model stays at 98% for 42 years.
Reliability then drops by 1% per month for 5 years.
Vehicle model withdrawn at 38% reliability after 47 years.
Any remaining veteran vehicles continue to see their reliability drop at 1% per month until the reliability score reaches zero.

Individual vehicles of this model lose reliability at a rate of 1% per 12 days as configured by the newGRF author.
Individual vehicles older than 18 years lose reliability at a rate of 1% per 6 days as configured by the newGRF author.

Which of these parameters are configurable - or not?

Thx.

Edit: Oh yeah, one last thing. When a vehicle does break down, it effectively brakes to speed zero as if stopping at a signal, then sits there for, what, three days, before starting up again? Is that number configurable? And planes, when they break down, slow to 200mph for the remainder of their journey, yes? Ships - they stop 'instantly' (as if at a signal), and restart instantly?
Arie-
Director
Director
Posts: 593
Joined: 20 Jan 2009 16:07

Re: Converting reliability to breakdowns per year

Post by Arie- »

Would you get the answer you could probably add it to the wiki, because I wanted to answer your question but could not find anything on actual numbers on breakdowns in various related wiki articles.
http://wiki.openttd.org/Game_mechanics
http://wiki.openttd.org/Difficulty_window
http://wiki.openttd.org/Vehicles
http://wiki.openttd.org/Servicing
http://wiki.openttd.org/Breakdowns
User avatar
Simons Mith
Transport Coordinator
Transport Coordinator
Posts: 326
Joined: 14 Jan 2010 23:45

Re: Converting reliability to breakdowns per year

Post by Simons Mith »

Arie- wrote:Would you get the answer you could probably add it to the wiki
Yeah, I will. The closest I found was http://wiki.ttdpatch.net/tiki-index.php ... on0General but even then there are gaps in what's specified.
Action0General wrote:The reliability decay speed is set when a new vehicle is bought, and specifies how quickly the reliability decays after servicing. The initial TTD default for all vehicles is 20. If a vehicle goes without servicing for a long time, or if it gets very, very old, this number increases, meaning faster decay and more breakdowns. Larger numbers mean faster decay, smaller number slower decay. If set to 0, reliability never decreases in normal operation.
'Reliability decays at a rate of 20'. I assume that's 20 ticks. But 'If a vehicle goes without servicing for a long time, or if it gets very, very old, this number increases' - by how much? Double? I assume it's the same penalty for an unserviced vehicle and for a very old vehcile, but if a vehicle is both old and unserviced, does its decay rate triple, say, (+penalty +penalty) or double twice (*penalty *penalty)? And so on...
Arie-
Director
Director
Posts: 593
Joined: 20 Jan 2009 16:07

Re: Converting reliability to breakdowns per year

Post by Arie- »

Simons Mith wrote:...
Not too long a ago there was another thread on reliability with respect to offers to use a train a year in advance and changes in reliability over the years an engine is in service. Let me look that one up.

edit: Again nothing on numbers but some general information on reliability; THREAD;
Eddi wrote:No, vehicle reliability is completely random, has nothing to do with economy. The NewGRF providing the vehicle can give a hint on whether the max reliability should be high or low, but the game still randomizes this data. Also, the max reliability follows a curve along the model lifetime. in the beginning it's low and slowly grows to maximum, in the end it falls again.
PikkaBird wrote:No it can't, all the NewGRF can do is specify how fast the reliability should decay after servicing.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Converting reliability to breakdowns per year

Post by planetmaker »

The code is found in vehicle.cpp:1019 and following

A breakdown check is performed every day.

There is one interesting lookup table and two interesting numbers:
* the lookup table _breakdown_chance:

Code: Select all

static const byte _breakdown_array[64] = {
	  3,   3,   3,   3,   3,   3,   3,   3,
	  4,   4,   5,   5,   6,   6,   7,   7,
	  8,   8,   9,   9,  10,  10,  11,  11,
	 12,  13,  13,  13,  13,  14,  15,  16,
	 17,  19,  21,  25,  28,  31,  34,  37,
	 40,  44,  48,  52,  56,  60,  64,  68,
	 72,  80,  90, 100, 110, 120, 130, 140,
	150, 170, 190, 210, 230, 250, 250, 250,
};
* Each vehicle has a 'breakdown_chance'. This 'breakdown_chance' is increased with 1/25 probability upon each check for breakdowns, at max to 255.
* The reliablity of the vehicle. The reliability is a number 0 ... 65535. If breakdowns are reduced, 26214 is added, ships get that factor yet another time (to a maximum of 65535). The resulting number is divided by 1024 - which results in a number <= 64. This is used as index into the look-up table _breakdown_array, which results in the 'reliability number'.

The thus obtained reliability number is compared to the breakdown_chance. The vehicle breaks down, if the reliability number is lower than the breakdown_chance.

Every day the reliability of the vehicle is decreased by the reliability decay speed, and only restored to the maximum when the vehicle visits a depot.
User avatar
Simons Mith
Transport Coordinator
Transport Coordinator
Posts: 326
Joined: 14 Jan 2010 23:45

Re: Converting reliability to breakdowns per year

Post by Simons Mith »

OK, I've looked at the breakdown code, and thanks to your explanation I think I follow it now. Mostly.

Putting the internal game mechanics into 'the player's viewpoint' of the same information, here's what I get.

A vehicle has an internal reliability score of 0-65535. 0 is 0% reliability, 65535 is 100%. Most vehicles can't achieve 100% reliability, so their maximum internal reliability score will usually be limited to something in the region of 50-60000 or so. As a guide, 50000 is 76% reliability, 60000 is 91%.

Ships get a bonus of 0x6666 (26214 in decimal) to their reliability score. That effectively adds a hidden 40% onto the ship's reliability score. Thus a ship with 0% reliability will behave the same as another vehicle with a 40% score, and all ships with reliability scores greater than 60% will operate equally well.

If reduced breakdowns are turned on, all vehicles become honorary ships, and ships get a double bonus. Hence ships with reliability scores greater than 20% will all function the same.

Servicing resets a vehicle's internal reliability score to the maximum, but does not adjust the breakdown number. This explains how vehicles can still break down just as they come out of the depot after being serviced.


A vehicle's breakdown chance starts at zero. Every day, it rises by one point. The code that does this is marked with *****. Every day, there is also a 1/25 chance (4%) that a vehicle's breakdown chance will rise by an extra 25 points.

Code: Select all


/* increase chance of failure */
int chance = v->breakdown_chance + 1; // This sets the new breakdown chance to whatever the current setting is, plus one *****
if (Chance16I(1, 25, r)) chance += 25; // This has a 4% chance of adding 25 to the breakdown chance
v->breakdown_chance = min(255, chance); // Maximum breakdown chance is limited to 255.
Note: in particular, if I've misunderstood the behaviour of the line marked with ***** the conclusions below this point will be wrong.

So even with perfect luck, a vehicle will end up with a 255/255 chance of a breakdown after 255 days. Worst case, it could end up with a 255/255 chance on the 10th day since its last service. On average, breakdown chance rises by 2 points per day, theoretically giving a breakdown once every 128 days ~ 4 months even for a vehicle with 100% reliability.


A vehicle's internal reliability score drops every day. The default loss is 20 points per day, and this is the bit that NewGRF authors can configure. A loss of 20 points per day out of 65535 gives a rough reduction rate of 1% per month. (1% * 65535 = 655.35; 655.35/20 = 32.7625 days for a 1% loss. Hence you'll usually see a drop every 33rd day.)


A vehicle will not break down while any of the following conditions are true:

Code: Select all

if (v->breakdown_ctr != 0 || (v->vehstatus & VS_STOPPED) ||
	_settings_game.difficulty.vehicle_breakdowns < 1 ||
	v->cur_speed < 5 || _game_mode == GM_MENU) {
return;
}
In order, in English; if it's already broken down; if it's stopped; if vehicle breakdowns are turned off; if it's moving at a speed of less than 5 (I assume that's 5 'internal kph') or if the game is on its main menu screen (I assume that's what the last entry is for.) However, vehicle reliability still continues to drop in all of these cases.


When a vehicle does break down, its breakdown counter is set back to zero again.

Whenever a breakdown check is performed (once daily per vehicle), the vehicle's current reliability score (0-65535) is divided by 1024 and looked up on the _breakdown_chance table. Thus a vehicle with a reliability of 45567 (69%) scores 56. (45567 / 1024 = 44.499, so choose the 44th entry in the list, counting from zero). Hence if the breakdown score is greater than or equal to 56, we get a breakdown. Assuming no change in reliability, the breakdown chance rises by 2 points per day on average, so we'd expect to see this vehicle break down after 56/2 = 28 days, but it could happen after 3 days in the worst case, and 56 days best case. However, normally reliability slowly drops as the breakdown chance rises, and in this case, while after 3 days the reliability index is still 44, after 26 days, the vehicle's reliability score will have dropped to 45047 (index now 43, breakdown threshold 52). So on average a breakdown happens at 26 days (52/2) when the rising breakdown chance reaches the same level as the ever-falling breakdown threshold. After 52 days, the index will have fallen to 43 (and looking up the 43rd entry on the table we see 52) and we'll definitely have a breakdown at this point if we haven't already.



Conclusions:

It seems that even with 100% reliability and a NewGRF with no reliability drop, you'll still have a breakdown every 251 days, guaranteed, or 126 days on average.

Vehicles with reliability scores >~95% will be indistinguishable, breaking down roughly once every 126 days.

Vehicles with reliability scores of <~13% are indistinguishable, breaking down every 3 days.

In the middle, a vehicle with a reliability of 40% will have an internal reliability score of about 26000 and will break down once every 13 days, best case, 6.5 days on average.

At medium-low reliability scores there's much more variation in how often vehicles break down. They won't all get hit with the 25 point penalty, but those that do will usually find it's immediately enough to tip them over the brink. Even with good luck, though, they'll still conk out within a few weeks.



I don't really think the current breakdown behaviour is remotely what anyone wants. The non-linear breakdown table really makes things screwy:

Code: Select all

reliability		days to break down
%			best	avg	worst
0-12			3	2	1
12-15		4	2	1
15-18		5	3	1
20-21		6	3	1
21-25		7	4	1
25-28		8	4	1
28-31		9	5	1
31-34		10	5	1
34-37		11	6	1
37-39		12	6	1
39-45		13	7	1
45-46		14	7	1
46-48		15	8	1
48-50		16	8	1
50-51		17	9	1
51-53		19	11	1
53-54		21	12	1
54-56		25	13	1
56-57		28	14	2
57-59		31	16	2
59-60		34	17	2
60-62		37	18	2
62-64		40	20	2
64-65		44	22	2
65-67		48	24	2
67-68		52	26	2
68-70		56	28	3
70-71		60	30	3
71-73		64	32	3
73-75		68	34	3
75-76		72	36	3
76-78		80	40	4
78-79		90	45	4
79-81		100	50	4
81-82		110	55	5
82-84		120	60	5
84-85		130	65	5
85-87		140	70	6
87-89		150	75	6
89-90		170	85	7
90-92		190	95	8
92-93		210	105	9
93-95		230	115	9
95-100		250	125	10
Add 40 to the reliability score for ships or if you have reduced breakdowns set.
Add 80 to the reliability score for ships and reduced breakdowns.

Trying 10 steam vans with 28% reliability for 3 months, I got an average of 2.5 breakdowns per vehicle. Reliability dropped from 28%-18% over that time. Without reduced breakdowns, I'd have had 18 breakdowns per vehicle on average, if I've interpreted the code correctly. In fact, the true figure would be reduced because a broken-down vehicle can't break down again, and TBH if that's the main factor protecting a vehicle from even worse performance than the already dismal behaviour we see now, then the breakdown system really does need an overhaul.

The reliability score isn't an really indicator of the percentage risk of breakdown, it's a measure of how many 'maintenance points' a vehicle has. Breakdown within some given (and rather low) number of days is certain for all vehicles, and a well-maintained or highly reliable vehicle merely lasts longer before it breaks down. Crucially, servicing does /not/ appear to reset the breakdown number. So, among other things, if you wanted to guarantee a train won't break down before going through a complex junction, you could do so by waiting for the thing to break down, then servicing it, then sending it through, and provided it has a reliability of 77%+ and can cross the junction in 4 days or so, it should get through OK. If a vehicle breaks down just as it comes out of being serviced, that's a good thing, because you then know the vehicle has a high maintenance score and a low breakdown number.


Finally: I'm not surprised no-one's analysed this area very closely before. Ew.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 19 guests