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)

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

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
        break;
      case 1:
        parentSheetIndex = 396;//Spice Berry
        break;
      case 2:
        parentSheetIndex = 406;//Wild Plum
        break;
      case 3:
        parentSheetIndex = 410;//Blackberry
        break;
      case 4:
        parentSheetIndex = Game1.random.NextDouble() < 0.1 ? 613/*Apple*/ : Game1.random.Next(634, 639);//Apricot, Orange, Peach, Pomegranate, Cherry
        break;
    }
}

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.

Mushroom

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;
	break;
}

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)