The math of fishing for treasure...

Rahnee

Planter
So, in my current active farm, a Meadowlands farm, I have an awful lot of sheep that I want to give animal crackers to. Since the best way to get those is fishing for treasure chests, I've spent a few days luck-fishing, with pirate profession and everything. Long story short, it inspired me to work through the math to figure out the most efficient combination of bait and tackles; to start I sort of naively just went with magnet bait, one treasure hunter, and one dressed spinner.

When I actually did the calculations based on the info on the wiki, though, the results surprised me. If I did the math right, by far the best way to get the most chests is with two dressed spinners and deluxe bait. The former didn't really surprise me since the treasure hunter perk is so low, but the latter did. It does make sense though since magnet bait gets you an extra 15% chance, whereas the extra boost you get (on average of course) from additional bites is 17% (again, going by the wiki, it's a 67% boost vs no bait versus a 50% boost).

Things like the pirate profession, luck buffs, daily luck, chance for golden chests, etc. all interact with the result linearly, so all being the same those don't affect the outcome and I just calculated average number of chests per hour.

Posting here because I'm curious if anyone else has done the exercise, and if so if there's a flaw in my calculations. The only thing I didn't fold in was the 25% mod from "first bite in the water" because I wasn't particularly sure how that's implemented...
 

Lothengriol

Planter
I started calculating these problems in Excel so I could be sure the math was coming out right. Or more sure, anyway...
These are the values I'm getting for now, which means all other things being equal, Deluxe Bait outclasses Magnets when using Dressed Spinners whether or not you have the Pirate profession. The curves show the ranges of values that can occur for delay times before a bite for each of the two scenarios being compared to each other. Calculating the areas under the curves gives a fair approximation of the average stats involved (green rectangle). I'm happy to answer any questions you have on the math I've done for this, so far the sheet accounts for every variable shown in the red and blue rectangles (those are drop-down menus). I'll make the sheet do more and eventually release it, but these are pretty cool preliminary results. Thank you for the inspiration!
Magnet & 2 Dressed Spinners outclasses Deluxe Bait & 2 Spinners when both have the Pirate Profession

Magnet & 2 Dressed Spinners outclasses Deluxe Bait & 2 Spinners when neither have the Pirate Profession
 

Rahnee

Planter
I started calculating these problems in Excel so I could be sure the math was coming out right. Or more sure, anyway...
These are the values I'm getting for now, which means all other things being equal, Deluxe Bait outclasses Magnets when using Dressed Spinners whether or not you have the Pirate profession. The curves show the ranges of values that can occur for delay times before a bite for each of the two scenarios being compared to each other. Calculating the areas under the curves gives a fair approximation of the average stats involved (green rectangle). I'm happy to answer any questions you have on the math I've done for this, so far the sheet accounts for every variable shown in the red and blue rectangles (those are drop-down menus). I'll make the sheet do more and eventually release it, but these are pretty cool preliminary results. Thank you for the inspiration!
View attachment 41599
View attachment 41601
This is great!! I also used a spreadsheet but I was lazy and couldn't be bothered to turn on my computer, so I was doing it a bit haphazardly on my tablet in Google sheets. I got a slightly different number for chests/hour for your top scenario 1, but that's likely because I didn't fold in the 'first bite' but did fold in daily luck and notional luck buffs. What is the 'special tile' indicator for? I must have missed something on the wiki maybe.

I'm curious on the plots ... since spinners lower the maximum delay time, they can't really go up to 30 seconds. Or is that the point of inflection where the fish and/or chests max out? I also may be reading the plots wrong but it seems like the fish per hour should have a negative derivative as a function of delay (more delay -> fewer bites per time) ... ? Not meant to be critical, definitely, I'm just a nerd and I like to understand things 🤓
 

Lothengriol

Planter
The 'special tile' option is for bubbles or a frenzy in the water. Bubbles decrease the bite time by a factor of four and frenzies by a factor of two.
Special Tile option, showing options for Bubbles, Frenzy, and None.

