Mission Impossible: Expert Mode Automated Playthrough (AFK from Pre-Hardmode to Moon Lord)

Yes, those calculations look good for determining probability of 3 bosses being fought within X day/night cycles. However, I was referring to the EV, which is more useful because it indicates how many cycles on average you'd be expected to wait before encountering all 3 bosses. Since the EV is the the probability-weighted average of all outcomes, I believe the calculation would go like this:

EV=3(1/10)^3 + 4(3C2)(1/10)^3(9/10) + 5(4C2)(1/10)^3(9/10)^2 + ... + n[(n-1)C2)(1/10)^3(9/10)^(n-3) where n is a very large number

The xCy function is the combination function. The 3, 4, 5 etc at the start of each term in the series refers to the number of day/night cycles and each of these numbers is multiplied by the probability of getting 3 mech bosses to spawn in exactly that many cycles. The probability of getting 3 boss fights in exactly n days is:

[(n-1)C2]*[(1/10)^3]*[(9/10)^(n-3)]

which simplifies to:

(1/2000)*(n-1)*(n-2)*(9/10)^(n-3)

The reason I'm using (n-1)C2 for the number of arrangements of 3 nights with boss spawns and n-3 nights (and not nC3) without boss spawns is because the 3rd boss spawn must always fall on the nth night.

So now we need to calculate this infinite sum:

EV=SUM(from n=3 to inf) n*(1/2000)*(n-1)*(n-2)*(9/10)^(n-3)

Let's bust out an online calculator:

http://www.wolframalpha.com/widget/widgetPopup.jsp?p=v&id=29c546473e1c796d6076bb18901b15e7&title=Infinite Series Calculator&theme=blue&i0=n*[(9/10)^(n-3)]*n!/(n-3)!/6000&i1=3&i2=Infinity&podSelect=&includepodid=Result&showAssumptions=1&showWarnings=1

The sum is 30, which makes sense since there is a 1/10 chance each day of getting a boss summon. In other words, the player will wait on average for 30 day/night cycles (or 12 hours) for all 3 mech bosses to spawn, assuming the calculations are correct.




Fingers crossed that you'll live the next time :).
I've still got a couple of years in school so I'm not up to this level of maths yet. It is definitely my favourite subject though, so this is really interesting to me :)

Just to muck around, I threw this together and tried to work it out ...
Code:
import math

#Combination function
def nCr(n,r):
   return (math.factorial(n))/(math.factorial(r)*math.factorial(n-r))

stringToEvaluate = ""
for i in range(3, 100):
   #Loop through this multiple times (starting at i=3, finishing at i=99)
   x = str(i) #String representation of i
   s = x + " * (nCr(" + x + ", 3) * (0.1)) ** (3 * (0.9**" + str(i-3) + ")) +"
   stringToEvaluate += s
   print(s)
   #Note: x**y is python for x^y. The ^ operator is used for XOR.
stringToEvaluate += "0" # Add a "0" to the string, to handle the extra plus at the end
print(stringToEvaluate)
print(eval(stringToEvaluate)) #Evaluate the result and print to console.

This gives me some nice-looking results like

3 * (nCr(3, 3) * (0.1)) ** (3 * (0.9**0)) +
4 * (nCr(4, 3) * (0.1)) ** (3 * (0.9**1)) +
5 * (nCr(5, 3) * (0.1)) ** (3 * (0.9**2)) +

... all the way up to 99 * (nCr(99, 3) * (0.1)) ** (3 * (0.9**96))
But, when evaluating all of these and adding together, I get 10672.056. I've tried removing the brackets (e.g. 3 * nCr(3, 3) * 0.1 ** 3 * 0.9**0), as I'm not entirely sure what the intended formula is, and I got the slightly more reasonable result of 381.2289.

What am I doing wrong? My understanding was that the result would get infinitely closer to the actual EV with each sucessive calculaation added. Since infinity seems to be a little bit big, I'm only doing 97 loops instead on the assumption that I would get close enough to infer the actual answer (e.g. 49.998).

Edit: whoops! I didn't see that you had taken it on! I didn't know wolfram could do that either :) I'll take a look at your math and learn something from it :D
Edit 2: That's making a bit more sense now that I read what you did.

I'vee been playing around with my script a bit more, and by evaluating the command on each loop I get something interesting ...
partial sum values.PNG

I think I know what to do now ...
 
Last edited:
Edit: whoops! I didn't see that you had taken it on! I didn't know wolfram could do that either :) I'll take a look at your math and learn something from it :D
Edit 2: That's making a bit more sense now that I read what you did.

Interesting - I fell into the same trap you did when I first posted, but since then I found the error and edited the post. The error is in the nCr calculation - turns out that 3,3 and 4,3 and 5,3 etc are not the right values, since the 3rd boss must always be spawned on the nth night. The numbers instead should be 2,2 and 3,2 and 4,2 etc. With the error, I got the same large value (380) you did :).

EDIT: I put the wrong wolframalpha link in the previous post. It now has the correct link.
 
Last edited:
Interesting - I fell into the same trap you did when I first posted, but since then I found the error and edited the post. The error is in the nCr calculation - turns out that 3,3 and 4,3 and 5,3 etc are not the right values, since the 3rd boss must always be spawned on the nth night. The numbers instead should be 2,2 and 3,2 and 4,2 etc. With the error, I got the same large value (380) you did :).

