Winning a battle

51 Views Asked by At

Given 2 game characters with a Max Damage (abrv. as max) and Hitpoints (abrv. as hp):

Character 1: max1, hp1

Character 2: max2, hp2

These characters go into battle and attack each other. At each turn, both characters hit each other at the same time for a uniformly distributed random integer between 0 and Max Damage (0 <= hit <= Max Damage). The characters' Hitpoints is decreased by the opponents hit. The battle finishes when one or both of the characters have Hitpoints <= 0.

Now, given max1, hp1, max2, hp2, is there a function that will determine the probability of character 1 winning?

1

There are 1 best solutions below

0
On BEST ANSWER

I doubt there's a compact formula in terms of max1, max2, hp1, and hp2. The markov-chains tag suggests that you're thinking this can be analyzed as a finite-state absorbing Markov chain. That's certainly true, but you can uncouple the two contestants and get a simpler model.

This is a sort of random walk for each contestant. Take character 1, for example. He stats at the point hp1 on the $x-axis,$ and each turn walks $0,1,...,max2$ units towards the origin, where the size of the step is selected uniformly at random. When he get to or beyond the origin, he stops. You can easily compute the probability distributions of the number of steps it takes for him to finish the walk.

Do the same for character 2. Now with both distributions in hand, it is an easy matter to compute the probabilities of winning. (I am assuming all probabilities are computed numerically, preferably with a computer.)