The plots are necessary for how the whole bite delay is calculated. It starts with a random number from 0.6 to 30.0, and that's what's shown on the x-axis. Then the output is determined by the bite delay function itself, whose variables are chosen by the options for each scenario. So the average height of the curve is effectively the average bite delay for all possible inputs (0.6 to 30.0). Here's how it looks with First Bite set to "No":
Erroneous plots, but accurate numerical data: Deluxe Bait & 2 Dressed Spinners vs. Magnet bait & 2 Dressed Spinners, with First Bite deselected.  Magnet bait gets much more fishing treasure chests (26.32 vs. 18.57) while Deluxe Bait gets slightly more fish (61.91 vs. 58.49).

The Catch Times graph shows the function output catch times that are generated for each input (0.6 to 30), it flatlines at 0.5 seconds because the fishing function selects 0.5 seconds as the lower limit for its outputs.

Thanks to your comment on derivatives, I realized that I inverted the values of the Initial Delay Value column for a no-longer-useful reason, and that inverted column resulted in inaccurate graphs for the second and third subplots. Thank you for pointing that out! For the sake of clarity I've also renamed the x-axis from "Delay" to "Initial Delay Value". Hopefully more sense can be made out of this now that it's more sensible:

Plotting errors fixed, numerical data remains accurate: Deluxe Bait & 2 Dressed Spinners vs. Magnet bait & 2 Dressed Spinners, with First Bite deselected.  Magnet bait gets much more fishing treasure chests (26.32 vs. 18.57) while Deluxe Bait gets slightly more fish (61.91 vs. 58.49).


Also, as difficult as it may be to believe from someone else who's making Excel spreadsheets for Stardew Valley game mechanics, I am also a nerd who likes understanding things. :laugh:
Luck is on my to-do list for the spreadsheet, so I'll start on that later today.
 

Rahnee

Planter
renamed the x-axis from "Delay" to "Initial Delay Value"
Ahhh, makes sense! I see now how we've actually implemented it differently - I interpreted the wiki rules to indicate that a spinner would actually change the range of the distribution (which I'm also assuming is a uniform distribution) before the "initial" random value was realized, so it makes sense we'd have different numbers. Now I'm curious I'll have to go look at the source code, and if you've done that already then your way is correct. Interesting that the upshot (deluxe bait wins over magnet) is the same!

Yes the plots do make more sense now 😄.

I am also a nerd who likes understanding things. :laugh:
Not hard to believe at all! I love doing the figuring of stuff like this 😁
 

Lothengriol

Planter
Now I'm curious I'll have to go look at the source code, and if you've done that already then your way is correct. Interesting that the upshot (deluxe bait wins over magnet) is the same!
I'll have to look at the source code too, but for now that's delayed by my Stardew Valley machine being in for repairs. In the meantime I've been working on that spreadsheet. I believe at this point all variables are accounted for the results I'm tracking. The Magnets do outperform Deluxe Bait for Treasure Chests, all other things being equal. And below, Deluxe Bait and two Dressed Spinners with Magic Rock Candy, Qi-seasoned Ginger Ale, and a +3 Luck Desert Festival food (any of them gives equal effect) still lose out to Magnets and two Dressed Spinners alone.
Illustration of above text.

Note that the red curves are for the Magnet scenario while the blue curves are for the Deluxe Bait scenario.

From here I'll implement the loot tables, if I can!
 

Rahnee

Planter
I'll have to look at the source code too,
Oookay, so I did finally get around to getting what I needed on my computer to decompile and look at the source code. I was right - the maximum bite time of 30 seconds is modified by fishing level and any spinners (dressed spinner or spinner are the only tackle that modify this) before the random number is drawn.

Then the resulting random number is modified by bait. Then that result is 'capped' on the low end to 0.5 (actually it's 500, all the calculations are done in milliseconds) at the end of the calculateTimeUntilFishingBite method of the FishingRod object.

And actually, the bite time modification from the special tiles you mention (which I totally forgot about, so thanks for the reminder!) happens after that max is taken ... it happens inside the DoFunction method right after the calculateTimeUntilFishingBite method is called. So actually the true minimum bite time a player could experience is notionally 0.125 seconds - if the random number happened to be low and you landed the bobber in a frenzy. I actually haven't incorporated the special tile or luck of any kind into my computer spreadsheet yet, but in the magnet vs deluxe it shouldn't matter.

So ... I dunno what you've done to get deterministic values up to thirty seconds ... 🤔? Rather than do a line plot like you I made a 2000-element array of random draws that follows the above algorithm and calculated the average and stdev of that (I work with statistics a lot and actually that number seems low to me, but I didn't want to break the spreadsheet). I actually got that magnet versus deluxe bait comes out pretty much the same. If either is better it's so slightly it probably doesn't matter.

