Changes

no edit summary
Line 1: Line 1: −
Small minable stones and ores can appear as random stones throughout the floor, or rarely as small clumps. These have different distributions<ref name="populateLevel" /><ref name="chooseStoneType" />.
+
Small minable stones and ores can appear as random stones throughout the floor, or rarely as small clumps. These have different distributions<ref name="populateLevel" /><ref name="createLitterObject" />.
 
On average there will be less than 0.67 small resource clumps on each floor with neutral luck, and less than 1 for the largest possible luck. These clumps have a 25% chance to be a dark grey rock (stone ore), a 1.5% chance to be iridium, and a 73.5% chance to be gold.
 
On average there will be less than 0.67 small resource clumps on each floor with neutral luck, and less than 1 for the largest possible luck. These clumps have a 25% chance to be a dark grey rock (stone ore), a 1.5% chance to be iridium, and a 73.5% chance to be gold.
    
The distribution for random stones is more complex and varies with depth and best understood in a few stages.
 
The distribution for random stones is more complex and varies with depth and best understood in a few stages.
   −
If a [[Quests#List of Mr. Qi's Special Orders|Qi quest]] is in progress which makes the mine more dangerous, there is a small chance for a stone to be replaced with a [[Radioactive Ore|radioactive ore]]. This is very dependent upon [[luck]], with the luck boost from the special charm being worth 192 floors, and the worst luck requiring a depth of floor 550 to have any chance ore will drop. This is also dependent on [[Luck#Luck Buffs|luck buffs]], with each level of luck worth 15 floors. This will replace any of the below stones.
+
If a [[Quests#List of Mr. Qi's Special Orders|Qi quest]] is in progress which makes the mine more dangerous, there is a small chance for a stone to be replaced with a [[Mining#Radioactive Node|radioactive node]]. This is very dependent upon [[luck]], with the luck boost from the special charm being worth 192 floors, and the worst luck requiring a depth of floor 550 to have any chance ore will drop. This is also dependent on luck [[buffs]], with each level of luck worth 15 floors. This will replace any of the below stones.
   −
The chance for a stone to be a metal ore (copper, iron, gold or iridium) will vary depending on floor, starting at 2% on floor 1, rapidly increasing to 16% on floor 100, and then increasing to 100% on floor 1780. Luck has no effect on this chance, or on the ore distribution. Copper and iron have the same distribution. From floor 2010 only [[Gold Ore|gold]] and [[Iridium Ore|iridium ore]] will be found, and from floor 5700 only iridium ore will be found from this generation.
+
The chance for a stone to be a metal ore ([[Copper Ore|copper]], [[Iron Ore|iron]], [[Gold Ore|gold]], or [[Iridium Ore|iridium]]) will vary depending on floor, starting at 2% on floor 1, rapidly increasing to 16% on floor 100, and then increasing to 100% on floor 1780. Luck has no effect on this chance, or on the ore distribution. Copper and iron have the same distribution. From floor 2010 only [[Gold Ore|gold]] and [[Iridium Ore|iridium ore]] will be found, and from floor 5700 only iridium ore will be found from this generation.
   −
If the stone is not a metal ore, there is a chance for it to be a a gem stone ore ([[diamond]], [[emerald]], [[aquamarine]], [[ruby]], [[amethyst]], [[topaz]] and [[jade]]), a gem node (the round purple stone), a mystic stone or a dark grey rock. This means that the chance can decrease as you go deeper as more of the stone is metal ore, and above floor 1780 these will not be found.
+
If the stone is not a metal ore, there is a chance for it to be a a gem stone ore ([[diamond]], [[emerald]], [[aquamarine]], [[ruby]], [[amethyst]], [[topaz]], and [[jade]]), a gem node (the round purple stone), a mystic stone or a dark grey rock. This means that the chance can decrease as you go deeper as more of the stone is metal ore, and above floor 1780 these will not be found.
Luck and mining level only play a significant role for mystic stones and gem nodes. For others the contribution is negligible.
+
Luck and mining level only play a significant role for [[Mining#Mystic Stone|mystic stones]] and gem nodes. For others the contribution is negligible.
    
For gem stone ores, diamond is slightly rarer than most, and jade is twice as rare as most. The chance initially increases, peaking at a chance of ~0.35% (~0.18% for jade) at a depth of ~800, before dropping back down.
 
For gem stone ores, diamond is slightly rarer than most, and jade is twice as rare as most. The chance initially increases, peaking at a chance of ~0.35% (~0.18% for jade) at a depth of ~800, before dropping back down.
   −
Dark grey rocks, start with their maximum chance at floor 1 (9.73% for dark grey rocks, 0.005% for mystic stones, 0.059% for gem nodes for best chances), and drop proportionally as ores take their place.
+
Dark grey rocks, start with their maximum chance at floor 1 (9.73% for dark grey rocks, 0.005% for mystic stones, 0.059% for gem nodes for best chances), and drop proportionally as ores take their place.
    +
During the [[Desert Festival]], there are some small changes to how the ore is generated, this is to allow the generation of [[Mining#Calico Egg Node|Calico egg nodes]]. This occurs below in the section to generate ore clumps, and the section to generate metallic ores.
    
==Code Details==
 
==Code Details==
 
The main code for populating the floor is found in the function <code>StardewValley.Locations.MineShaft::populateLevel</code>. In setting up to populate the floor, it initially defines stoneChance as a random number (double) in the range [10,30), and gemStoneChance as 0.003. It then calls <code>StardewValley.Locations.MineShaft::adjustLevelChances</code>, which will perform a few checks including setting the chance to find stone to 0 for infested floors and dividing gem stone chance by 2<ref name="adjustChances" />.
 
The main code for populating the floor is found in the function <code>StardewValley.Locations.MineShaft::populateLevel</code>. In setting up to populate the floor, it initially defines stoneChance as a random number (double) in the range [10,30), and gemStoneChance as 0.003. It then calls <code>StardewValley.Locations.MineShaft::adjustLevelChances</code>, which will perform a few checks including setting the chance to find stone to 0 for infested floors and dividing gem stone chance by 2<ref name="adjustChances" />.
After this setup, it will then iterate through every square of the floor, and if it passes a few checks it will add a stone selected using the function <code>StardewValley.Locations.MineShaft::chooseStoneType</code>, passing the gemstone chance from above and the magic numbers 0.001 and 5e-5 for gem nodes (internally chanceForPurpleStone) and mystic stones (internally chanceForMysticStone). In the same sweep, if it does not add a stone there is a chance for it to add a large resource clump, which are 2 possible variants of a 2 by 2 boulder.
+
After this setup, it will then iterate through every square of the floor, and if it passes a few checks it will add a stone selected using the function <code>StardewValley.Locations.MineShaft::createLitterObject</code>, passing the gemstone chance from above and the magic numbers 0.001 and 5e-5 for gem nodes (internally chanceForPurpleStone) and mystic stones (internally chanceForMysticStone). In the same sweep, if it does not add a stone there is a chance for it to add a large resource clump, which are 2 possible variants of a 2 by 2 boulder.
    
After iterating through every square, and performing a few other tasks, it will attempt to add ore clumps using the function <code>StardewValley.Locations.MineShaft::tryToAddOreClumps</code>, but only if the floor is not divisible by 5, and it is not a treasure room.
 
After iterating through every square, and performing a few other tasks, it will attempt to add ore clumps using the function <code>StardewValley.Locations.MineShaft::tryToAddOreClumps</code>, but only if the floor is not divisible by 5, and it is not a treasure room.
    
===Ore Clumps===
 
===Ore Clumps===
In the <code>StardewValley.Locations.MineShaft::tryToAddOreClumps</code><ref name="oreClumps" /> function, a try will only be made if a random number is less than 0.55 plus the average daily luck. The maximum possible average daily luck is 0.1 from random luck and 0.025 from the special charm<ref name="dailyLuck" />. This means with neutral luck there is a 55% chance to try, and with the best possible luck there is a 67.5% chance.
+
In the <code>StardewValley.Locations.MineShaft::tryToAddOreClumps</code><ref name="oreClumps" /> function, a try will only be made if a random number is less than 0.55 plus the average daily [[luck]]. The maximum possible average daily luck is 0.1 from random luck and 0.025 from the special charm<ref name="dailyLuck" />. This means with neutral luck there is a 55% chance to try, and with the best possible luck there is a 67.5% chance.
 
It will try once, and then generate a random number and keep going if that random number is less than 0.25 plus the average daily luck.
 
It will try once, and then generate a random number and keep going if that random number is less than 0.25 plus the average daily luck.
 
This means there will be 1 chance, plus a 25% chance with neutral luck or a 37.5% chance with best possible luck.
 
This means there will be 1 chance, plus a 25% chance with neutral luck or a 37.5% chance with best possible luck.
Line 31: Line 32:  
However, each try chooses a random tile on the map and will only place an ore clump there if the tile is free, resulting in less than these numbers.
 
However, each try chooses a random tile on the map and will only place an ore clump there if the tile is free, resulting in less than these numbers.
   −
To choose which type of ore to add it calls the function <code>StardewValley.Locations.MineShaft::getAppropriateOre</code><ref name="whichOre" />, which just before returning has a 25% chance (if it is not in hard mode) to set the ore to 668 or 670, which are the dark grey rocks (stone ore). Otherwise, the ore is set as 764, gold ore, with a 2% chance to set it to 765, iridium ore.
+
To choose which type of ore to add it calls the function <code>StardewValley.Locations.MineShaft::getAppropriateOre</code><ref name="whichOre" />, which just before returning has a 25% chance (if it is not in hard mode) to set the ore to 668 or 670, which are the dark grey rocks (stone ore).
This results in total chances of 25% for dark grey rocks, 1.5% chance for iridium ore, and 73.5% for gold.
     −
===Random ore placement (chooseStoneType)===
+
Otherwise, it first checks if the [[Desert Festival]] is ongoing. If it is there is a (25 + [[Desert Festival#Skull Cavern|"Egg Rating"]] / 20)% chance of the node being a [[Mining#Calico Egg Node|Calico egg node]].
 +
Otherwise, the ore is set as 764, gold ore, with a 2% chance to set it to 765, iridium ore.
 +
 
 +
When the festival is not ongoing, this results in total chances of 25% for dark grey rocks, 1.5% chance for iridium ore, and 73.5% for gold.
 +
 
 +
===Random ore placement (createLitterObject)===
 
====Radioactive Ore====
 
====Radioactive Ore====
[[File:SDV SC Radioactive.png|300px|thumb|right|Changing distribution of radioactive ore with luck (daily luck and luff buffs).]]
+
[[File:SDV SC Radioactive.png|300px|thumb|right|Changing distribution of radioactive ore with luck (daily luck and luff buffs) with a difficulty of 1.]]
 
This will first produce radioactive ore, with the following check:
 
This will first produce radioactive ore, with the following check:
 
<syntaxhighlight lang="C#">
 
<syntaxhighlight lang="C#">
 
if (this.GetAdditionalDifficulty() > 0 && this.mineLevel % 5 != 0 && this.mineRandom.NextDouble() < (double)this.GetAdditionalDifficulty() * 0.001 + (double)((float)this.mineLevel / 100000f) + Game1.player.team.AverageDailyLuck() / 13.0 + Game1.player.team.AverageLuckLevel() * 0.0001500000071246177)</syntaxhighlight>
 
if (this.GetAdditionalDifficulty() > 0 && this.mineLevel % 5 != 0 && this.mineRandom.NextDouble() < (double)this.GetAdditionalDifficulty() * 0.001 + (double)((float)this.mineLevel / 100000f) + Game1.player.team.AverageDailyLuck() / 13.0 + Game1.player.team.AverageLuckLevel() * 0.0001500000071246177)</syntaxhighlight>
For this, the luck boost from the special charm (0.025, contribution to AverageDailyLuck) is equivalent to an additional 192.3 floors (2500/13), and a single point of luck (such as from a food buff) is worth ~15 floors. With the best possible luck (0.125 daily luck with special charm, +9 luck from [[Magic Rock Candy]], a [[Ginger Ale]] made with [[Qi Seasoning]], and 2 [[Lucky Ring|Lucky Rings]]) 1.32% of stones will be [[Radioactive Ore|radioactive ore]] on floor 1, increasing to 1.42% on floor 99. With the worst possible luck no radioactive ore will appear until floor 550. Also note that radioactive ore will not appear on any floor divisible by 5.
     −
This means that hypothetically with the best possible luck, from floor 98684 onwards, except on floors divisible by 5, the only ore found from random stones would be radioactive ore. With the worst possible luck, this increases to floor 100550. Reaching these floors would require bypassing the [[Quarry Mine]] floor, which can be found on floor 77257 of Skull Cavern.
+
The difficulty can be changed by using the statue at the cavern entrance or by accepting the [[Quests#List of Mr. Qi's Special Orders|Qi quest]] Skull Cavern Invasion. This provides 3 levels, normal (0), one of these active (1), or both of these active (2). With a difficulty of 0, no radioactive ore will spawn.
 +
 
 +
The luck boost from the [[Special Charm|special charm]] (0.025, contribution to AverageDailyLuck) is equivalent to an additional 192.3 floors (2500/13), and a single point of luck (such as from a food buff) is worth ~15 floors. The boost from the additional difficulty (setting it to 2 instead of 1) is equivalent to 100 floors.
 +
 
 +
With the difficulty set to 1, with the best possible luck (0.125 daily luck with special charm, +9 luck from [[Magic Rock Candy|magic rock candy]], a [[Ginger Ale|ginger ale]] made with [[Qi Seasoning|Qi seasoning]], and 2 [[Lucky Ring|lucky rings]]) 1.32% of stones will be [[Radioactive Ore|radioactive ore]] on floor 1, increasing to 1.42% on floor 99. With the worst possible luck no radioactive ore will appear until floor 550. Also note that radioactive ore will not appear on any floor divisible by 5.
 +
 
 +
This means that hypothetically with the best possible luck, with difficulty set to 2, from floor 98584 onwards, except on floors divisible by 5, the only ore found from random stones would be radioactive ore. With the worst possible luck, this increases to floor 100450. Reaching these floors would require bypassing the [[Quarry Mine]] floor, which can be found on floor 77257 of Skull Cavern.
    
====Metal Ores====
 
====Metal Ores====
Line 53: Line 63:  
     }</syntaxhighlight>
 
     }</syntaxhighlight>
   −
This ends up being defined as either <code>0.02 + skullCavernMineLevel * 0.0005 </code> for floors 1-10, <code>0.01 + skullCavernMineLevel * 0.0015</code> for floors 10 to 100 (when skullCavernMineLevel <= 100), and <code>0.11 + skullCavernMineLevel * 0.0005</code> for floors 100 and up(when skullCavernMineLevel >= 100). This means the chance for ore will increase by 0.05% for each floor, except between floors 10 and 100 where it increases by 0.15% each floor. This reaches 100% at floor 1780, providing the 4th region. At the crossover point of floor 10 the 2 chances are equal as the extra term is 0. This means the function is continuous.
+
This ends up being defined as either <code>0.02 + skullCavernMineLevel * 0.0005 </code> for floors 1-10, <code>0.01 + skullCavernMineLevel * 0.0015</code> for floors 10 to 100 (when skullCavernMineLevel <= 100), and <code>0.11 + skullCavernMineLevel * 0.0005</code> for floors 100 and up(when skullCavernMineLevel >= 100). This means the chance for ore will increase by 0.05% for each floor, except between floors 10 and 100 where it increases by 0.15% each floor. This reaches 100% at floor 1780, providing the 4th region. At the crossover point of floor 10 the 2 chances are equal as the extra term is 0. This means the function is continuous. If this ore check passes it will return an ore.
    
[[File:Skull Cavern Ore Distribution.png|300px|thumb|right|Changing distribution of metal ore with floor.]]
 
[[File:Skull Cavern Ore Distribution.png|300px|thumb|right|Changing distribution of metal ore with floor.]]
If this ore check passes it will return an ore, with it first checking for iridium, then gold, then iron, then returning copper.
+
 
 +
First, if the [[Desert Festival]] is ongoing. If it is there is a (13 + [[Desert Festival#Skull Cavern|"Egg Rating"]] / 20)% chance of the node being an [[Mining#Calico Egg Node|Calico egg node]]. This will not be included in the below graphs and discussions. After that, it first checking for [[Iridium Ore|iridium]], then [[Gold Ore|gold]], then [[Iron Ore|iron]], then returning [[Copper Ore|copper]].
 
As an example, this means for a stone to be gold ore it must pass the ore check, then fail the iridium check, then pass the gold check.
 
As an example, this means for a stone to be gold ore it must pass the ore check, then fail the iridium check, then pass the gold check.
 
This means in order to get an ore, the chance for the previous ore must be less than 100%, so once iridium ore reaches 100%, no other metal ores can be made.
 
This means in order to get an ore, the chance for the previous ore must be less than 100%, so once iridium ore reaches 100%, no other metal ores can be made.
Line 124: Line 135:  
     };</syntaxhighlight>
 
     };</syntaxhighlight>
   −
[[File:Skull Cavern Diamond.png|300px|thumb|right|Changing distribution of diamond nodes with floor, luck and mining level]]
+
[[File:Skull Cavern Diamond.png|300px|thumb|right|Changing distribution of diamond nodes with floor, luck, and mining level]]
Before analysing in full, it is worth noting the impact of luck. Diamonds and Gemstones both use <code>chanceModifier</code>. As daily luck ranges from a minimum of -0.1 to a maximum of 0.125 (with special charm), and farmer level ranges from 0 to 14, the lowest this can be is -0.1, and the highest is 0.195. For diamonds this is multiplied by 0.0005 and divided by 2 making its effect range from -0.0025% to 0.004875%, or by approximately 0.007%, equivalent to 8.85 floors. For a farmer with the special charm and level 10 mining, the range is reduced to 0.005%, equivalent to 6.6 floors. This is also quite small compared to the base of 0.126% for floor 1 with 0 luck and 0 mining levels.
+
Before analysing in full, it is worth noting the impact of [[luck]]. [[Diamond]]s and Gemstones both use <code>chanceModifier</code>. As daily luck ranges from a minimum of -0.1 to a maximum of 0.125 (with [[Special Charm|special charm]]), and farmer level ranges from 0 to 14, the lowest this can be is -0.1, and the highest is 0.195. For diamonds this is multiplied by 0.0005 and divided by 2 making its effect range from -0.0025% to 0.004875%, or by approximately 0.007%, equivalent to 8.85 floors. For a farmer with the special charm and level 10 mining, the range is reduced to 0.005%, equivalent to 6.6 floors. This is also quite small compared to the base of 0.126% for floor 1 with 0 luck and 0 mining levels.
 
For gemstone ores, the range works out to be 0.044% for the entire range, or 0.033% for the reduced range; equivalent to 10.62 and 7.92 floors, and still small compared to the 0.654% at floor 1.
 
For gemstone ores, the range works out to be 0.044% for the entire range, or 0.033% for the reduced range; equivalent to 10.62 and 7.92 floors, and still small compared to the 0.654% at floor 1.
The chance for gem nodes and mystic stones don't directly use the floor, and the multiplier for the chance is used in all parts of the calculation. Now the range for averageDailyLuck/2 (0.1125) is quite large, over 20% of the base 0.5 chance, making this much more dependent upon luck. Likewise, the 14 levels from mining contribute 0.112, over 10%, but the 4 gained from food buffs only contribute 0.032, much less significant. Likewise, for Mystic Stones the contribution from luck is over 10% of the base of 1, with the mining levels having a similarly reduced impact.
+
The chance for gem nodes and [[Mining#Mystic Stone|mystic stones]] don't directly use the floor, and the multiplier for the chance is used in all parts of the calculation. Now the range for averageDailyLuck/2 (0.1125) is quite large, over 20% of the base 0.5 chance, making this much more dependent upon luck. Likewise, the 14 levels from mining contribute 0.112, over 10%, but the 4 gained from food buffs only contribute 0.032, much less significant. Likewise, for Mystic Stones the contribution from luck is over 10% of the base of 1, with the mining levels having a similarly reduced impact.
    
This can be better understood by considering the exit points.
 
This can be better understood by considering the exit points.
Line 163: Line 174:  
Which will randomly select an integer in the range [59,70), and then add 1 if it is odd.
 
Which will randomly select an integer in the range [59,70), and then add 1 if it is odd.
 
This has the effect of randomly selecting an even integer from 60 to 70 inclusive, with the integers from 60 to 68 inclusive having an equal likelihood and 70 being half as likely.
 
This has the effect of randomly selecting an even integer from 60 to 70 inclusive, with the integers from 60 to 68 inclusive having an equal likelihood and 70 being half as likely.
This is because the mineRandom.Next(a,b) will return an integer greater than or equal to a and less than b, from internally generating a random number from 0 to 1, scaling it and offsetting it to be a random decimal number from 59 to 70, and then rounding down. This means that the range 59 to just below 61 will round to 59 or 60, which is then both forced to 60; while the numbers from 69 to 70 will round to 69 and then be converted to 70, meaning 70 has half the range. This means that the chance for jade (from 70) will be one 11th of the chance to obtain a gem, and the other gems (emerald, aquamarine, ruby, amethyst & topaz) will be double that:
+
This is because the mineRandom.Next(a,b) will return an integer greater than or equal to a and less than b, from internally generating a random number from 0 to 1, scaling it and offsetting it to be a random decimal number from 59 to 70, and then rounding down. This means that the range 59 to just below 61 will round to 59 or 60, which is then both forced to 60; while the numbers from 69 to 70 will round to 69 and then be converted to 70, meaning 70 has half the range. This means that the chance for [[jade]] (from 70) will be one 11th of the chance to obtain a gem, and the other gems ([[emerald]], [[aquamarine]], [[ruby]], [[amethyst]], and [[topaz]]) will be double that:
 
       jade = (1-chanceForOre)*(1-chanceForDiamond)*chanceForGem/11
 
       jade = (1-chanceForOre)*(1-chanceForDiamond)*chanceForGem/11
 
       other = (1-chanceForOre)*(1-chanceForDiamond)*chanceForGem*2/11
 
       other = (1-chanceForOre)*(1-chanceForDiamond)*chanceForGem*2/11
Line 227: Line 238:  
|}
 
|}
 
When not being used as the x axis, the values of daily luck, mining level and floor are controlled by a variable in the left pane and are used to calculate a reference. Initially these are set to floor 100, a daily luck of 0.025 (average daily luck with special charm) and a mining level of 10.
 
When not being used as the x axis, the values of daily luck, mining level and floor are controlled by a variable in the left pane and are used to calculate a reference. Initially these are set to floor 100, a daily luck of 0.025 (average daily luck with special charm) and a mining level of 10.
 +
 +
==History==
 +
{{History|1.6|chooseStoneType renamed to createLitterObject. Additional difficulty can now be 2. [[Calico Statue|Calico statues]] introduced.}}
    
==References==
 
==References==
Line 235: Line 249:  
<ref name="dailyLuck">See <samp>FarmerTeam::AverageDailyLuck</samp> and <samp>Game1::_newDayAfterFade</samp> in the game code.</ref>
 
<ref name="dailyLuck">See <samp>FarmerTeam::AverageDailyLuck</samp> and <samp>Game1::_newDayAfterFade</samp> in the game code.</ref>
 
<ref name="whichOre">See <samp>FarmerTeam::getAppropriateOre</samp> in the game code.</ref>
 
<ref name="whichOre">See <samp>FarmerTeam::getAppropriateOre</samp> in the game code.</ref>
<ref name="chooseStoneType">See <samp>MineShaft::chooseStoneType</samp> in the game code.</ref>
+
<ref name="createLitterObject">See <samp>MineShaft::createLitterObject</samp> in the game code.</ref>
 
<ref name="whichGem">See <samp>MineShaft::getRandomGemRichStoneForThisLevel</samp> in the game code.</ref>
 
<ref name="whichGem">See <samp>MineShaft::getRandomGemRichStoneForThisLevel</samp> in the game code.</ref>
 
<ref name="stoneDrop">See <samp>MineShaft::checkStoneForItems</samp> in the game code.</ref>
 
<ref name="stoneDrop">See <samp>MineShaft::checkStoneForItems</samp> in the game code.</ref>
1,424

edits