Sundew Farms Research Division Presents: Animal Mechanics

Discussion in 'General Discussion' started by SunTide, Oct 26, 2016.

  1. SunTide

    SunTide Scruffy Nerf-Herder

    IMPORTANT EDIT: StarPeanut (aka The Hero) did some code diving and discovered a bug that was destroying the intended correlation between animal mood and product quality. The data presented here suggest that there is no relationship between the two, when in fact, the intended result is that there is a strong correlation. However, there is a bug that wrecks this. Discussion of this bug, and how to work around it can be found later in this thread.

    As of this writing, SDV is in version 1.11. I am hopeful that this bug will be patched out in future versions. I will update this header if the bug is resolved.

    In my main thread, I've been doing a detailed playthrough that tries to be grounded in game mechanics. I've gotten to the point where I need to start working with animals, and quickly discovered that no one knows anything about that.

    The amount of speculation presented as fact out there on the internet is staggering. Lots and lots of arcane sounding rules about what affects what, with no evidence or data to back anything up. People use reasoning like "I left the barn door open once, and my goat gave me a small milk, so open doors means no large milk."

    This is my attempt to make actual measurements and try to understand how the mechanics work. To my knowledge, this post will be the only place in the entire internet where any real data has been presented. If you know of anyone who has done any code-diving or empirical testing, I'm interested.

    Some ground rules: If you have any actual data, I am interested. If you have anecdotes, I am not. The signal to noise on this subject is terrible, and talking about how you did complicated action x and got result y only creates work for everyone else, unless you have solid data showing a clear pattern (and no, "I did it three times and it seemed to work" doesn't count).

    I am assuming that Concerned Ape is a clinically sane man trying to create a game that could be enjoyed and understood. I expect that if two things are intended to be related, then the effect will be strong enough to be noticeable. If an effect is so weak that you would have to do thousands of trials and carefully record your data to see it, then it probably isn't real, because why would CA code something like that?

    The tldr summary: Animal mood is essentially random, and has no clear correlation with either animal love or product quality. It is mostly only useful when it reports a specific problem (e.g. "Bessie was not fed yesterday"). There appears to be no mechanical difference between "fine" and "really happy" and I suspect that these are just there for flavor.

    Animal love is correlated with product quality. The effect is strong enough to measure, with zero-heart animals giving close to zero percent large products and 5-heart animals clocking in at around 30%.

    I tested three scenarios, one where I went to bed right after tending my animals and not waiting for them to go inside, another where I waited but left the door open, and a third where I closed the door behind them. I found no correlation between any of these behaviors and animal mood/love/products. In fact, the most work intensive behavior (closing the door behind them) actually had a negative correlation with product quality, which I write off as random noise.

    Measurements were only made on cows, but as a first order assumption, I am assuming that CA did not write parallel but unique mechanics for each animal. At most, I would expect different drop rates, but not actual changes to the game rules. If you have data that contradicts this, I am interested. Remember, anecdotes are not data.

    Mechanics
    Love
    Each heart takes 200 points to fill. Here are some things that affect points:
    Petting +5
    Milking +5
    Eating grass +8
    Eating Hay +10
    Left outside -10
    Not Fed -10
    No heat in winter -10

    The negative effects aren't cumulative. You lose ten points, regardless if all three bad effects are present or only one. Animals are only "left outside" if they can't get to the barn before they fall asleep. Going to bed before they reach the door does not cause them to be counted as being trapped. I don't know what happens if an animal is physically blocked from getting in but you go to bed before they fall asleep. I didn't bother testing this because that's just not something that comes up during natural play.

    Mood The game uses an internal index number for mood, which is translated into text when the player checks the animal. Some text corresponds to more than one index number. My list so far:

    2: sad (rare, not sure what causes this)
    13: fine
    23: not fed
    24: left outside
    31: really happy
    49: fine (only happens on rain days, and even then, only rarely. No obvious difference from 13)
    100: really happy (all animals have this by default until the player interacts with them, and then the "real" mood is selected. On very rare occasions, this number ends up being selected as the real mood. No obvious effect)


    Data
    Here is the case where I went to bed immediately after tending my animals. I tracked the behavior of two separate cows, one with zero hearts and one with 5. I had to periodically use a save game editor to re-zero the first cow. I didn't do this every day, so the zero-heart cow is probably scoring slightly better than it should.

    [​IMG]

    The correlation between love and product size is probably real. Mood is all over the place and has no obvious connection to product quality. Love doesn't seem to affect mood either.

    Here is when I waited for the animals to go inside, but left the door open

    [​IMG]

    There is no obvious change. The effect between love and quality is still present, so that's probably real.

    Here is where I closed the door behind them. I did not bother tracking the zero-heart cow, because at this point I was convinced that the love-product relationship is real, and maintaining the zero-heart cow was more than doubling my work.

    [​IMG]

    The weakest performance yet, which I attribute to random noise rather than actual code.

    None of these data are strong enough to draw rigorously scientific conclusions, but they are plenty strong enough for my own casual play. I'm going to stop caring about animal mood (except for when it indicates a specific problem) and I'm certainly not going to bother with manipulating the doors.
     
      Last edited: Oct 26, 2016
      robogena likes this.
    • nevyn21

      nevyn21 Cosmic Narwhal

      Are you sure that eating hay is better than eating grass? It's supposed to be the other way around, with grazing giving better mood. I've also noticed that moving a barn full of animals seems to negatively affect their mood the following day. Anyway, thanks for exploring this. :)
       
      • Shiverwarp

        Shiverwarp Starship Captain

        It's sort of baffling to me that eating grass (+8) is worth less than eating hay (+10), when it definitely requires more work and more footprint on the farm (creating an area with grass fenced in next to the animals). Especially more work when you have the auto-feeder.
         
        • SunTide

          SunTide Scruffy Nerf-Herder

          I checked it twice. I was surprised too.

          EDIT: In fact, having two people ask about this spooked me enough that I checked again RIGHT NOW, and yes, grass gives +8.
           
            nevyn21 likes this.
          • nevyn21

            nevyn21 Cosmic Narwhal

            Huh. So it's better to keep grass for cutting than for grazing. Good to know, especially when you're crazy like I am and keep 60 sheep.
             
            • Shiverwarp

              Shiverwarp Starship Captain

              This definitely changes things a bit for how to take care of animals. Only reason to really let them outside is I guess pigs for truffles.
               
              • SunTide

                SunTide Scruffy Nerf-Herder

                I personally like letting them out, but I tend to use smaller numbers of animals. If your grass is able grow as fast as it is eaten, that's one less chore you have to do every day.

                I think that grazing also has clear superiority to hay during the time period before you get your autofeeder.

                I wouldn't worry about the extra +2 affection. For cows, we are talking about 25 days before reaching max hearts, vs 28 days. It's not like each heart makes a huge difference, either. For chickens, which can't be milked, the difference is 34 days vs 39. Still doesn't matter much.
                 
                • LuthienNightwolf

                  LuthienNightwolf Oxygen Tank

                  Yay, somebody else who likes largescale animal farming. lol I was up to 60 cows on my old save, would have gone all the way to 96 if I hadn't accidentally updated to 1.1 and broke my save (incompatible mods). >u<

                  In regards to the OP, this is interesting info, especially the part about eating grass being less favorable than eating hay, I certainly would not have expected that.
                   
                  • nevyn21

                    nevyn21 Cosmic Narwhal

                    I couldn't imagine keeping 96. Just how many silos did you have?

                    What's interesting about the findings is Grass Starter is 100g and Hay is only 50g bought from Marnie.
                     
                    • StarPeanut

                      StarPeanut 2.7182818284590...

                      Like you, I discovered recently that no one knew anything about animals. Unlike you, I decided to solve this by reading the code rather than by experimenting.

                      You've done a great job covering one of the two mechanics, which is friendship (hearts). Let me try to shine a light on the other one, which is happiness/mood.

                      tl;dr: Let your animals graze on grass and end your day as early as possible to maximize your animal products.

                      At the start of each game day (before you wake up), the game calculates which animal product each animal will produce. This is somewhat random, but is influenced by both the friendship and happiness. This is the ONLY time that happiness matters. Its value during the middle of the day is irrelevant. You want happiness to be high when the game rolls animal produce, but it's fine if it drops for the rest of the day.

                      Happiness is on a scale from 0 to 255. Being above 200 is extremely important, because the way happiness contributes to the animal products score is this:
                      • if happiness > 200, then score (2 * happiness) points
                      • else, score (-2 * happiness) points
                      So, if you have the max happiness of 255, then you add 2*255 = 510 points to the score, which is equivalent to having an extra 2.5 hearts of friendship. However, if you have a happiness of only 150 (this is a special value, as we'll see later), then you REMOVE 2*150 = 300 points from the score, which is like having 1.5 fewer friendship hearts. Understanding this mechanic was the single biggest thing I did to improve my animal drops.

                      Okay, so now we know what happiness is. What affects it? Contrary to your empirical evidence, it is NOT set randomly. Here are the events that change happiness during the day, for all seasons other than winter:
                      • Petting increases happiness.
                      • Eating grass sets happiness to maximum (255).
                      • Being outside in the rain or in the winter decreases happiness.
                      • Being outside past 19:00 decreases happiness.
                      • Being awake past 18:00 decreases happiness, to a minimum of 150.
                      Winter is a special case: in winter, a heater counteracts the happiness decay caused by being awake late, and actually turns it into a happiness increase instead. You need one heater per barn/coop; additional heaters do not have any extra positive effect.

                      The two most interesting ones here are that eating grass sets happiness to max, but eating hay has no effect on happiness; and animals gradually lose happiness over time the longer they're awake in the evenings.

                      At the start of the day, there are some checks that have a big effect on happiness. These occur before the game decides which animal products are produced, so they have an immediate effect. They can really throw off your happiness even if it was quite good when you went to bed. Here they are:
                      • Animal slept outside AND (barn/coop door is closed OR you went to bed after 18:00 and the animal wasn't in the middle of walking back home): cut happiness by half
                      • Animal was not pet: decrease happiness.
                      • Animal was fed: increase happiness slightly.
                      • Animal was not fed: decrease happiness by 100.
                      You may be asking yourself why I didn't specify exactly how many points each action increases/decreases happiness by. The reason is that this changes per animal. I can't be bothered digging the exact values out of the game data files, but each action has a small effect, on the order of 5 points of happiness each.

                      Due to what I presume are bugs in the code, happiness can "wrap around" from the highest positive value to the lowest negative value. That is, if you pet an animal that's already at max happiness (255), then its happiness will actually drop to almost zero.

                      So, where does this all leave us?
                      • If your animals are free to come and go from the barn/coop as they please (i.e., you keep the door open), their happiness will go up to max (255) and then stay there until 18:00, at which point it will gradually drop to 150 and stay there. If you stay up late, happiness will be at 150 at the start of the next day, and you'll take a 300 point penalty on the animal product rolls, equivalent to having 1.5 fewer hearts. If you go to bed at 18:00, happiness will still be at 255, and you'll earn a 510 point bonus on the animal product rolls, equivalent to having 2.5 extra hearts.
                      • If your animals are fed hay, their happiness will appear to be more random, as you'll only be making small changes to it each day. You'll probably stay below the magic happiness number of 200, so you'll generally have a penalty to your rolls rather than a bonus.
                      • In winter, make sure you have one heater in each barn/coop.
                      Empirically, after spending a week or so failing to get the large milk and large eggs I needed to open my greenhouse, I just went to bed right at 18:00 (on a day my animals were free to graze). The next morning I got all the drops I needed, and more. Of course, n=1 isn't a great experiment, but hey, it solved the problem I was facing.

                      Hope this helps!
                       
                        Last edited: Oct 26, 2016
                        robogena, nevyn21 and SunTide like this.
                      • LuthienNightwolf

                        LuthienNightwolf Oxygen Tank

                        I had four, but I had a LOT of farm space to grow grass on so at the end of Fall I'd fill them up, empty them into a chest, and then fill them up again. Rinse, repeat until all my grass was cut down. I use Timespeed which helps with the time involved to milk them all every morning, and I had an expansion mod where I kept them so I wasn't really cutting into my gardening space. I'm on a brand new save now and I've only got four chickens so far, I miss all the cows. lol
                         
                          nevyn21 likes this.
                        • nevyn21

                          nevyn21 Cosmic Narwhal

                          I never thought to empty them into chest and fill them again. Thanks for the tip. :) I wonder how long it'll take me to fill 7 twice.

                          Also: I don't care how happy it makes my animals, I'm not going to bed at 6:00pm.
                           
                            LuthienNightwolf likes this.
                          • SunTide

                            SunTide Scruffy Nerf-Herder

                            StarPeanut, that is extremely helpful, and explains some oddities. I would have read the code myself, if I knew how.

                            The thing is, in my test cases, I was going to bed well before 8:00 PM, and my animals were eating grass on every non-rain day. So this was the optimal possible case, and the drop rates were still pretty weak. Which, I have to admit, is pretty disappointing.

                            Is there any correlation between the displayed mood and this happiness number that you are seeing? Because my "happy" cow should have been in the best possible mood almost every time (early bed + grass +being pet + five base hearts), but anything other than "fine" was quite rare.

                            FAKE EDIT: Oh wait, that's probably the wrap around bug you mentioned. I'd like to see a mod to fix that. That's extremely annoying.

                            REAL EDIT: Digesting this a bit, this means that you need to pet your animals either before they eat their hay or sometime after 8:00 PM or you actually set your happiness to zero. Ugh! This might be the origin of the myth that closing your doors increases mood. It kind of does, if your animals are grazing AND you don't make petting them your number one chore for the day.

                            MOAR EDIT: This explains why all my animals showed 100% happiness until I interacted with them. The 100% happinesss (probably corresponds to 255 internal happiness points) was real. They had just eaten their hay and were happy as could be. But then I petted them, which caused a wrap around bug, setting it to the 13% that I commonly saw. Ugh!

                            Seriously, we need a mod for this.
                             
                              Last edited: Oct 26, 2016
                            • Elysiia

                              Elysiia Aquatic Astronaut

                              This is so wrong.

                              It definitely warrants an animal protection label that uses a 1 to three star system that denotes produce that comes from animals that have the best living conditions (we have this in my country); i.e. that get to go outside, have a relatively normal growth and life span and are tended to with human care (I would add without antibiotics, too, expect the game doesn't have them). Obviously, in such a system, higher star produce should yield more! Keeping animals inside and hay-fed makes me sad...

                              StarPeanut, that you so much for elaborating on the code underlying animal mechanics. You have just restored my faith in the Stardew Valley universe's stance on sustainable animal farming :p
                              That wrap-around bug sounds annoying though... wish someone knew how to fix it, somehow.
                               
                              • StarPeanut

                                StarPeanut 2.7182818284590...

                                Yes, that's exactly right. Petting an animal that is at max happiness will drop their happiness to almost zero. My daily routine is to pet all the animals before letting them out to graze for the day, so I hadn't even thought about the case where you pet them after they eat!

                                Note that eating hay does not increase happiness. Only eating grass does that. I presume that was just a typo in your last post, since you had previously mentioned that during your tests they were eating grass. :)

                                EDIT: That said, there's nothing wrong with petting an animal first thing in the morning that's already 100% happy and dropping their happiness to 13%, as long as you're going to let them outside to graze later that day. Once they eat their daily grass they'll jump right back to 100% happiness and stay there until 18:00, barring any other tragedies. (And note that 18:00 = 6 pm, if you're using a 12-hour clock.)
                                 
                                • SunTide

                                  SunTide Scruffy Nerf-Herder

                                  Confirming, I just tried letting my cows eat grass and then NOT petting them, and I got a 100% drop rate on large products, over 12 trials. Milking doesn't cause the wrap around bug (presumably because it only affects friendship, not happiness), so you can do this every day.

                                  This is a significant bug. It seriously impacts the viability of animals and creates a totally counter intuitive situation where petting your animals makes them desperately unhappy. Could someone that knows how direct CA to this thread? This really needs to be patched.
                                   
                                    ChaosAzeroth and nevyn21 like this.
                                  • nevyn21

                                    nevyn21 Cosmic Narwhal

                                    Probably best to file a bug report on it in the bug forum.
                                     
                                    • SunTide

                                      SunTide Scruffy Nerf-Herder

                                      No I took measurements, and I saw a +10 increase in friendship on days that they ate hay. I guess it's possible that there is a +10 bonus for being locked in the barn all day, but that seems kind of odd.

                                      What I don't like about this is that it creates an extra task where you have to open/close your doors every day. I'd rather just be able to leave the doors open and let the animals mostly take care of themselves.
                                       
                                      • SunTide

                                        SunTide Scruffy Nerf-Herder

                                        Submitted a bug report, but my understanding is that CA doesn't really check these forums and prefers the Reddit. Maybe he checks here more often because of the recent update?

                                        Anyone want to make a mod for this?
                                         
                                        • StarPeanut

                                          StarPeanut 2.7182818284590...

                                          Friendship (hearts), yes; happiness, no. This is why grazing on grass is superior to eating hay: both will keep your animals fed, and both will improve your friendship (hearts) with them (and, in fact, hay is slightly better for this, as you pointed out), but only grass will set their happiness to max. Eating hay has no effect on happiness.
                                           

                                          Share This Page