Completing all bundles in the least number of days

Discussion in 'General Discussion' started by MrWint, Feb 4, 2020.

  1. MrWint

    MrWint Space Hobo

    Obligatory spoiler warning: This post talks in-depth about the game's content and mechanics. It may spoil some content for you or uncover the "magic" of its mechanics in a way you can't unsee.

    TL;DR I don't want to read all this, just give me the end result: here

    The Goal

    Given that Stardew Valley's bundles require such a variety of different items, I was wondering how quickly it's possible to complete it. More specifically, I'm interested in the least number of days needed to complete all bundles. Progress in SDV is mostly gated on days passing, and the number of days is a nice metric to reason about and optimize for. This is notably quite different from optimizing for real time, where you would skip a lot of days to accumulate money and advance seasons quickly.
    What started out as an innocent question quickly spiraled out of control into an in-depth dissection of the game's inner workings and mechanics, with this lengthy post as the final result.

    Theoretical limits

    At first glance, it seems that since some required items like the Crocus are only found in Winter, you'd need at least until Winter 1. However, there is one other place where most items in the game can be found, and that is the Traveling Cart, allowing to collect the items way sooner.

    There are some items that cannot be bought from the Traveling Cart though, most notably all Quality Crops Bundle items, since all items bought at the Cart are always regular quality. That means the earliest this bundle can be completed is in Summer, after three of the necessary crops had a chance to grow.

    There's one more trick to speed up the process though, and that is the Crop Fairy event: Randomly each night a fairy may appear on your farm and instantly grow your crops. So if a fairy arrived on Summer 1, we could have the crops be fully grown by Summer 2.

    All other items are obtainable by then in principle, so it's theoretically possible to complete the Community Center by Summer 2, and therefore the Missing Bundle by Summer 4, if the stars align. But, is it possible for the stars to align in practice? It all depends on RNG.

    Stardew Valley's RNG

    Stardew Valley has lots of random events, like weather, loot of monsters, crop quality, shop stock, forage items, artifacts, the mines, fishing, etc. To determine their outcomes, it uses .NET's (the framework the game is written in) built-in pseudo-random number generator class. The interesting part is how it is set up: It is always initialized with a seed, which determine the sequence of generated numbers. That means using the same initial seed always results in the same random outcomes. What Stardew Valley uses as the seed depends on the event. They can be divided into two main categories: predictable RNG, and unpredicable RNG.

    In predictable RNG, the seed only depends on predictable values, which allows you to calculate which random outcomes you'll get ahead of time. The Traveling Cart's item stock falls into this category, as it is only dependent on the unique ID of your save file and the number of days played, so it can be predicted for all future days. If you want to check this out for yourself, I can recommend MouseyPounds' Stardew Predictor, which does this for lots of predictable RNG elements for your save file.
    Predictable RNG has the advantage of always giving you the same outcome, and therefore discouraging what is affectionately known as "save scumming": reloading the day again will not make your crop gold quality no matter how often you try. It also has a major disadvantage though: it it not possible to manipulate the outcomes other than with careful planning ahead. If there are no starting conditions that lead to all the outcomes you need, there's nothing you can do to change that.

    In unpredictable RNG, the seed is either independent of any in-game state (e.g. the mine layouts work this way), or uses the game's shared RNG (called Game1.random), which is only re-initialized at the start of each day, so any previous random event affects any later random event.
    While this sounds bad at first, it actually is quite useful for my purposes, given that it means it can be manipulated to produce any outcome I want. They continue to get updated even when the in-game clock is paused, allowing you to just wait for favorable outcomes without wasting any in-game time. That means you can always manipulate it to get the exact outcomes you want by just pausing for the right amount of time beforehand to let the RNG advance.

    Here's a list of relevant random events categorized this way:
    Predictable:
    • Crop quality (depends on: Game ID, date and position)
    • Digging Artifact Spots (depends on: Game ID, date and position)
    • Digging dirt outside the mines (depends on: Game ID, date, position, and number of tiles tilled)
    • Rock and tree contents (depends on: Game ID, date and position)
    • Traveling Cart/Krobus stock (depends on: Game ID and date)
    • Random overnight events (depends on: Game ID and date)
    • Trash Can contents (depends on: Game ID, date, daily luck, number of trash cans opened, reached mine level and Vault bundle completion)
    • Geode contents (depends on: Game ID and number of Geodes opened so far)
    • Location of ladders in the Mines and Skull Cavern.
    Unpredictable:
    • Digging dirt inside the mines
    • Monster loot
    • Fiber and Mixed Seeds drops of Weeds
    • everything about Fishing
    • Mine level layout (i.e. where the stones, objects and enemies are)
    DayUpdate:
    • Dish of the day in the Saloon
    • Daily Luck
    • Tomorrow's weather
    • Farm Cave bat fruits
    • Fairy event crop location
    I snuck in a third category I called "DayUpdate". It consists of things that use the shared Game1.random, but very shortly after it's been re-initialized at the start of the day, making them somewhat predictable. It's still true that all previous random events affect all later ones, so the earlier the event is, the easier it is to predict.
    I ordered them by how easy they are to predict, with later ones being more and more difficult to keep track of since the game uses Game1.random a lot. While the Dish and Daily Luck are easy since they happen right at the start of the day, the Cave fruits only happen fairly late, so literally anything you have on your farm or in your house affects the outcome, including crops, furnaces, grass, trees, everything. So while all of them are technically predictable, my success in accurately predicting them is mixed. My predictions are reliably correct up to the weather, and only sometimes right for everything after that, due to inaccuracies in mimicking the game's behavior.

    Finding the right Game ID

    Whether or not you can find all the items you need from the Traveling Cart quickly enough only depends on your unique Game ID. It's a fixed number associated with your save file, and used in basically all random events. It is the reason that different save files have different random events.

    While it is a 64-bit number and therefore can hold up to 2^64 different values, due to how it is used in the RNG only 2^32 (~4 billion) different outcomes are possible. So I wrote a program to check all of them so see which IDs produced all necessary Traveling Cart items in Spring, and had a Fairy Event on Summer 1.

    And the answer was: none.

    Luckily, there are other sources for one of the necessary items, namely Krobus who can sell a Tiger Trout.
    Including that in the search resulted in exactly 8 plausible game IDs.

    However, the one thing I didn't account for at that point was the Red Snapper.
    While it can be caught in Summer normally, and there seems to be enough time to do so, there actually isn't: It can only be caught when it's raining, but neither Summer 1 (always sunny) nor Summer 2 (needs to be sunny for Fairy event to work) have rain.
    None of the 8 plausible IDs had a Red Snapper on sale, but luckily it can be found in a different place as well: in the Garbage Cans! Looking through the garbage can drops, 2 of the 8 IDs had a Red Snapper in one of the trash cans on Summer 1 or Summer 2.

    But there was a second and final issue with the Game IDs:
    The Fairy event affects a 5x5 area of crops, so it can grow at most 25 crops. However, when adding up all the Summer crops that need growing, the total is 27: 10x Wheat, 6x Melon, 6x Corn, Blueberry, Hot Pepper, Tomato, Poppy, Sunflower. That means two of these 27 need to come from a different source, i.e. the Traveling Cart. Only one of the two Game IDs offers this.
    That means there is exactly one Game ID which will allow you to complete all Community Center bundles by Summer 2.

    The magic seed is 3772546972.

    So, can this Game ID actually be achieved in-game? The ID is determined at the time you start the game (or exit to title screen), as the number of seconds that have passed since 2012-06-22 midnight UTC. So as long as you start your game exactly at 17:42:52 UTC on January 8 in the year 2132, you're good to go! Lacking a time maching at my disposal, changing the system clock (not recommended!) does the trick as well though.

    As a note, if you're trying to plug in this ID into MouseyPounds' Predictor, you'll not see accurate results. That's because MouseyPounds' JavaScript re-implementation of the .NET RNG is not accurate beyond game ID 2^31, due to how how JavaScript handles integer overflows differently from .NET.
    Since that inaccuracy will not affect anyone for a few more decades to come though, it doesn't really have any effect other than these artificial cases. Of course I'm welcoming some independent verification that this ID actually produces the shown results by fixing the Predictor (or trying it yourself in-game), I may look into a PR for it.

    The Missing Bundle

    In Stardew Valley update 1.4, a new bundle was added, to be completed after the Community Center is complete. It only opens at least two days after the Community Center was completed (the next day is the celebration cutscene, and the night after the abandoned Joja mart can open up), meaning that the earliest possible completion is on Summer 4.

    The items in it are not particularly restricted in terms of when you can obtain them, but they can require a lot of setup and resources to collect. You only need 5 out of 6, and that's good because the Caviar is impossible to procure in time (Sturgeons can only be caught in Summer, and aging the Roe takes 4 days), unless you buy a sturgeon in spring, which is not possible with the given Game ID. So I need to do all the other five. The Dinosaur Mayonnaise and the Prismatic Shard are the easy ones, but the other three require a lot of work:
    • Silver Quality Wine (requires a fully upgraded house + 14 days of aging)
    • Void Salmon (requires 60 museum donations for access to the Sewer)
    • 5x Ancient Fruit (requires 28 days of growth)

    Putting it all together

    To truly prove that it's actually possible to complete the Missing Bundle by Summer 4 and I didn't miss any detail, I set out to complete a full run.

    Planning out each day, it became clear that the main limiting factor would be Robin, which will be required quite a lot to build and upgrade the buildings. The Cellar needs to be completed by Spring 18, in order for the Wine to have enough time to age. At the same time, the Deluxe Barn as to be completed by Spring 20 in order for the Pig to have enough time to grow up and find Truffles. Additionally, we'll need at least a Big Coop for the Duck Egg and Duck Feather, and the chickens need enough time to raise their friendship in order to lay Large Eggs.

    This turned out to be really tight to fit all the buildings into the schedule at the right time. In order to complete everything in time, it's necessary to start buying buildings right on Spring 1. While it's not impossible to accumulate the money to buy a Coop in your first day, it's challenging even when optimizing for it since you run out of time quickly before Robin closes at 5pm. Instead, I chose to buy some more time by delaying the Coop.
    That would mean that the chickens will not be able to accumulate enough Friendship to produce Large Eggs in time though (they only gain 23 Friendship per day max), unless I have the Coopmaster perk. That means leveling up Farming to 10, which is not a huge deal, and since it's useful to have anyway for the gold quality crops, I went with that approach.

    Other minor challenges were collecting the 60 museum donations, and accumulating enough money to buy all the things. The museum donations actually turned out to be quite simple by abusing fishing treasure chests a lot. All 60 minerals and artifacts can be found and donated on Spring 2, either directly from a treasure chest or from the Geodes found in them.
    Money is quite easy to come by using the same method, fishing for Treasure Chests. Another even faster but less engery-efficient way is digging up the soil inside the mines, the Strange Dolls found in it sell for 1000g a piece. So money was never a problem, but it still surprised me how much was needed overall.

    The completed run



    The run itself was created using lots of planning and tools. While I'm trying to not waste any time throughout, this is not meant to be a speedrun. It doesn't try to hold up to any standard of validity, instead first and foremost tries to be nice to look at while demonstrating how all bundles can be completed by Summer 4. Not only is the game modded (to both visualize and execute some of the RNG manipulation), it's also segmented and spliced (each day played individually).

    The whole playthrough does not use any beneficial glitches (as that would defeat the point), but does contain some harmless moments of the game breaking a bit with wonky animations or overlapping cutscenes.

    If you think all the tool uses look like they are sped up a lot, that is because of a technique called animation canceling. Stardew Valley has a hidden key combination to cancel tool use animations: Right Shift + Delete + R. Usually all tool animation have a long follow-through period after the action is already finished, which can be canceled to significantly speed up tool use. I modded the game to always do perfect animation cancels for me, except for the Scythe where different animation frames have different hitboxes so the length of the animation is important.

    Caveats

    I played it fast and loose with manipulating the unpredictable RNG in the game:
    While I'm confident that all the shown outcomes can be achieved by strategic pausing, I'm also aware that it'd be an absolute slog to do every single event like that and that you'd need to spend ages in the inventory screen for some of them.
    It wouldn't be fun to do, nor fun to watch, so I used a mod instead to manipulate the game's shared RNG to give me the outcomes I want without the need for delays.
    The resulting play-through satisfies my desire to prove the possibility of finishing all bundles by Summer 4, but if RTA-viability matters for you, I invite you to improve on this by finding a more real-time-friendly route to finish the bundles quickly.
     
      Honeywell and One More Day like this.
    • One More Day

      One More Day Cosmic Narwhal

      So, I watched the first 20 minutes or so of the video, and it is definitely a bit....... cheaty

      But it looks very impressive nonetheless. Well done. A while back someone on here found a seed ID that could be done vanilla by about Summer 18 IIRC, and a few people did that. I doubt I'll be copying this, but I'll definitely watch the rest later
       
      • ShneekeyTheLost

        ShneekeyTheLost Master Astronaut

        First off... a hearty congratulations on your accomplishment! This is one for the record books.

        Regarding the Crocus, there's another method of obtaining, but not within the timeframe allotted. During your mining dives, blue slimes have a good chance of dropping Winter Roots, which can be run through a Seed Maker to make Winter Seeds, which can then be planted in the Greenhouse to obtain Crocus out of season. While a bit RNG, you can generally get enough to have a reasonable expectation to get at least one Crocus.

        Of course, with this strategy, the bundle unlocking the greenhouse is the last one completed, with the gold-star crops being the final submission, so that wasn't going to be possible. But for those who want something somewhat less reliant on Cart Vendor, it's an alternative.
         
        • endly

          endly Void-Bound Voyager

          without the Bat Cave, i believe the fastest is Fall 3rd. even with the Bat Cave, this requires helluva luck from it to spawn Fall Fruits (at least i think so).
           
          • Elenna101

            Elenna101 Scruffy Nerf-Herder

            Super cool, even if it's not doable without mods.

            You can also manually change the ID number of a game by going to the save file, changing the number in the folder name and file name, and then, within the file (the one that starts with your farmer's name), search for "uniqueIDForThisGame" and change the number found after that.
            If you start a new game and immediately do this, it's exactly the same as starting a game with that ID number.

            There's also the option of getting it from the Travelling Cart, if you get lucky with your game seed or pick a seed that has it.
             
            • MrWint

              MrWint Space Hobo

              Fair point, I'm exploiting the RNG as aggressively as I am mostly because of the Missing Bundle, which is the source of most expensive purchases and the museum donation requirement. If you skipped it, the whole thing would be way more RTA-viable, and there's a good chance you'd be able to do it without any luck manipulaiton, just with the right seed and planning.

              Technically it is doable without mods, in that there's a sequence of inputs to the vanilla game which can do it, but since SDV depends so heavily on external factors in its RNG, we don't have a good way to make it reproducible without altering the game (i.e. modding) anyway, or emulating the whole environment it runs in.
              I used mods for convenience, and because I wanted to visualize how the game's RNG functions under the hood.

              It will work for most things, but it will not be exactly the same, since the Game ID influences e.g. the Forage and Artifact Spot locations on day 1, which are determined before the first save happens, so even if you change the ID in the save file right away, some things will still be placed according to the old ID. For example, the Anchor artifact spot on day one is 100% consistent in the beach on day 1, always in the same location, but only when starting with the correct seed.
               
              • squigglyruth

                squigglyruth Pangalactic Porcupine

                I had a feeling this was the case. Can you clarify what they are based on?
                 
                • MrWint

                  MrWint Space Hobo

                  They depend on the Game ID, the mine level, the position of the stone, your daily luck and luck level, and the number of stones remaining on the map. You can see a visualization of this in the video. Note though that this only applies to the ladders found under stones. Ladders found after defeating enemies or pre-spawned ladders are unpredictable, as are the locations of the stones themselves, so it's not possible to pre-plan a route through the mines just using this information. All you can predict is given a stone in the mines, is there a ladder under it or not.
                   
                  • squigglyruth

                    squigglyruth Pangalactic Porcupine

                    Thank you! That explains why they were often appearing in the same place when I replayed a day, but without 100% repeatability.
                     
                    • Tachyonic Particle

                      Tachyonic Particle Yeah, You!

                      Can you please share all the mods that you used for the run, especially the rain, mining, and dig predictors? Thanks!
                       
                      • Bla_De

                        Bla_De Yeah, You!

                        How did I not know about this? I am currently doing a series of streams on this, but on vanilla. You will be able to find me on Twitch, same name.

                        What was your criteria for finding a seed? I have done a similar search, and I know of another code diver who has searched also, and we have a list of ~24 that have CC Summer 2 year 1 possible, with ~5 of those able to complete Missing Bundle Summer 4.

                        BTW, this is your seed on the predictor: https://mouseypounds.github.io/stardew-predictor/?id=-522420324
                        And the seed I am using: https://mouseypounds.github.io/stardew-predictor/?id=-709968377

                        You may notice that there is no red cabbage or seed in the cart. I am going to force it out of a Skull Caverns treasure chest, which has odds of 1/648... That will be fun...

                        The tile the fairy chooses is actually tied into the gameID and day (FairyEvent::setUp). If you completely clear your farm of trees, grass, flooring, and tilled dirt, you can determine which tilled tile it will hit (based on the order that the HoeDirt is created).

                        Well done on working out how to get the red snapper out of the trash.
                         
                        • Bla_De

                          Bla_De Yeah, You!

                          Aaaaand just saw that you are correct in that the fairy doesn't come when it is raining. Looks like I am restarting my run.

                          I will be using this seed though: https://mouseypounds.github.io/stardew-predictor/?id=-638161535

                          As mentioned above, Red Cabbage Seeds can be found in the Caverns, and this seed has 10 wheat in the cart, which means Ancient Fruit can be grown by the fairy too.
                           
                          • Jarhead99z

                            Jarhead99z Aquatic Astronaut

                            Which mods did you use, like for the cancel animations and the predictor overlay for clay, stones, ladders, etc?
                             
                            • Elenna101

                              Elenna101 Scruffy Nerf-Herder

                              The animation cancel is not a mod. It's a hard-coded thing on PC where you can cancel animations by pressing right shift, R, and delete together during the animation you want to cancel.

                              The predictor is here: https://www.nexusmods.com/stardewvalley/mods/6614/
                              BTW, the predictor doesn't actually change your game at all - it just reads some information (either from the save file or manually entered) and spits out predictions. Technically the same thing could be done in a spreadsheet, it would just be bigger and less pretty. So arguably that's not a mod either :)
                               
                              • magiccarrot

                                magiccarrot Space Hobo

                                He specifically said that animation canceling can be done but he used a mod to do it in the challenge, and the mod you link to for the predictor doesn't overlay onto the game map like it does in the challenge and isn't anywhere near as convenient to use.
                                 
                                • Murky9527

                                  Murky9527 Space Hobo

                                  I tried to check the seed that you used, but there is no way to input the seed that was given by you. I tried to set the time, but win10 is giving me a hard time setting it to 2132.
                                  Anyway, I made it, and the chart is different.
                                  So is this run only working in 1.4?
                                  Is it possible that you provide the first-day save?
                                   
                                  • geekgirl101

                                    geekgirl101 Void-Bound Voyager

                                    I tried to input this number in the Random Seed but it only allows 9 digits, this is 10 digits. Was there a typo?
                                     
                                    • squigglyruth

                                      squigglyruth Pangalactic Porcupine

                                      I am very impressed by the Summer 4 finish. A record well broken.

                                      Yes, back in the day we searched long and hard for a suitable seed. I think the earliest we found allowed completion of the community centre on summer 15 without any further RNG manipulation (apart from starting with that seed). Then a few of us tried it out and posted updates as we went. It was a fun time!

                                      We didn't factor in fairies - because who can predict where they land? (I know this is possible, but I didn't know how at the time). We also didn't think about utilising trash cans for the red snapper - it wasn't necessary when we thought the theoretical limit was Summer 10 (which I think is true without fairies?)

                                      At the time we were struggling to find seeds that would give the right items for an earlier completion. I remember that the run I did (that completed on Summer 15) took a lot of concentration and planning, but I feel I could probably play it better now. On the other hand, some things have changed - for example, the ability to farm mushrooms from mine levels (which was how I got lots of money without RNG manipulation).

                                      The RNG manipulation in-game isn't something I have ever tried, but it's something I can admire. It makes a huge difference - without it, the idea of donating 60 items to the museum by Spring 2 is just completely laughable - it can be hard to do that by late spring without any RNG manipulation!

                                      I would be interested to know what items the travelling cart gives in your seed. Any chance of posting a list? I'd like to see how plausible it might be to do a vanilla run through...
                                       

                                      Share This Page