ShotgunNinja / Kerbalism

Hundreds of Kerbals were killed in the making of this mod.
The Unlicense
43 stars 19 forks source link

Track in-use time of modules for reliability purposes #123

Closed lordcirth closed 5 years ago

lordcirth commented 7 years ago

Right now, engines have a MTBF of 8 years, which is fine if they are sitting around in orbit. But an engine that's running at full throttle for many minutes should have a non-negligible chance of failure during that time (say 0.05% per minute?). If I understand correctly, running the engine doesn't currently change the failure chance. I don't have a build environment set up, but around: https://github.com/ShotgunNinja/Kerbalism/blob/814e3c2a4f80d17b25e3e0dbcdd736a8c2d898cb/src/Modules/Reliability.cs#L121

you could maybe bring the next failure 2000 seconds closer per second the engine is running, or something like that. A 2000 multiplier might seem like a lot, but if my math is correct, that gives a ~0.05% chance of failure per burn minute. After all, a nuclear tug's engine might spend 10's of minutes burning over a 8-year lifespan. I rather like the idea of sending an engineer out to inspect the engine after a 3-minute burn to Mun to make sure it's ready for the retrograde burn when you get there. More fun than only needing to inspect once it's been sitting in a stable orbit for a few years. Not sure what the exact code would be - we'd want to avoid running too much, since it's in a fixedUpdate().

ShotgunNinja commented 7 years ago

The issue is in fact that age is computed on the total time, instead of the time a module has been in use.

Detecting when a module is in use is a module-type aware operation. The reliability system in its current implementation is instead module-type agnostic: in other words, it works with any module type and doesn't require knowledge specific for a particular type of module.

The current implementation also exploit this limitation to reduce computation done for each reliability module (as there may be hundreds of them around at any given time).

That being said, I agree keeping track of time in use is desiderable. Maybe something to that effect can be implemented in future, so let's keep this open.

lordcirth commented 7 years ago

Just a thought - is there a way to embed the trigger for reducing reliability into the specific module, ie the engine module, such that Unity will only run it while the engine is on, rather than us having to check on every fixedUpdate()?