EDIT: I put the wrong wolframalpha link in the previous post. It now has the correct link.
Ah! Thanks! At 384 loops, I got the magical 30.0!
Thankyou very much, this has been a fun adventure! Now, I better get back to fixing these ghosts ...
 
My math is a little rusty and most of my knowledge of probability is self-taught so finding out about the EV (expected value) is an eye-opener. An EV of 30 is close to my earlier estimate of 26 and the infinite series does converge. I am still a little sketchy on why (n-1)C2 works because the the binomial probability for getting 3 successes in n trials would be (nC3)(1/10)^3 * (9/10)^(n-3) as you originally had but I'm sure that will sink in.

Hmmm... I just tried Wolfram/Alpha giving it n*(1 - (9/10)^n - n/10*(9/10)^(n-1) - n*(n-1)/200*(9/10)^(n-2)), which is the 1 - the probability of having 0, 1 or 2 successes, but it didn't converge. Oh, well. Will keep pondering this.

Ok. I get it now. With n tries, you have 3 successes and (n - 3) failures. The way you distribute those 3 successes in with the failures would be in (n-1)C2 combinations. The formula for this is similar but not the same as that for binomial probability which has to account for 4, 5, ... up to n successes.
 
Last edited:
Ok. I get it now. With n tries, you have 3 successes and (n - 3) failures. The way you distribute those 3 successes in with the failures would be in (n-1)C2 combinations. The formula for this is similar but not the same as that for binomial probability which has to account for 4, 5, ... up to n successes.

Indeed, nC3 would mean that you can distribute 3 desired outcomes among n trials in any way, but in our case one of those outcomes must necessarily happen on the nth trial because if it happens earlier then there would be no need to have the additional trials afterwards. I missed this the first time, but corrected my mistake when the EV I got was way too high.

Hmmm... I just tried Wolfram/Alpha giving it n*(1 - (9/10)^n - n/10*(9/10)^(n-1) - n*(n-1)/200*(9/10)^(n-2)), which is the 1 - the probability of having 0, 1 or 2 successes, but it didn't converge. Oh, well. Will keep pondering this.

With this calculation you're multiplying n by the probability of 3 successes up to n trials, instead of exactly n trials. In EV (i.e. average) calculations a given value for n must be multiplied by the probability of 3 successes in exactly n trials for it to serve as the probability-weight in calculating the average.
 
Wait just one minute... When the player has defeated skeletron and gets teleported to the WOF arena, a bird statue gets toggled - activating the dart traps. Isn't that statue a lot more than 2000 wire distance from the skeletron teleporter (and button)? Has the limit of 2000 wires for activation been removed from other stuffs than teleporters?
 
Wait just one minute... When the player has defeated skeletron and gets teleported to the WOF arena, a bird statue gets toggled - activating the dart traps. Isn't that statue a lot more than 2000 wire distance from the skeletron teleporter (and button)? Has the limit of 2000 wires for activation been removed from other stuffs than teleporters?

When the wire length limit was removed back in 1.2.3 it applied to everything a wire could activate, not just teleporters.
 
Another viewer tried the playthrough and discovered one more place where the run can potentially end. Plantera has hooks that deal 120 damage (+/-18) in expert mode, which I didn't even realize. In testing and in other players' runs the hooks never touched the player, just the beak, which only does a maximum of 97 damage due to the 25 defense. Getting hit by the hook should be rare since plantera makes an early bee-line for the player and the hooks usually go diagonally, but a hook did kill the player in one run. I'm not sure anything can be done to reduce the chances of that happening to 0, but getting hit by the hook should be a pretty unlikely event anyways, and even if the player is tagged by the hook there's around a 40% chance it won't inflict 100 damage or more.

Still, I could probably strip away as many blocks and background walls around the player as possible to give the hooks fewer places to grip around the player.

The other potential issue, which hasn't come up in any runs yet, is at the pillar arena where the stardust pillar appears. Oh, the stardust pillar, my autofarming bane! Its possible that the pillar ends up spawning nothing but airborne enemies over a 5 second stretch, which will cause the timer to fail to refresh and thus send the player to the next arena. This of course ends the run since the Moon Lord won't spawn at the end of the pillar chain.

There is a failsafe that I could adopt, which I actually use in my main world recursive lunar event farm. The failsafe consists of a long timer cascade at the moon lord farm that eventually sends the player back to the start of the pillar arena chain if allowed to trigger. The cascade would be around 40 minutes, since it takes 30 minutes for the Moon Lord to die. After the Moon Lord's death the Cultists respawn and thus can serve as the trigger to send the player to the victory chamber. If they fail to spawn, it's because the moon lord didn't die because one of the pillars is still around, and thus the player is send back to the pillar area once the timer cascade reaches the end.
 
In the boss arena where you fight the Eater of Worlds and such, the player is too far away from the campfire and heart lantern, and slowly loses health.
 
This is amazing. three things i noticed tho, Spazmatism is finally living up to his name, Golem is a HISMG (Highly Inaccurate Sub-Machine Golem) and Moon Lord knows how to dance
 
Back
Top Bottom