taniwha / Extraplanetary-Launchpads

GNU General Public License v3.0
54 stars 45 forks source link

Add ETA to build window and add Kerbal Alarm Clock support #82

Closed henrybauer closed 9 years ago

henrybauer commented 10 years ago

For issue #78, just adds a simple hh:mm:ss display to the progress bar

henrybauer commented 9 years ago

tacoship2

Still needs some work - need to only create one KAC alarm per build if we have multiple resources (although I'm not sure how I'd test multiple resources), and KerbalStats makes it overestimate.

Oh and there's some cruft in there to get it to compile with 0.90. Will need to rebase against the proper 0.90 release.

henrybauer commented 9 years ago

space center settings

henrybauer commented 9 years ago

This patch is basically ready, except it still overestimates when KerbalStats is installed.

I've been avoiding looking at the math for KerbalStats, and finally did so.. I can't use the current delta method to compute that, since the increase in productivity changes every step (the delta of the delta changes). So, being accurate for KerbalStats would require a whole different method. I can think of two ways to do it:

  1. Run a copy of DetermineProductivity(), but with a time parameter (which would them eventually call GetKerbalContribution() with a time parameter). Then run DetermineProductivity(0), DetermineProductivity(1), DetermineProductivity(2), etc, to get the productivity for now, now+1 hour, now+2 hours, etc. Keep adding clock hours until we have enough productivity (kerbalHours) to complete the craft. Basically numerical integration. Depending on how slow it is, use smaller units (half hours, minutes, seconds) to get more accurate.
  2. Somehow make a giant equation where I can plug in required productivity and get number of hours, across all Kerbals.

Since I don't know how to do the second one, I've been thinking about the first.

Both methods would mean calculating the ETA once at the start of the build instead of every FixedUpdate because it's not exactly lightweight calculations. We would also have to recalculate whenever the ship changes (just like onCrewTransferred calls DetermineProductivity() already). That's probably better overall for performance anyways.

It would also mean trying to figure out how much productivity we need - which right now seems to be kerbalHours needed = (number of resource needed * density * 5), or RocketParts * 0.0025 * 5. So 1000 RocketParts would be... 25 kerbalHours? Actually that seems fairly straightforward.

I started writing up this comment as to why the current version should be merged now and the KerbalStats version should be merged at some future date.. but now it doesn't seem like it will be so terrible to do, so I might as well do that first. :)

taniwha commented 9 years ago

After a rather desperate race to get a workshop up to my station to get a ship built in time for a Jool window, I see the value of even an inaccurate ETA. Please update this so I can merge it.

Note: keep in mind that I plan on adding recipes so not only will RocketParts not be the only required resource, but the Kh/t for each resource may vary (for now, don't worry too much about the latter).

henrybauer commented 9 years ago

Merged up to date with master, no real changes. Tested again and it still works :)

Includes the Settings window change