-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal for thermal control + various changes #105
base: master
Are you sure you want to change the base?
Conversation
catchup 2
… a separate set of modifiers for the degeneration rate
…ecked for - Reworked STRESS section of the planner to better accomodate custom rules
- changed temp_diff to return signed temperature, temperature modifier still absolute
src/Profile/Modifiers.cs
Outdated
@@ -47,6 +55,10 @@ public static double evaluate(Vessel v, vessel_info vi, vessel_resources resourc | |||
k /= vi.comforts.factor; | |||
break; | |||
|
|||
case "mod_comfort_space_limiter": | |||
k *= vi.comforts.factor * ((1 - vi.comforts.factor) + (vi.living_space)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary parenthesis, possible int to double conversion that can be avoided (don't trust the compiler)
k *= vi.comforts.factor * (1.0 - vi.comforts.factor + vi.living_space);
for (int i = 0; i < factors.Count; i++) | ||
{ | ||
if (i > 1) tooltip_text += "\n"; | ||
tooltip_text += factors[i]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
string operations generate a lot of temporaries
use StringBuilder directly instead
StringBuilder sb = new StringBuilder();
for(...)
{
sb.append(factors[i]);
}
return sb.ToString();
src/Profile/Modifiers.cs
Outdated
|
||
case "inverse": | ||
double i = 1.0 / k; | ||
k = double.IsInfinity(i) || double.IsNaN(i) ? 0.0 : i; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace it with
k = k > double.epsilon ? 1.0 / k : 0.0;
First of all, thanks a lot for your continuous contributions to this project. Now, you are probably aware I'm about to refactor/rewrite a lot of stuff. I already got a 'generic expression parser' done. So I was thinking to introduce the concept of a 'modifier-expression'.
That way you can write modifier-expressions like:
to get temperature above survival range. Or you could write a modifier-expression like:
that will evaluate to 1.0 when something is pressurizing the habitat, and 0.0 otherwise. Or this one:
that is 1.0 if pressure is ~90 kPA, and 0.0 otherwise. This new 'modifier-expressions' concept is also going to be used in two other (awesome) new things that are coming: a new telemetry system where arbitrary modifier-expression readings are provided by parts/rules, and a new alert system where arbitrary modifier-expression conditions are checked by parts/rules. The new telemetry system in particular is going to be relevant here. You have already understood the fundamental impossibility of providing the current planner analysis panels in a generic rule-driven framework. Therefore the current planner panels are a sort of 'hack', good enough but show its limitations as soon as the user start specifying rules very different than the ones I developed against. I hope the new telemetry system may completely replace the planner panels too. This is all very early-design / experiments. I'm really interested in what you think about these proposed improvements. Best! |
Thanks for the reviewing of my code. I'm a hobbyist programmer and while I usually succeed in making things work, I'm really struggling to find the most efficient/fast/clean way of doing it, so your remarks are super useful. All this is meant to be an implementation proposal, not a real PR. It would require a testing / fixing / optimization pass as well as a rebasing on your dev branch. The modifier change seems a good idea, indeed having to maintain duplicates of functional code for flight and editor (planner) situations is not ideal. My tough on this when I discovered how all this work is that ideally, the "Vessel" reference in the "vessel_info" class should be allowed to be null. Then all the functions used to calculate the "vessel_info" properties should be able to perform with the actual vessel being optional. This is what I did for the Habitat static function that calculate atmospheric flux and use the root part skinTemp when loaded to account for reentry heat. This allow me to use the same function in planner and vessel_info: Unless I misunderstand what you are proposing, it seems to me that this is what you are trying to do : an unified vessel variables cache that would be indifferent to the game context (editor/flight loaded/flight unloaded). If this happen and together with your (awesome) "modifier-expression" idea, this could indeed allow a config-driven planner (and in-flight monitor) UI system. Another thing that I was thinking is that processes and rules should be merged in a single system. Maybe this is too much but here is some prospective work for an unified system, using habitat thermal control as an example :
Another GUI example for stress :
|
@gotmachine That's very good ideas and I feel the need to speed-update you on what's going on, so we can design this together. I'll create a new issue with the proposed changes to the mod architecture and we'll discuss there. |
The PR contains a proposal for the thermal control system and various tweaks. Meant as a reference for future implementation
CHANGES :
Issue #81 : Being able to use different modifiers for input rate and degeneration rate in a rule
Added an optional "modifier_degen" field to rule, that allow to specify a separate set of modifiers for the degeneration rate.
I tried to check "modifiers_degen" in all places where rules modifiers existence was checked, but this may need to be reviewed.
Issue #114 : Temperature inconsistency between loaded / unloaded vessels
Sim.Temperature() now doesn't use the skinTemp of the vessel root part.
Issue #83 : Thermal control
The proposed system has the following features :
Simulate the thermal flux that affect the vessel habitat, accounting for :
Simulate the temperature change in habitat accounting for thermal inertia
Kill the kerbals when the temperature change is too drastic
A ECLSS heater process use EC to compensate heat losses
Radiators produce a Coolant resource using EC to compensate heat gains
The Coolant output of radiators account for
Exothermic ECLSS/ISRU processes have a Coolant input, meaning that they require radiators to work
Related settings :
Other modifiers changes / addition
ex : modifier = volume,inverse,temperature // equal (1/volume)*temperature
Planner changes