Jump to content

Math challenge: Deerclops First Tree Farm.


Recommended Posts

It turns out determining the optimal time to plant a tree farm is a bit trickier than I thought. 

My goal: calculate the optimal moment to plant an evergreen tree farm in the early game so that Deerclops can harvest the absolute maximum number of logs possible when he arrives at midnight on day 30.

Theoretically, a tree can grow to the 'aged' state in a mere 4.2 days, but can take as long as 6.2 days to grow to large. We want to minimize the number of aged tree's, but we also don't want to harvest until most of the medium trees are fully grown. An aged tree costs us three logs, while a medium tree only costs us one, so we should lean towards having more mediums. 

Adding to the difficulty, the distribution curve isn't even. The growth state of an evergreen is a sum of four different probabilities: time taken to grow as sapling, small, medium and large. And, for bonus points: sapling and small take a lot less time to grow than medium and large.

My work so far:

VWCnt60.png

My information on evergreen growth stages is taken from the wiki: 

Quote

Evergreens have a 4-stage life cycle (small, medium, large, and aged) which they continuously cycle through. The time for each stage to grow to the next one is, respectively, 0.625-1.25 days (5-10 min), 1.875-4.375 days (15-35 min), 1.875-4.375 days (15-35 min) and 0.3125-0.9375 days (2.5-7.5 min).

...

Planting a Pine Cone will produce a sapling tree which will grow into a small Evergreen in 0.3125-0.625 (2.5-5 min) day and follow the life cycle until it is chopped down or burned. 

(Edit) In hindsight, it would have been easier to do the math in real-time minutes and convert back once done.

Link to comment
Share on other sites

Okay, so, turns out I'm too lazy to do math. In hindsight, urgh math. What was I thinking?

 

Yeah, that was a dumb idea. So instead, here's a C# console application that simulates the result of harvesting 10 million tree's at each minute of their growth cycle.

Spoiler

 


            int numberOfTreesInFarm = 10000000;

            float saplingMinTimeToGrow = 2.5f;
            float saplingMaxTimeToGrow = 5f;
            float smallMinTimeToGrow = 5f;
            float smallMaxTimeToGrow = 10f;
            float medMinTimeToGrow = 15f;
            float medMaxTimeToGrow = 35f;
            float largeMinTimeToGrow = 15f;
            float largeMaxTimeToGrow = 35f;

            for (int age = 0;  age < 75; age++)
            {
                int logs = 0;
                int pinecones = 0;

                for (int treeCount = 0; treeCount < numberOfTreesInFarm; treeCount++)
                {
                    float saplingTimeToGrow = RandomValueBetween(saplingMinTimeToGrow, saplingMaxTimeToGrow);
                    float smallTimeToGrow = RandomValueBetween(smallMinTimeToGrow, smallMaxTimeToGrow);
                    float medTimeToGrow = RandomValueBetween(medMinTimeToGrow, medMaxTimeToGrow);
                    float largeTimeToGrow = RandomValueBetween(largeMinTimeToGrow, largeMaxTimeToGrow);

                    float growToSmall = saplingTimeToGrow;
                    float growToMed = saplingTimeToGrow + smallTimeToGrow;
                    float growToLarge = saplingTimeToGrow + smallTimeToGrow + medTimeToGrow;
                    float growToAged = saplingTimeToGrow + smallTimeToGrow + medTimeToGrow + largeTimeToGrow;


                    if (age < growToSmall)
                    {
                        //No logs, no cones
                    }
                    else if (age < growToMed)
                    {
                        //Small size
                        logs += 1;
                    }
                    else if (age < growToLarge)
                    {
                        //Med Size
                        logs += 2;
                        pinecones += 1;
                    }
                    else if (age < growToAged)
                    {
                        //Large Size
                        logs += 3;
                        pinecones += 2;
                    }
                    else
                    {
                        //Aged
                        pinecones += 1;
                    }
                }
                Console.WriteLine("Tree farm harvested at " + age + " minutes. | Logs: " + logs + ", Pinecones: " + pinecones);
            }
            Console.ReadKey();
        }


        static Random r = new Random();
        public static float RandomValueBetween(float min, float max)
        {
            return (float)(r.NextDouble() * (max - min)) + min;
        }

 

 

 

Yeah, who needs probability math when you can just brute force a problem? Here are the results:

Spoiler

 Tree farm harvested at 0 minutes. | Logs: 0, Pinecones: 0
