Need help developing probability calculator for a game

In summary, the conversation discussed the goal and variables of a game where players must reduce their opponent's life points to 0 before their own. The conversation also mentioned the use of formulas and probability distributions to calculate the probability of winning. It was suggested to use a computer simulation to generate the numbers and solve the problem. The use of linear interpolation was also mentioned as a possible approach.
  • #1
Firefight
6
0
The goal of this game is to get your opponents life points down to 0 before he gets yours down to 0. You take turns hitting each other until one persons health is at 0.

The variables are:
Attack (accuracy of hitting instead of missing)
Strength (how high you can hit)
Defense (determines opponents hit / miss ratio)
Life points (How much health of yours is to take away.

Now, I'm going to leave the formulas of the game out. But usually, you miss around 30% of the time.

Out of the times you do hit, a random number is generated between 1 and your max hit determinant on your strength. A common max hit is 8, so the hitting range would be 1-8.

Now, let's assume that we have already calculated both opponents hit/miss ratio and max hit and that we know their life points.

The average number of hits the match will last is easy to calculate. However, my goal is to determine the probability of each player winning.

Assume P1:
Misses 35% of the time
Has a hitting range of 1-8
Life points are 60
and P2:
Misses 30% of the time
Has a hitting range of 1-10
Life points are 55

So, P1 has to hit a total of 55 or more damage against P2 before P2 hits a total of 60 damage against P1 for P1 to win. What is the probability of P1 winning?

I've thought about ways to do this, and I imagined that we had two overlapping probability distributions of the number of turns it would take P1 to hit 55, and P2 to hit 60.

If we knew these distributions, we could calculate the % chance of either one of them winning with relative ease. The hard part for me is getting the probability distributions.

Any insights on how to do this?
 
Last edited:
Physics news on Phys.org
  • #2
The model for this is a two-dimensional random walk with orthogonal absorbing boundaries. If the life points of the two players are represented as (x, y) then there is a probability distribution of how this vector changes each move. A normal analytic approach is to set up some recurrence relations to represent these transition probabilities and try to solve them using generating functions.
In practice this can get quite messy; a more practical approach may be just to generate the numbers in software, maybe with a spreadsheet. Generate the numbers starting at (x, 0) and (0, y), working up.
 
  • #3
haruspex said:
The model for this is a two-dimensional random walk with orthogonal absorbing boundaries. If the life points of the two players are represented as (x, y) then there is a probability distribution of how this vector changes each move. A normal analytic approach is to set up some recurrence relations to represent these transition probabilities and try to solve them using generating functions.
In practice this can get quite messy; a more practical approach may be just to generate the numbers in software, maybe with a spreadsheet. Generate the numbers starting at (x, 0) and (0, y), working up.

haruspex is correct.

His suggestion is most definitely your best bet, and if you're having to ask for help with this (I mean no disrespect) your only bet.

Please read more here.
 
  • #4
Use a computer simulation

I once had a very complex three dimensional problem, where I needed to estimate the error distribution, which depended on the number of samples and geometrical factors. So I made an linear approximation of the geometrical factors, and scaled the distribution by k(n)/sqrt(n).
I then applied a rather massive computer simulation, and simply calculated the average factor k(n) for n=(3,4,5,6,7,8,9). In the setup the distribution is non-linear, so I have no clue if it is even possible to calculate the k(n) analytically.
In any case your problem should be easy to solve by a computer simulation, where you may extend simulation results by an interpolation of results as a function of an interesting parameter.

Bo at TRNG98.se
 
  • #5
If all 6 parameters (max hit, hit probability, life for both players) are variable and you are interested in a rough approximation ("is it a good idea to fight this player?"), I would just simulate 100 or 1000 battles and check how often P1 wins.
This is not too time-consuming if your values are typical and if you don't have to do this for thousands of battles at once.
 
  • #6
There is a good chance that your input parameters has some distribution, so they are not all (all combinations of) equally probable. You can focus your computer run on frequent alternatives. I would then consider a direct search for most close simulations, compared to the actual case. Try a linear (multi-dimensional) interpolation between closest computer runs and the actual case.
Bo at TRNG98.se
 

1. What is a probability calculator for a game?

A probability calculator for a game is a tool that helps determine the likelihood of a certain outcome or event occurring in a game. It takes into account the different variables and factors involved in the game to provide an estimate of the probability of a specific outcome.

2. How do you develop a probability calculator for a game?

Developing a probability calculator for a game involves understanding the rules and mechanics of the game, identifying the variables and factors that affect the outcome, and using mathematical formulas and algorithms to calculate the probabilities. It also requires testing and refining the calculator to ensure accuracy.

3. Why is a probability calculator important for a game?

A probability calculator is important for a game because it can help players make informed decisions and strategize their gameplay. It also adds an element of fairness and transparency to the game by providing a mathematical basis for the probabilities rather than relying on chance or luck.

4. What factors should be considered when developing a probability calculator for a game?

When developing a probability calculator for a game, factors such as the game rules, player actions, random chance, and any special mechanics or bonuses that affect the outcome should be taken into account. It is also important to consider the level of complexity and accuracy desired for the calculator.

5. Can a probability calculator be used for any type of game?

Yes, a probability calculator can be used for any type of game as long as the rules and variables are well-defined and understood. It can be applied to board games, card games, video games, and even sports and gambling activities.

Similar threads

  • Calculus and Beyond Homework Help
Replies
1
Views
1K
  • Calculus and Beyond Homework Help
Replies
8
Views
2K
  • Calculus and Beyond Homework Help
Replies
1
Views
913
  • Set Theory, Logic, Probability, Statistics
Replies
1
Views
1K
  • Set Theory, Logic, Probability, Statistics
2
Replies
41
Views
3K
  • Set Theory, Logic, Probability, Statistics
Replies
4
Views
1K
  • Precalculus Mathematics Homework Help
Replies
18
Views
2K
Replies
9
Views
985
  • Set Theory, Logic, Probability, Statistics
Replies
5
Views
897
Back
Top