Ludeon Forums

RimWorld => General Discussion => Topic started by: Alenerel on October 14, 2016, 11:47:05 AM

Title: Crop calculator ?
Post by: Alenerel on October 14, 2016, 11:47:05 AM
I was wondering if this exist... If it doesnt and someone wants to do it that would be nice...

It should include things like taking in account the temperature, how many colonists, calculate in hydroponics too, calculate hay for animals (they require different nutrition) and would be very nice if you could include handicaps like taking in account how many days of winter there are and be able to choose more handicaps like cold snaps, eclipses, etc. And with all of that tell the number of growing squares that you need of a crop.
Note: when I handicap I mean growing more than necessary for when you cant grow, idk if thats the word.

BTW a question. How can I calculate how much food an animal needs? Is it the hunger rate? If the wiki says hunger rate from chicken is 0.25, does that mean 0.25 nutrition a day needed to be fed?
Title: Re: Crop calculator ?
Post by: Zhentar on October 14, 2016, 12:23:11 PM
Hunger rate is times 1.6 nutrition per day, so a chicken needs 0.4 nutrition per day.
Title: Re: Crop calculator ?
Post by: Alenerel on October 14, 2016, 01:38:11 PM
Thanks. Where did you get that info?
Title: Re: Crop calculator ?
Post by: Zhentar on October 14, 2016, 05:30:59 PM
Decompiling the game code
Title: Re: Crop calculator ?
Post by: Alenerel on October 14, 2016, 05:53:13 PM
Its just that... 1.6 seems a weird number, why isnt it directly the hunger rate? Or why isnt the 0.4 directly at the wiki?
Title: Re: Crop calculator ?
Post by: Zhentar on October 14, 2016, 06:11:12 PM
I don't really know why things are the way they are... but I can speculate. The wiki uses the hunger rate pulled from the XML defs, presumably because that's easy and avoids potential misinformation if some numbers are pulled straight from the XML and others were converted to nutrition (and it may well mention the 1.6 somewhere). For the 1.6, that's balanced around colonists having a hunger rate of 1; I would guess initially the 1.6 was a round number but got adjusted somewhere along the line as Tynan tweaked game balance and adjusted day lengths (and editing the constant in the game code lets him just change one place without needing to update every animal, or affecting mod balance).
Title: Re: Crop calculator ?
Post by: O Negative on October 14, 2016, 06:53:46 PM
Quote from: Alenerel on October 14, 2016, 11:47:05 AM
I was wondering if this exist... If it doesnt and someone wants to do it that would be nice...

It should include things like taking in account the temperature, how many colonists, calculate in hydroponics too, calculate hay for animals (they require different nutrition) and would be very nice if you could include handicaps like taking in account how many days of winter there are and be able to choose more handicaps like cold snaps, eclipses, etc. And with all of that tell the number of growing squares that you need of a crop.
Note: when I handicap I mean growing more than necessary for when you cant grow, idk if thats the word.

BTW a question. How can I calculate how much food an animal needs? Is it the hunger rate? If the wiki says hunger rate from chicken is 0.25, does that mean 0.25 nutrition a day needed to be fed?

There's a pretty decent equation given on the plants wiki (http://rimworldwiki.com/wiki/Plants). Although, I admit, I should probably go in there and account for the instant 5% growth plants receive once planted. Regardless, it works perfectly fine for greenhouses and hydroponic rooms, where temperature and light are more controlled than the harsh outdoors. It's a bit tricky to account for temperature extremes (summer;winter) and the average light/day, for outdoor growth, since the algorithms used to calculate those things are based on your latitude and day-of-year. It delves into more calculus than simple algebra, because these things follow a sort of sin() or cos() curve [with values capped at 100%]. Finding the average areas under those curves can be tedious, and even redundant, because you kind of have to have an idea of how many days it's going to take ahead of time to do these calculations correctly. It becomes more of a guess-and-check than a perfect calculator.

