## Monster Hunter Game Probability Using Linqpad

I was playing Monster Hunter, and was trying to get a particular item for killing a monster – specifically a number of *Rathian Spikes*. There are 5 chances to get the item per kill – three of which have a drop chance of 5% and the other two with a 7% drop chance. I was wondering what the actual probability per kill would be, so I decided to make a small program in F# using Linqpad to calculate the probability.

The below formula is one that I created with the help of a coworker.

*n*is the list, and*l*is the length of the list.By building the formula into a product, I was able to use a reduce function on my list to do the calculation. Here is the final program: https://gist.github.com/dotsonjb14/efa9ddaa26eeba89d405

Because F# doesn’t have a reduce function, I needed to use a fold function. In this case, I used a fold function to achieve the same effect as a reduce function.

After the fold, I used an

*in*statement to turn the function into a single statement. The first dump is the sanity check, which should come out to 75% every time. The second dump is the actual calculation I wanted to make. In this case, the result is ~25.85%, which lets me know that I need to kill roughly four monsters to get one spike. This allows me to estimate how long it will take me to get all the spikes that I need.

While this isn’t a diffucult task to figure out on paper, having the program allows me to be more efficient in the way I do my hunts, saving me time and effort.