Probability of single result over repeated chances

Skye Veran

New member
Joined
Jul 17, 2014
Messages
2
Hi there! I'm 24 years old and currently off-and-on working on programming a video game as a side project. It's been quite a while since I've had a math class and, though I've been able to dredge up most of what I need in terms of programming calculations, this one is eluding me.

Basically I need to know the probability of a given action over a number of frames (a "frame" is a time period of 1/60th of a second, the fixed step in which a game is processed) with a given percentage per frame of the action being initiated.

As an example:

EnemyA has a 3% chance to initiate an attack each frame. Over 60 frames, what is the percent chance that it will initiate this attack?

I can guess 3/100 and 60 are used, but I can't figure out how to properly use them in this situation. Multiplying 3/100 by 60 seems (very) incorrect, and I just don't know how to work out the numbers otherwise.

Any help highly appreciated, preferably with the most efficient way of solving this so I can do it quickly for future calculations. Thanks! =)
 
Are you asking "What is the probability of a attack any time in the first 60 frames?" or "What is the probability of the first attack on the 60th frame"

The probability that an attack will occur in the first 60 frames is 1 minus the probability of no attack. If the probability of an attack in one frame is 0.03 then the probability there is not an attack in that frame is 0.97 so the probability of no attack in the first 60 frames was \(\displaystyle 0.97^{60}\). The probability of an attack in the first 60 frames is \(\displaystyle 1- 0.97^{60}\).

The probability that the attack happens in the 60th frame is the probability that the attack does NOT occur in any of the first 59 frames but does occur in the 60th frame. That is \(\displaystyle (0.97)^{59}(0.03)\).
 
Last edited by a moderator:
The probability that an attack will occur in the first 60 frames is 1 minus the probability of no attack. If the probability of an attack in one frame is 0.03 then the probability there is not an attack in that frame is 0.97 so the probability of no attack in the first 60 frames was \(\displaystyle 0.97^{60}\). The probability of an attack in the first 60 frames is \(\displaystyle 1- 0.97^{60}\).
This is exactly what I needed! Thank you very much!
 
Top