Two realizations so you can see how close they are ... sadly OnlyOffice (I don't have Excel at home) doesn't do histograms, but here's scatter plots so you can see the range:
stardew_fishing_deluxebait.png

stardew_fishing_magnet.png
 

Rahnee

Planter
Oh I forgot to mention, too ... it seems like there's a discrepancy between the code (at least, whatever it is that I've decompiled, it happens to be a GOG install) and the wiki regarding the effectiveness of spinners. The wiki says 3.75 seconds / 7.5 seconds for normal / dressed spinners, but the source code has a -5000 for the former and a -10000 for the latter (5 and 10 seconds respectively). ????
 

Lothengriol

Planter
Fascinating! I was assuming a flat distribution across 0.6 to 30 seconds as per the wiki's line,
The fish bite time measures the amount of time that passes before a fish bites once the fishing rod is in the water. This base time is a random number between 0.6 and 30 seconds.
I assumed that distribution was the principal input to the overall bite time equation, so I graphed that domain of bite time inputs against the bite time equation's outputs for each input. From those tables, the results get averaged out into the final numbers of Fish/Chests per hour.
1791084030979.png

So from what you're saying, instead of initially being drawn from [0.6, 30] the domain is reduced by any maximum bite time reductions (bait, fishing level)? Which here would mean that with Dressed Spinners (using your newfound GOG decompile value) it'd be reduced to [0.6, 10] and the random number is then drawn from that range. Is that correct? I'm looking forward to revising my calculations with what you've found! I agree that the special tiles shouldn't matter for this; I included them with the dream of eventually arriving at some form of complete fishing calculator spreadsheet.

Rather than do a line plot like you I made a 2000-element array of random draws that follows the above algorithm and calculated the average and stdev of that (I work with statistics a lot and actually that number seems low to me, but I didn't want to break the spreadsheet).
My logic behind the deterministic approach is that we don't need to draw randomly when we are already assuming the distribution. Any array of random draws will be fundamentally noisier than the function from which they originate. Of course, we could be wrong about that distribution. We've been assuming it was flat, but this is fishing, after all: it might be a poisson distribution! Another thing to check in the code.

In other news, my Stardew Valley machine is operational again, but its internal drive was replaced so I need to figure out the decompiling process again. I don't think I saved those files across the move. I'd trust your version to have the same values as mine, but it's interesting that they differ from the wiki. My Stardew Valley copy is from Steam so we'll be able to compare them on that front. What did you use for decompiling? Also, those are some fun visualizations. I wonder how much you'd have to torment a spreadsheet program in order for it to display a Power Spectral Density diagram!
 

Rahnee

Planter
it might be a poisson distribution
🤣🤣🤣🤣🤣🤣🤣🤣🤣🤣

then drawn from that range
Yes exactly! It's just an order of operations thing but definitely makes a difference. Though only spinners and fishing level, the bait mods come after.

torment a spreadsheet program
I actually found a FREQUENCY function that may do the trick, but I'm actually pondering just switching to something written in Python... I'm halfway decent with spreadsheets but not really expert, and I found myself severely missing Numpy and matplotlib. Your sheet definitely looks nicer to use haha!

I used a VS Code extension of ILSpy.
 
Last edited:

Terdin

Farmer
Two realizations so you can see how close they are ... sadly OnlyOffice (I don't have Excel at home) doesn't do histograms, but here's scatter plots so you can see the range:
Hmm... Seems like the amount of chests in an irl hour is close to the same with the two different baits, but you'd get a lot more fish (and money) from the combo with deluxe bait in addition to having a bigger bar and thus a better shot at catching the fish+chest.
 

Rahnee

Planter
Hmm... Seems like the amount of chests in an irl hour is close to the same with the two different baits, but you'd get a lot more fish (and money) from the combo with deluxe bait in addition to having a bigger bar and thus a better shot at catching the fish+chest.
Hmmm, true ... and actually in the past I've gone with targeted bait during one of these sessions even though it's definitely not max efficiency, but just to catch a lot of something I need for cooking (e.g. sea cucumbers for lucky lunches)...
 
Top