And then, there's handicaps, like you were saying... As far as handicaps/events go, that's even more random than the temperature/light variations. You kinda just need to plan for the worst. I'm sorry the answer isn't better than that :(

There's an equation in the .dll for hunger rates, but I don't really have time to put it in simple terms right now. I've got to go to work soon...
Title: Re: Crop calculator ?
Post by: Alenerel on October 18, 2016, 05:10:19 PM
Quote from: Zhentar on October 14, 2016, 06:11:12 PM
I don't really know why things are the way they are... but I can speculate. The wiki uses the hunger rate pulled from the XML defs, presumably because that's easy and avoids potential misinformation if some numbers are pulled straight from the XML and others were converted to nutrition (and it may well mention the 1.6 somewhere). For the 1.6, that's balanced around colonists having a hunger rate of 1; I would guess initially the 1.6 was a round number but got adjusted somewhere along the line as Tynan tweaked game balance and adjusted day lengths (and editing the constant in the game code lets him just change one place without needing to update every animal, or affecting mod balance).

So then a colonist needs 1 nutrition a day to be full?

Im going to make that damn calculator cause Im tired of not know how much I have to plant.
Title: Re: Crop calculator ?
Post by: Alenerel on October 18, 2016, 06:26:38 PM
Well, Im working on it but I notice that i get different results than the wiki (http://rimworldwiki.com/wiki/Plants#Food_Plants) on this page.

To support one colonist, the wiki says:
Corn 10
Potato 11
Rice 12
Strawberry 13

I get:
Corn 7.7
Potato 16.55
Rice 13.07
Strawberry 14.17

I used the formulas supposing that all growth factors are 1 (normal temp, normal soil, normal light). Also the wiki says that corn grows in 10.52 days but I get 12.44 in excel. So Im confused now, am I wrong or is the wiki wrong?

I attach what I have done, its pretty ugly cause I like to make it pretty when I finished the math.
Title: Re: Crop calculator ?
Post by: Alenerel on October 18, 2016, 07:29:37 PM
I polished it a bit more and added haygrass for animals (medium size, small ones eat half, big ones eat double, approximately). The green cells are the ones that should be modified to change the conditions. Blue are the results, squares of soil per colonist. I added a compensation factor (over production) for those unpredictable things.

Note that in optimal conditions with 45 days of growing a year its just the double than the ideal value but if there are more or less than 45 days it changes.

Please tell me if you see a mistake somewhere.
Title: Re: Crop calculator ?
Post by: Zhentar on October 18, 2016, 08:59:31 PM
Quote from: Alenerel on October 18, 2016, 05:10:19 PM
Quote from: Zhentar on October 14, 2016, 06:11:12 PM
I don't really know why things are the way they are... but I can speculate. The wiki uses the hunger rate pulled from the XML defs, presumably because that's easy and avoids potential misinformation if some numbers are pulled straight from the XML and others were converted to nutrition (and it may well mention the 1.6 somewhere). For the 1.6, that's balanced around colonists having a hunger rate of 1; I would guess initially the 1.6 was a round number but got adjusted somewhere along the line as Tynan tweaked game balance and adjusted day lengths (and editing the constant in the game code lets him just change one place without needing to update every animal, or affecting mod balance).

So then a colonist needs 1 nutrition a day to be full?

Im going to make that damn calculator cause Im tired of not know how much I have to plant.

No, a human needs 1.6 nutrition a day.
Title: Re: Crop calculator ?
Post by: Alenerel on October 18, 2016, 09:13:35 PM
Quote from: Zhentar on October 18, 2016, 08:59:31 PMNo, a human needs 1.6 nutrition a day.

Well then, now I get even bigger values... 21 squares of rice per pawn sounds ok or is totally off? And this is counting that they are processed in simple meals, cause if they arent it would be 36.

I get:
Corn 13
Potato 27
Rice 21

The formula is 1.6*GrowthDays / ( MinYield*0.05*1.7 )

= How much I need per colonist in the time the plant grows / the nutrition of the harvest

Where 1.7 comes from processing simple meals: 0.5 to 0.85
GrowthDays = GrowthTime / 0.55 (from wiki when all factors are 1)
Title: Re: Crop calculator ?
Post by: O Negative on October 19, 2016, 02:52:23 AM
Quote from: Alenerel on October 18, 2016, 06:26:38 PM
I used the formulas supposing that all growth factors are 1 (normal temp, normal soil, normal light). Also the wiki says that corn grows in 10.52 days but I get 12.44 in excel. So Im confused now, am I wrong or is the wiki wrong?

I attach what I have done, its pretty ugly cause I like to make it pretty when I finished the math.

I can only validate the equations up to Actual Growth Time. I still have to go in there and add that 0.95 coefficient :(

The wiki is still very flawed at the end of the page. I'm not sure how to change the values within those charts, because I don't really understand wiki code that well. I'd really like to get it fixed soon, but I don't have the time to learn how to do it. Maybe I'll get ahold of that Jimyoda guy, he seems to know what he's doing. Just gotta give him the values.

Hunger rate has its own calculation in the .dll, which I haven't looked at yet. When I get some time, I'll return to this forum (I have notifications turned on), and I'll attach a link to a google spreadsheet of my version of the calculator you're looking for. First, I need to make the calculator, though...

Edit: I've updated the wiki to include instantaneous plant growth when calculating how long the plant will actually take to grow. You'll find that the 5% difference is significant enough to account for.
Title: Re: Crop calculator ?
Post by: Jimyoda on October 19, 2016, 11:40:17 AM
Sure, let me know what needs to be changed on the wiki. I feel obliged to mention PieTau who reconstructed those completely broken tables on the Plants page.

Also, it'd be easy to create a new parameter on the wiki to calculate and display a pawn's nutritional need based on the formula, hunger rate * 1.6. However, I need to do some testing because there are two stats to consider:
hunger rate - the speed at which a pawn's food meter drops
food capacity - the total nutrition of a full food meter (hunger rate * 1.6)

I'll follow up on this thread when I can fire up the game and check it out.
Title: Re: Crop calculator ?
Post by: Zhentar on October 19, 2016, 02:54:18 PM
hungerRate * 1.6 per day is the rate the hunger meter falls. The size of the hunger meter is equal to body size.
Title: Re: Crop calculator ?
Post by: Jimyoda on October 19, 2016, 03:10:11 PM
Quote from: Zhentar on October 19, 2016, 02:54:18 PM
hungerRate * 1.6 per day is the rate the hunger meter falls. The size of the hunger meter is equal to body size.
Ah, ok. Thanks. Makes alot more sense to me now.
Title: Re: Crop calculator ?
Post by: Alenerel on October 19, 2016, 03:13:18 PM
Quote from: Zhentar on October 19, 2016, 02:54:18 PM
hungerRate * 1.6 per day is the rate the hunger meter falls. The size of the hunger meter is equal to body size.

You mean that all pawns dont eat the same? Or you were talking about the animals?
Title: Re: Crop calculator ?
Post by: Jimyoda on October 19, 2016, 03:25:53 PM
Quote from: Alenerel on October 19, 2016, 03:13:18 PM
Quote from: Zhentar on October 19, 2016, 02:54:18 PM
hungerRate * 1.6 per day is the rate the hunger meter falls. The size of the hunger meter is equal to body size.

You mean that all pawns dont eat the same? Or you were talking about the animals?
Must be referring to animals. All humans all have body size of 1.0 so they'd all have the same base stats for hunger rate and food meter. As a side note, icons for pawns have different body types/sizes but that's just cosmetic.
Title: Re: Crop calculator ?
Post by: O Negative on October 19, 2016, 05:11:45 PM
I feel like we're failing to explain where we're getting 1.6 from.

FoodFallPerTick = 2.667e-5*HungerRate under normal "fed" circumstances; hungerRate is 1 for humans.
Therefor, FoodFallPerDay = (60,000ticks/day)*(2.667e-5food/tick)*1
FoodFallPerDay = 1.6 food/day




Food() = Nutrition()*Yield() or Nutrition()*Amount()
For example, a simple meal offers 0.85 nutrition and can only be eaten one at a time.
Food(SimpleMeal) = Nutrition(SimpleMeal)*Amount(SimpleMeal) = 0.85*1 = 0.85

Also,

Simple Meals Needed Per Day Per Person = FoodFallPerDay/Food(SimpleMeal) = 1.6/0.85 = 1.88
Or, just round that up to 2 Simple Meals per day for each colonist you have :)
The same method can be used for raw food, if you know the nutritional values of said raw food :D

-bleh-
Title: Re: Crop calculator ?
Post by: Alenerel on October 22, 2016, 01:03:29 AM
I think I finished this. I took in account 2 meals per day instead of 1.6 nutrition per pawn. I also included all fertilities.

The top table is the same as below but rounded up.

[attachment deleted by admin due to age]
Title: Re: Crop calculator ?
Post by: pconners on October 26, 2016, 09:38:48 PM
Nice work, I do admire people who take the time to do the maths properly.
Title: Re: Crop calculator ?
Post by: O Negative on October 26, 2016, 09:43:12 PM
It is very nice, indeed. Much better than the crud I threw together lmao
Title: Re: Crop calculator ?
Post by: Rock5 on October 27, 2016, 12:02:39 AM
If I understand correctly are you assuming 55% growing time in a day? That would assume sunlamps right? I think if you take into account how long the sun takes to get to full brightness the average growth might be a lot less.
Title: Re: Crop calculator ?
Post by: O Negative on October 27, 2016, 12:10:18 AM
Oh, it would be. The sun light curve is just really tricky to take into account.
Title: Re: Crop calculator ?
Post by: Zhentar on October 27, 2016, 12:14:21 AM
Particularly since it's latitude dependent
Title: Re: Crop calculator ?
Post by: Alenerel on October 29, 2016, 08:05:11 AM
I just used the wiki values. Personally I dont care much if i need 20 or 25 squares, just wanted to know approximately how many I needed, if 10 or 50.

In any case I just lay 20 squares per colonist of whatever, rice/corn, then add a couple more. Then since I like to have fine meals I end up hunting the same amount in meat, which means that I usually have the twice of the food required.

BTW rice is for fast food. Corn is for efficiency, you have to sow/harvest less. Potatoes are only better when the fertility is less than 100%. For example in 70% fert, potatoes are better than corn and rice.

The problem with going corn is that a blight is way more destructive to it since it has a long growing period (12 days) while you can get rice fast if it gets flighted in 5 days. I think that the best is to have a combination of two, maybe in mid/end game thinking in just having corn, but with some good backup storage.

Strawberries I think that are for ignoring the cooking, but you need to lay like 1.5 more than rice and corn.
Title: Re: Crop calculator ?
Post by: Rock5 on October 30, 2016, 01:49:49 AM
Quote from: O Negative on October 19, 2016, 05:11:45 PM
I feel like we're failing to explain where we're getting 1.6 from.

FoodFallPerTick = 2.667e-5*HungerRate under normal "fed" circumstances; hungerRate is 1 for humans.
Therefor, FoodFallPerDay = (60,000ticks/day)*(2.667e-5food/tick)*1
FoodFallPerDay = 1.6 food/day
Ah, ok...

Now we just need to know where we get 2.667e-5. :D
Title: Re: Crop calculator ?
Post by: O Negative on October 30, 2016, 06:51:29 AM
That really small number is the hard coded value of food fall per tick.

I probably should have mentioned that :P

I was being super annoying about it for no reason really. Maybe I was having a bad day, and just felt like being nitpicky haha