We are in the process of transferring the hosting and maintenance responsibilities of the wiki from Chucklefish to ConcernedApe, which is why the wiki will temporarily be hosted at stardewcommunitywiki.com. Soon the official wiki will resume at stardewvalleywiki.com and will be hosted going forward by ConcernedApe. Prior to the transfer to ConcernedApe we will update this site with the date on which the transfer will occur.

Talk:The Cave

From Stardew Valley Wiki
Jump to: navigation, search
This talk page is for discussing The Cave.
  • Sign and date your posts by typing four tildes (~~~~).
  • Put new text below old text.
  • Be polite.
  • Assume good faith.
  • Don't delete discussions.

I came upon this page and the whole of the Mushrooms section was in the last cell of the fruit table. I think I've fixed that so it's readable but there's now a cell missing from the fruit table. Sorry! --Toast recon (talk) 20:49, 25 June 2016 (EDT)

Fixed? I think I formatted it correctly and if I didn't at least the last cell is back, yay? Nice catch btw.--DigDug (talk) 01:46, 26 June 2016 (EDT)

Regarding the spawn times for the mushrooms, the main page seems to have incorrect info (though I didn't want to edit it until someone confirms it). From my experience, the mushrooms spawn on the morning of every second day regardless of when they are harvested. So if you don't harvest them the day they spawn (say, for example, Fall 16), and then harvest them the next day (Fall 17), they will still spawn the day after (Fall 18). If anyone can confirm this, please edit the main text. --Perpetuate303 15:22, 29 December 2016

Hi Perpetuate303! I can answer part of your question. The formula is minutesUntilReady = 3000 - timeOfDay, and it executes in the DayUpdate() function. So, the boxes definitely don't spawn every day, and the time is definitely not random.
As for the exact time they spawn... this is still unclear to me. If the timer is set at the beginning of the day following a harvest (as it seems to), then "timeOfDay" would always be 0600 -- which makes it meaningless to include.
So, the page is incorrect on two counts (random and every day), but as for the rest... I'm just not seeing how it works.
Perhaps someone more experienced with the game code can shed some light. :D margotbean (talk) 09:35, 30 December 2016 (UTC)

This should be updated now that the way sleeping affect machines has changed. Regardless of the time of the day you sleep, mushrooms will be ready at the same time.(7:20am I think) Unless you go to sleep after midnight. If you do, you will miss a whole day of production.Digus (talk) 05:20, 13 January 2020 (UTC)

Fruit & Mushroom Chances

These percentages were added to the page in September 2018 without a code reference. I've dug into the code for v1.3.36, and believe them to be accurate.


Fruit is more straight-forward than mushrooms, the code is in FarmCave::DayUpdate:

while (Game1.random.NextDouble() < 0.66)
    int parentSheetIndex = 410;//Blackberry
    switch (Game1.random.Next(5))
      case 0:
        parentSheetIndex = 296;//Salmonberry
      case 1:
        parentSheetIndex = 396;//Spice Berry
      case 2:
        parentSheetIndex = 406;//Wild Plum
      case 3:
        parentSheetIndex = 410;//Blackberry
      case 4:
        parentSheetIndex = Game1.random.NextDouble() < 0.1 ? 613/*Apple*/ : Game1.random.Next(634, 639);//Apricot, Orange, Peach, Pomegranate, Cherry

There is a straight 20% chance for each foraged fruit, and a (0.2 * 0.1 = 0.02) 2% chance for Apple. For each of the other 5 fruit tree fruit, there is a (0.2 * 0.9 * 0.2 = 0.036) 3.6% chance.

The likelihood of spawning any kind of fruit is 0.66 for the first fruit, and (0.66 * 0.66) for the 2nd fruit, and so on until the check for a random number between 0 and 1 < 0.66 fails. I do not know how to calculate the average number of times this loop is successful before it fails. I also don't know the differences between platforms (PC, console, mobile) in calculaing pseudo-random numbers. I've removed the line on the page saying "about 0.8 fruit spawn per day", since I can't verify it. Anyone who wishes to spell it out for the wiki, please add a topic to this discussion page! Then we can add the average fruit expected per day back to the main page.


Mushrooms are a bit more complicated; the code is in Object.DayUpdate. Inside a switch/case on the location of the mushroom box in the sprite sheet TileSheets\Craftables.xnb, the case for the mushroom box is 128:

case 128://Mushroom Box
if (this.heldObject.Value == null)
	this.heldObject.Value =
	  new Object
	    Game1.random.NextDouble() >= 0.025 ?
		(Game1.random.NextDouble() >= 0.075 ?
		    (Game1.random.NextDouble() >= 0.09 ?
			(Game1.random.NextDouble() >= 0.15 ? 404/*Common Mushroom*/ : 420/*Red Mushroom*/)
		    : 257/*Morel*/)
		: 281/*Chanterelle*/)
	    : 422/*Purple Mushroom*/, 1, false, -1, 0
	this.minutesUntilReady.Value = 3000 - Game1.timeOfDay;

Purple Mushroom.png Purple Mushroom = 0.025 = 2.5%
Chanterelle.png Chanterelle = (1 - 0.025) * 0.075 = 0.073125 ≈ 7.3%
Morel.png Morel = (1 - 0.025) * (1 - 0.075) * 0.09 = 0.08116875 ≈ 8.1%
Red Mushroom.png Red Mushroom = (1 - 0.025) * (1 - 0.075) * (1 - 0.09) * 0.15 = 0.1231059375 ≈ 12.3%
Common Mushroom.png Common Mushroom = (1 - 0.025) * (1 - 0.075) * (1 - 0.09) * (1 - 0.15) = 0.6976003125 ≈ 69.8%
-- margotbean (talk) 23:03, 14 May 2019 (BST)

Time for Mushrooms to Mature

The page currently says "Growth time is 3000 minutes [2], which means production will vary based on the amount of time you spend sleeping.". This is no longer true in the most recent patch, right? --Zamiel (talk) 21:10, 14 February 2020 (UTC)

Having dug into the code for mushroom boxes, I have this to report:
If a box has no mushroom processing in it, either by being created or having been harvested, the box begins processing at 6am the next morning (Object::dayUpdate). The time it takes to complete is 3000 minutes, minus the time that you went to sleep the previous day.
I.e. if you went to sleep at 2am (2600) then the mushrooms would be ready in 400 minutes, or 6 hours 40 min, or 12:40pm
If you went to sleep at 7am (700) then the mushrooms would be ready in 2300 minutes, or 1 day (1600) 11 hours (660) and 40 min, or 5:40pm the following day.
Object::dayUpdate is called before timeOfDay is reset, and after overnight processing is done.
Can someone please verify this? BlaDe (talk) 09:16, 21 February 2020 (UTC)
Yep, your predictions match what I get in-game.
The time you go to sleep controls when mushrooms are ready. 2am bed = 12:40pm mushrooms. 1:30 am bed = 11:50 mushrooms. 6:20 pm bed = 1:40 am mushrooms. Going to bed at or before 6pm means mushrooms aren't ready the next day. I've done tests both after harvesting old mushroom bins and with newly-installed mushroom bins.
I also confirmed that harvest time has no effect: I harvested each mushroom bin at a different time ranging from 6:30am to 11pm, but all were ready at the same time.
But even though the article is correct that sleeping controls mushroom production, the details are currently wrong (presumably because the details were based on 1.3). Nebulous Maestress (talk) 22:04, 1 August 2020 (UTC)

Fruit Chances

The above code snippet leaves out a critical element: the part where the location of the new fruit is set. The code randomly selects one of 90 tiles (X=1-10, Y=1-9, inclusive), but at most 50 of those tiles are valid -- 50 are valid if the cave is completely empty, but each spawned fruit reduces the number of valid tiles. So even though 66% is the chance of the loop not terminating, there's at most a 37% chance of fruit spawning on any loop.

I've calculated the cumulative effect of multiple possible loops, starting from an empty cave, and added the results to the article. Nebulous Maestress (talk) 23:09, 1 August 2020 (UTC)