4

Here is an interesting model inspired by the game Plants vs. Zombies. A Kernel-Pult can lob either a kernel (with probability $1 - p$, dealing $1$ damage) or a butter (with probability $p$, dealing $2$ damage with stunning effect) to a zombie. (The damage is counted relative to a peashooter.) Suppose that an invincible zombie is walking in front of him (so the zombie will not die prematurely). A zombie will walk one "step" during the interval between firing two projectiles if not stunned. If the zombie is hit by a butter, then he will be unable to walk for an interval of $t$ steps (assuming $t$ is a positive integer for simplicity). If he is hit by another butter when he is already stunned, the number of unable-to-walk-steps will be reset to $t$.

The question is: What is the expected value of damage taken by the zombie within one step?

I think the possible values of damage taken within one step ranges from $1$ (one kernel) to $\infty$ (consecutive butters as much as possible). However, I can't derive the distribution behind it.

(PS: In the real-world PVZ game, $p = 0.25$, and the time interval between two projectiles is slightly randomized.)

1 Answers1

0

The projectile selection is a Bernoulli process (denote kernels by $k$ and butter by $b$). Consider the possible outcomes: either 1) you get $k$ at first hit and exit immediately (with probability $1-p$), or 2) you get $b$ and continue sampling the process until you get a subsequence $S = $ "$t+1$ kernels". I'll consider the case 2); for the total expected value, just add $1-p$.

Write the general form of a 2) outcome in terms of generating functions (similarly e.g. to this post), so every monomial of this expression (before rearranging variables in products) uniquely corresponds to some possible sequence of samples. I have $$\sum\limits_{q=0}^\infty \left ( (\sum^\infty_{i=1} b^i ) (k+\ldots+k^t)\right)^q \cdot (\sum^\infty_{i=1} b^i) k^{t+1} \qquad (*)$$ Rewriting the geometric progressions, we get $f(k,b)=\dfrac{\frac{b}{1-b} k^{t+1}}{1-\frac{b}{1-b}\frac{k^{t+1}-k}{k-1}} = \dfrac{b (1-k) k^{t+1}}{1 - b - k + b k^{t+1}}$.

Then the coefficient $C_{mn}$ of $k^m b^n$ in the generating function is the number of possible outcomes with $m$ kernels and $n$ pieces of butter: $f(k,b) = \sum\limits_{m,n = 0}^{\infty} C_{mn} k^m b^n$. Note that $C_{0n} = C_{m0} = 0$, so we can use the derivatives of $f$ to get $k \dfrac{\partial f}{\partial k} + 2 b \dfrac{\partial f}{\partial b} = \sum\limits_{m,n = 0}^{\infty} (m+2n) C_{mn} k^m b^n$. Substituting $k = 1-p$, $b = p$ into LHS, we get the desired formula for 2) (and then also add $1-p$ for the "kernel first" case 1) ).

If you also need the variance or higher moments, you can use higher derivatives, however you'll need to account for the low-degree terms that are lost after differentiation.

Notes:

  • there may be an off-by-one error due to the understanding of $t$;
  • I didn't really check my calculations;
  • there may be a shorter or less computational method (e.g. with EGFs);
  • $t$ being a positive integer is the general case, since the timer is being reset;
  • unrelated to the mathematical problem: the projectile flight time depends on the distance between the shooter and the target, and the steps in PvZ are more frequent than the projectile attacks, so there would also be a considerable Doppler effect.