Tree farm harvested at 1 minutes. | Logs: 0, Pinecones: 0
Tree farm harvested at 2 minutes. | Logs: 0, Pinecones: 0
Tree farm harvested at 3 minutes. | Logs: 1999571, Pinecones: 0
Tree farm harvested at 4 minutes. | Logs: 5997793, Pinecones: 0
Tree farm harvested at 5 minutes. | Logs: 10000000, Pinecones: 0
Tree farm harvested at 6 minutes. | Logs: 10000000, Pinecones: 0
Tree farm harvested at 7 minutes. | Logs: 10000000, Pinecones: 0
Tree farm harvested at 8 minutes. | Logs: 10099998, Pinecones: 99998
Tree farm harvested at 9 minutes. | Logs: 10899134, Pinecones: 899134
Tree farm harvested at 10 minutes. | Logs: 12499979, Pinecones: 2499979
Tree farm harvested at 11 minutes. | Logs: 14499525, Pinecones: 4499525
Tree farm harvested at 12 minutes. | Logs: 16498303, Pinecones: 6498303
Tree farm harvested at 13 minutes. | Logs: 18401943, Pinecones: 8401943
Tree farm harvested at 14 minutes. | Logs: 19599118, Pinecones: 9599118
Tree farm harvested at 15 minutes. | Logs: 20000000, Pinecones: 10000000
Tree farm harvested at 16 minutes. | Logs: 20000000, Pinecones: 10000000
Tree farm harvested at 17 minutes. | Logs: 20000000, Pinecones: 10000000
Tree farm harvested at 18 minutes. | Logs: 20000000, Pinecones: 10000000
Tree farm harvested at 19 minutes. | Logs: 20000000, Pinecones: 10000000
Tree farm harvested at 20 minutes. | Logs: 20000000, Pinecones: 10000000
Tree farm harvested at 21 minutes. | Logs: 20000000, Pinecones: 10000000
Tree farm harvested at 22 minutes. | Logs: 20000000, Pinecones: 10000000
Tree farm harvested at 23 minutes. | Logs: 20000883, Pinecones: 10000883
Tree farm harvested at 24 minutes. | Logs: 20022517, Pinecones: 10022517
Tree farm harvested at 25 minutes. | Logs: 20104643, Pinecones: 10104643
Tree farm harvested at 26 minutes. | Logs: 20278778, Pinecones: 10278778
Tree farm harvested at 27 minutes. | Logs: 20553762, Pinecones: 10553762
Tree farm harvested at 28 minutes. | Logs: 20930004, Pinecones: 10930004
Tree farm harvested at 29 minutes. | Logs: 21383314, Pinecones: 11383314
Tree farm harvested at 30 minutes. | Logs: 21873628, Pinecones: 11873628
Tree farm harvested at 31 minutes. | Logs: 22376223, Pinecones: 12376223
Tree farm harvested at 32 minutes. | Logs: 22874853, Pinecones: 12874853
Tree farm harvested at 33 minutes. | Logs: 23375634, Pinecones: 13375634
Tree farm harvested at 34 minutes. | Logs: 23875063, Pinecones: 13875063
Tree farm harvested at 35 minutes. | Logs: 24375604, Pinecones: 14375604
Tree farm harvested at 36 minutes. | Logs: 24873959, Pinecones: 14873959
Tree farm harvested at 37 minutes. | Logs: 25373976, Pinecones: 15373976
Tree farm harvested at 38 minutes. | Logs: 25875755, Pinecones: 15875767
Tree farm harvested at 39 minutes. | Logs: 26373385, Pinecones: 16374319
Tree farm harvested at 40 minutes. | Logs: 26865369, Pinecones: 16871825
Tree farm harvested at 41 minutes. | Logs: 27336043, Pinecones: 17361221
Tree farm harvested at 42 minutes. | Logs: 27777684, Pinecones: 17843322
Tree farm harvested at 43 minutes. | Logs: 28164643, Pinecones: 18303773
Tree farm harvested at 44 minutes. | Logs: 28470948, Pinecones: 18724808
Tree farm harvested at 45 minutes. | Logs: 28645242, Pinecones: 19063486
Tree farm harvested at 46 minutes. | Logs: 28654063, Pinecones: 19281619
Tree farm harvested at 47 minutes. | Logs: 28483925, Pinecones: 19374721
Tree farm harvested at 48 minutes. | Logs: 28141731, Pinecones: 19344885
Tree farm harvested at 49 minutes. | Logs: 27641691, Pinecones: 19209405
Tree farm harvested at 50 minutes. | Logs: 27029250, Pinecones: 19009750
Tree farm harvested at 51 minutes. | Logs: 26333529, Pinecones: 18777843
Tree farm harvested at 52 minutes. | Logs: 25573317, Pinecones: 18524439
Tree farm harvested at 53 minutes. | Logs: 24725772, Pinecones: 18241924
Tree farm harvested at 54 minutes. | Logs: 23804106, Pinecones: 17934702
Tree farm harvested at 55 minutes. | Logs: 22806642, Pinecones: 17602214
Tree farm harvested at 56 minutes. | Logs: 21742536, Pinecones: 17247512
Tree farm harvested at 57 minutes. | Logs: 20600799, Pinecones: 16866933
Tree farm harvested at 58 minutes. | Logs: 19379844, Pinecones: 16459948
Tree farm harvested at 59 minutes. | Logs: 18086958, Pinecones: 16028986
Tree farm harvested at 60 minutes. | Logs: 16738737, Pinecones: 15579579
Tree farm harvested at 61 minutes. | Logs: 15349425, Pinecones: 15116475
Tree farm harvested at 62 minutes. | Logs: 13952664, Pinecones: 14650888
Tree farm harvested at 63 minutes. | Logs: 12569865, Pinecones: 14189955
Tree farm harvested at 64 minutes. | Logs: 11258613, Pinecones: 13752871
Tree farm harvested at 65 minutes. | Logs: 10005498, Pinecones: 13335166
Tree farm harvested at 66 minutes. | Logs: 8810241, Pinecones: 12936747
Tree farm harvested at 67 minutes. | Logs: 7708110, Pinecones: 12569370
Tree farm harvested at 68 minutes. | Logs: 6684459, Pinecones: 12228153
Tree farm harvested at 69 minutes. | Logs: 5724852, Pinecones: 11908284
Tree farm harvested at 70 minutes. | Logs: 4843272, Pinecones: 11614424
Tree farm harvested at 71 minutes. | Logs: 4033566, Pinecones: 11344522
Tree farm harvested at 72 minutes. | Logs: 3310212, Pinecones: 11103404
Tree farm harvested at 73 minutes. | Logs: 2643885, Pinecones: 10881295
Tree farm harvested at 74 minutes. | Logs: 2067537, Pinecones: 10689179

 

As you can see, the optimal time to harvest is 45-46 minutes after planting. Given that a day in Don't Starve is 8 minutes long, that's 5.625 - 5.75 days after planting.

Which means the optimal time to plant evergreens is during the morning on day 25.

Thank goodness that vitally important question has now been answered.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...