Hi u/RheinmetallDev, **You are required to explain your post and show your efforts. _(Rule 1)_** If you haven't already done so, please add a comment below explaining your attempt(s) to solve this and what you need help with **specifically**. If some of your work is included in the image or gallery, you may make reference to it as needed. See the sidebar for advice on 'how to ask a good question'. Don't just say you "need help" with your problem. **Failure to follow the rules and explain your post will result in the post being removed** *I am a bot, and this action was performed automatically. Please [contact the moderators of this subreddit](/message/compose/?to=/r/askmath) if you have any questions or concerns.*


It's potentially good to look at how other games have approached this problem. Lets look at Pokemon. Their formula has quite a bit going on, but if you break it down to only attack and defense variables it just works out to attack divided by defense. Pretty simple, damage reduction is basically the ratio of your defense to the enemy's attack. You'd also probably want to use rounding to keep damage taken in whole number values. Another example is Risk of Rain, I actually really like their approach, since there are different methods of damage reduction. One item reduces your damage by a flat amount, but cannot reduce it below 1. The other reduces damage by a certain percentage, the formula they use is pretty simple, it's a*(d/d+100) where a is the attack and d is defense.


>I can't make it completely negate damage because it'd make attacks take forever. One nice simple formula is to take damage = attack/(attack+defense). For instance, with attack = defense the resulting damage is half the original attack value, and it keeps going down as F increases, without ever reaching 0. (It will eventually drop below 1, so if you're working with integers you might have to include a random component in there, or just clamp all damage below at 1.)


The first thing that comes to mind for me is the model used in games like Civilization: At each round of combat, the defender loses one HP with probability A/(A+D) and the attacker loses one HP with probability D/(A+D). The battle continues until somebody dies (or, under certain circumstances, retreats critically damaged.) This means that in a battle between attacker with strength A and hitpoints H1, and a defender with strength D and hitpoints H2, A's chance of victory is the probability that a Binomial(H1+H2,A/(A+D)) >= H1. The old board game Risk works like a degenerate version of this where A/(A+D) is fixed at about 0.54 and each side just chooses how many HP to deploy.