OneLife icon indicating copy to clipboard operation
OneLife copied to clipboard

Clothing R results in bizarre equilibrium temperatures

Open JoePaulsen opened this issue 7 years ago • 10 comments

(I'm considering "R" here to mean insulation values in onetech/wiki, not the editor R, which are just R*the body part constants)

So I did the math and in game testing on clothing, and the equilibrium temperature for cold biomes gives some extremely weird results. For example, the extra temperature you get from adding a backpack (only .05R) and one shoe in completing a full set of clothing, adds more temperature than the rest of the clothing combined. 3 decent pieces of clothing are essentially no better than naked as well, which is weird.

While the full formula is a bit complex, the bonus temperature from the result of computeClothingR simplifies pretty closely to: 0.025/(1-R) - 0.025.

Which also has the weird corollary that if we could achieve .96+ R, we would heat up uncontrollably past desert levels in a cold biome.

Possibly fixes, IMO:

  1. Just simplifying the formula. Instead of body heat increases every update, you'd have a simple destination heat calculated using clothing and environment.

  2. A bandaid fix on the combined R: cube rooting the R and multiplying by 0.95 would give fairly decent values on the lower end and higher end.

  3. Use a Rimwold-style post-processing formula, which you can re-use for other after-corrections you have in the game. Basically you define a curve of points for input/output In this case the post-process curve for the R would be something like:

(0,0),(.05,0.2),(0.2,0.5),(0.5,0.7),(0.8,0.8),(0.9,0.88),(0.98,0.92),(1,0.94),(5,0.96)

JoePaulsen avatar Mar 05 '19 12:03 JoePaulsen

Yeah it absolutely does not feel good with the current system. I was attempting to remake a server 15 town because I had thought they learned to make a heated outside area via some mix of bear skin rugs, flat roads, regular floors, and a few walls. What had actually pulled my temperature to such a good state was having a backpack.

Once you learn how much the difference a shoe or BP makes you suddenly realize how useless buildings are in comparison. The 93.5% insulation possible means that once you step on a fire for a few seconds you're not going to need to worry about temperature for a long time. As described above using your current system we're so close to reaching the magic 96% that if you added better clothing we would likely explode into flames by trying to use a mixture of best in slot items.

It just seems off that a single shoe or BP is what makes up 30%+ of your total heat.

ghost avatar Mar 05 '19 12:03 ghost

Full gear:

Full gear minus one shoe :

So just removing one piece of gear removes almost as much heat has the whole gear but wearing only one piece of gear even with good insulation gives almost no temperature.

It makes every clothes except full gear almost not worth it, and people that only wear a few clothes but not full gear waste unknowingly a lot of heat potential thinking that the current clothes they have are good but they are maybe only missing one loincloth or one shoe to have double temperature insulation which is illogical.

Dodg-e avatar Mar 05 '19 15:03 Dodg-e

Cold foot there, hmm?

Yes, I will have to figure out what's going on here.

I think it's that the build-up factor of body heat grows exponentially the closer we get to perfect insulation. So that's why the last piece of clothing helps so much. The difference between 0.85 and 0.90 is way bigger than the difference between 0.40 and 0.80, in terms of the way body heat builds up.

jasonrohrer avatar Mar 07 '19 06:03 jasonrohrer

Yeah, so what is happening is that the total R value of the clothing set effectively "sets" the equilibrium point between you and your environment.

You gain 0.25 heat per sim step (body heat), and the environment is trying to pull you down at a certain rate, based on how far your temp is from the env.

When you're at a temp so that the env is pulling you down at a rate of -0.25 per sim step, your temp will stop changing.

The R-value of the clothing has a non-linear effect on this, which makes it hard for players to reason about.

I won't have time to think more about it this week, but I'll figure something out here soon.

jasonrohrer avatar Mar 07 '19 06:03 jasonrohrer

One option, by the way, is to just get rid of the body heat component entirely.

Then clothing will just slow your loss of heat acquired from heat sources, and that's all it will do.

I think the "slow down" part feels about right, currently. Taking off one shoe doesn't speed that up in a shocking way.

jasonrohrer avatar Mar 07 '19 07:03 jasonrohrer

Current code is here:

            float clothingHeat = computeClothingHeat( nextPlayer );
            
            float heldHeat = computeHeldHeat( nextPlayer );
            

            float clothingR = computeClothingR( nextPlayer );

            // clothingR modulates heat lost (or gained) from environment
            float clothingLeak = 1 - clothingR;

            // clothing heat and held heat are conductive
            // if they are present, they move envHeat up or down, before
            // we compute diff with body heat
            // (if they are 0, they have no effect)
            float heatDelta = 
                clothingLeak * ( clothingHeat + 
                                 heldHeat + 
                                 nextPlayer->envHeat 
                                 - 
                                 nextPlayer->bodyHeat );

            // slow this down a bit
            heatDelta *= 0.5;
            
            // feed through curve that is asymtotic at 1
            // (so we never change heat faster than 1 unit per timestep)
            
            float heatDeltaAbs = fabs( heatDelta );
            float heatDeltaSign = sign( heatDelta );

            float maxDelta = 2;
            // larger values make a sharper "knee"
            float deltaSlope = 0.5;
            
            // max - max/(slope*x+1)
            
            float heatDeltaScaled = 
                maxDelta - maxDelta / ( deltaSlope * heatDeltaAbs + 1 );
            
            heatDeltaScaled *= heatDeltaSign;


            nextPlayer->bodyHeat += heatDeltaScaled;
            

jasonrohrer avatar Mar 07 '19 07:03 jasonrohrer

Yup, pretty much said all that in the topic post :P It's got the current equation that you settle on and a few solutions. Like I said, just simplifying it is probably easiest, but also a quick and dirty

float clothingR = computeClothingR( nextPlayer );

//New clothingR = pow(clothingR,0.3)*0.92 //End New

float clothingLeak = 1 - clothingR;

Smoothes out the clothing hunger reduction per piece a lot. It'd buff air insulation enough to give everyone about a half second delay per pip when naked, but it'd also nerf clothing on the higher end (right now, an absolutely perfect set gives you basically perfect temperature)

JoePaulsen avatar Mar 07 '19 07:03 JoePaulsen

One option, by the way, is to just get rid of the body heat component entirely.

Clothing not making you warm, but only slowing the rate at which you get cold, is going to be very counterintuitive, and it's going to make clothing useless for anyone who can't go stand by a fire every minute or so - i.e. everyone hunting and foraging, or anyone who wants to stay productively engaged in some task that doesn't involve a fire.

CrazyEddieTK avatar Mar 07 '19 17:03 CrazyEddieTK

The effects of sitting on a fire and then working aren't currently worth it anyways. The reason it feels worth it is because it is actually useful to jumpstart your temperature bar so you don't have to wait the full time for your clothing to reach equilibrium when you first put on clothes. But once it's there, there's no reason to ever step on a fire again, you return to equilibrium too fast from the hot end. I guess I don't like it from a realism point either, clothes should be useful for warming up on their own right?

JoePaulsen avatar Mar 07 '19 21:03 JoePaulsen

Yeah, I think I'm going to move toward simplifying the formula here.

The clothing R works fine in terms of slowing down heat change when the environment is hotter or colder than you.

But it should have a different effect on your overall temp other than just holding body heat in.

I'm changing it to "close the gap" between the environment and your ideal temp.

jasonrohrer avatar Mar 15 '19 19:03 jasonrohrer