Content: Slate Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate Marble
Background: Slate Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate Marble
Pattern: Blank Waves Notes Sharp Wood Rockface Leather Honey Vertical Triangles
Welcome to TerraFirmaCraft Forums

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

  • Announcements

    • Dries007

      ATTENTION Forum Database Breach   03/04/2019

      There has been a breach of our database. Please make sure you change your password (use a password manager, like Lastpass).
      If you used this password anywhere else, change that too! The passwords themselves are stored hashed, but may old accounts still had old, insecure (by today's standards) hashes from back when they where created. This means they can be "cracked" more easily. Other leaked information includes: email, IP, account name.
      I'm trying my best to find out more and keep everyone up to date. Discord (http://invite.gg/TerraFirmaCraft) is the best option for up to date news and questions. I'm sorry for this, but the damage has been done. All I can do is try to make sure it doesn't happen again.
    • Claycorp

      This forum is now READ ONLY!   01/20/2020

      As of this post and forever into the future this forum has been put into READ ONLY MODE. There will be no new posts! A replacement is coming SoonTM . If you wish to stay up-to-date on whats going on or post your content. Please use the Discord or Sub-Reddit until the new forums are running.

      Any questions or comments can be directed to Claycorp on either platform.
dodgersfan2134

Setting up our own decay rate.

11 posts in this topic

I was hoping someone would answer some questions I had in regards to configuring decay.

"food decay" {


# This is a global multiplier for food decay. Unlike FoodDecayRate which only modifies the base decay and not the environmental effect upon decay, this multiplier will multiply against the entire amount. Set to 0 to turn decay off.
D:FoodDecayMultiplier=1.0

# This number causes base decay to equal 50% gain per day. If you wish to change, I recommend you look up a y-root calculator 1.0170378966055869517978300569768^24 = 1.5
D:FoodDecayRate=1.01703789660558695

# If a food item has not been ticked for >= this number of days than when it is ticked for the first time, only a small amount of decay will occur.
I:decayProtectionDays=24

# Set this to false if you want food to auto decay when a chunk is loaded instead of limiting decay when a chunk has been unloaded for a long period.
B:useDecayProtection=true

 

What is the global decay multiplier exactly? How does it effect different types of food, and play with the decay rate?

I don't quite understand the explanation of the decay rate. Causes to equal 50% gain per day. What does it multiply with to start the gain in the first place? Not 1

 

 

As a test. I tried to set up a rate to have the food generally reach 50% decay after 72 days. Which is 1728 MC hours. So I did x^1728=1.5   So X equals 1.000234672.   So 1.000234672^1728=1.5

But when I add 1728000 to time, it decays the food entirely. 

I have no idea what the rate is going up against...whats being multiplied by 1.000234672 every minecraft hour? How could I go about to set up a time frame to reach a general approximate amount of decay?

 

"Set this to false if you want food to auto decay when a chunk is loaded instead of limiting decay when a chunk has been unloaded for a long period."

Does decay act differently when a chunk is loaded or unloaded? Food seems to decay when chunks are loaded by default...I don't understand. 

 

 

0

Share this post


Link to post
Share on other sites

So, I played around with it a little and figured the math is not really correct.

First, lets get analytical equation for the decay rate : http://www.wolframalpha.com/input/?i=f%5Bt%5D+%3D+f%5Bt-1%5D%2Bf%5Bt-1%5D*r%3B+f%5B0%5D%3Dx

Then, if we want to have 1.5 amount of decay in 24 hours, we solve this: http://www.wolframalpha.com/input/?i=solve+x*1.5%3Dx*%28r%2F24%2B1%29%5E24+over+the+positive+reals

Which gets : 0.408909518534087 decay rate

0

Share this post


Link to post
Share on other sites

The way I understand it is that every hour, the amount of decay is multiplied by that rate, then new decay is added. Hopefully it's not the other way around, which would be worse as you'd be multiplying that new decay right when it was added. So in theory, over 24 hours you'd have 50% more decay than if you didn't have the compounding effect (imagine you removed the decayed amount every hour). That's why rate^24 = 1.5.

 

I'm not sure if it really works out that way or not, because the 1.5 number isn't accounting for the new decay being added every hour. I'll have to write a program to see what really happens.

 

Also, there's going to be a set amount of decay no matter what you do. So if decay is .1 oz per hour on average, after 1728 hours you'd get 172.8 oz of decay even if the rate was 1.0. Setting it to less than 1.0 will probably remove decay.

0

Share this post


Link to post
Share on other sites

float d = (((decay * Global.FOOD_DECAY_RATE) / 24) * thisDecayRate * environmentalDecay * protMult)*TFCOptions.decayMultiplier;

 

It's very important to note that the 1.01703789660558695 value is multiplied only on the base decay BEFORE the environment is taken into account. 15C is our base temperature at which the multiplier is 1.0. Any temp above 15C causes a multiplier >1.0 and below 15C, the decay begins to slow due to the environment. 

 

Lets assume now that the food is squash which has a decay rate of 1.0.

 

Now lets assume that the temperature is exactly 15C.

 

To make it simple, we have 1oz of decay already on the squash.

 

(((1.0 * 1.01703789660558695) / 24) * 1.0 * 1.0 * protMult)*TFCOptions.decayMultiplier;

 

Now if this food is in a chunk with no food protection due to the chunk being unloaded for a long period of time:

 

(((1.0 * 1.01703789660558695) / 24) * 1.0 * 1.0 * 1.0)*TFCOptions.decayMultiplier;

 

And assuming that there is no artifical decay multiplier:

 

(((1.0 * 1.01703789660558695) / 24) * 1.0 * 1.0 * 1.0) * 1.0. = 0.04237657902523278958333333333333

 

This is how much decay is added on the very first tick. So the total decay becomes 1.04237657902523278958333333333333

 

On the next decay tick we do this again with the new total decay:

 

(((1.04237657902523278958333333333333 * 1.01703789660558695) / 24) * 1.0 * 1.0 * 1.0) * 1.0 = 0.04417235347511458918630703117016

 

Now the decay is 1.0865489325003473787696403645035

 

This now repeats every decay tick(once per hour or faster if the food has just been loaded from an unloaded chunk and needs to play catchup) do this equation 24 times and you'll see that the 1.0 decay that we started with has has become very very very close to 1.5. Only reason it is not exactly 1.5 would be loss of precision when using floats instead of doubles.

0

Share this post


Link to post
Share on other sites

Hmm so if there's no additional decay added every tick, why didn't the OPs change to make it 1.5 after 72 days work? With that setting he should have seen barely any decay after 72 days, right?

0

Share this post


Link to post
Share on other sites

do this equation 24 times and you'll see that the 1.0 decay that we started with has has become very very very close to 1.5. Only reason it is not exactly 1.5 would be loss of precision when using floats instead of doubles.

 

I end up with 2.71, not 1.5. I think there's something wrong with your equation where you're dividing by 24. I think you really just want to multiply it and remove the divide by 24 and not add the result (the result is the new decay). So this:

 

decay = ((decay * Global.FOOD_DECAY_RATE) * thisDecayRate * environmentalDecay * protMult)*TFCOptions.decayMultiplier;

 

Doing that equation 24 times I get 1.5, with initial decay value of 1. Example C++ code:

#include <cstdio>int main(int argc, char* argv[]){        float decay = 1;        float rate = 1.01703789660558695;        printf("Initial decay: %.10fn", decay);        int ii;        for(ii=1; ii<=24; ++ii)        {                decay = decay * rate;                printf("Decay after %d hours = %.10fn", ii, decay);        }        printf("Final decay: %.10fn", decay);        return 0;}
0

Share this post


Link to post
Share on other sites

... and I see you already fixed it 20 minutes ago. Nevermind :D

0

Share this post


Link to post
Share on other sites

The 50% ratio means that after 24 hours, the food will have 50% more decay than before. So if food has 1% decay, then after day, it will have 1.5% decay. Also, to add, food with 0% decay will gain 0-0.5% random decay.

So, if you want "food reaches 50% after 72 day", you need to calculate it like this : http://www.wolframalpha.com/input/?i=solve+50+%3D+0.25*r%5E1728+for+positive+real

0

Share this post


Link to post
Share on other sites

Bioxx could you please explain and show us like were five, what other things go into account when multiplying by the decay rate. I do know that the environment, chunk loading, and temperature have an effect. As example, I didn't know the multiplier changed with the temperature. 

 

   There are many things that are being calculated by the decay rate that are being left out that I don't understand. I'm assuming the decay starts out at 0, so what starts the fire? When I go in creative and take out 5 apples, and add 10 days, It results in different decay in all the apples. When the total decay becomes larger, it reacts more to the decay rate. Lets say one apple has 5% decay, and another has .5%. I will add 1 day, and the first will have about 7-8% (about 50% more by default), and the second might have 1.5% (thats more the 50% more by default) or .6% decay. If an item has a full 50% decay, and a day goes by, your more likely to see 75% total decay at the end of the day. That was my observation yesterday, but I need to look at it again. Funky stuff

 

A decay rate of 1.000234672 will give me 50% decay after 72 days if the multiplier remains 1, and all else is left out...how would you go about in approximating the values to reach the goal of 50% decay after 72 days? 

 

Better yet could someone just show us whats going on in the code with the decay...

0

Share this post


Link to post
Share on other sites

float d = (((decay * Global.FOOD_DECAY_RATE) / 24) * thisDecayRate * environmentalDecay * protMult)*TFCOptions.decayMultiplier;

 

 

Hmm. I like the idea that food decays, but the exponential aspect makes me feel obligated to cut the decay away once per day, which feels like a chore (and I don't want to do chores in a game).

 

I was thinking I'd try to make food decay linear (as much as the random aspect will allow) -- that way I'd still have a reason to go out and find food, but I wouldn't have a reason to do the chore (the food's going to decay at the same rate whether I do or don't).

 

But if this is the equation, I don't see an obvious way to ensure linear decay. Even if I set FoodDecayRate and FoodDecayMultiplier to 1.0, the individual food type and environmental decay rate multipliers can still make it exponential (or possibly remove decay in cold temperatures?).

 

Am I missing something?

0

Share this post


Link to post
Share on other sites