Dice Calculation for Tabletop RPG
Thanks for your time.
I believe this would fit under the Calculus heading since it appears to be related to finding the maxima of a nonlinear function, though I'm not sure. I am not good at math. If I have posted in error please let me know.
Here is my question:
In the tabletop RPG Dungeons and Dragons 3.5 attacks are made using a 20-sided die compared to a target "armor class" value of the defender. If you meet or exceed the target you will hit. If you roll a 20 on the die, you will have the opportunity to hit again in which case you will deal extra damage. If you roll a 1 you automatically miss. A 20 is known as a threat, or threatening a critical.
There is an ability in the game called Power Attack. When players attack targets they have an "attack bonus." Often early in the game this is roughly +5. This ability allows you to subtract a given quantity x from your attack bonus in order to gain either x (if using a 1 handed weapon) or 1.5x (if using a two-handed weapon) as a bonus to damage if your attack is successful. This 1.0x vs 1.5x coefficient is known as the handedness multiplier.
I want to create a pocket excel spreadsheet that will auto-calculate optimal power attacks from the data I've given it about my character (it acts as my character's information sheet). It needs to take into account both the probability of a hit (or a confirmed critical after rolling a 20) as well as the damage on a hit, or a critical respectively.
So far I have done the following calculation. Does this look right?
GOAL: Find the maximum of a nonlinear equation such that y is the average damage output and x is the power attack input in amount of attack bonus points subtracted.
the damage output will be based on the following:
chance that we will hit without threatening a critical * damage that will be done in this case
chance that we will threaten * damage that will be done in this case * ratio of rolls that will confirm this critical
chance that we will threaten * damage that will be done in this case * chance that we will fail to confirm this critical
ratio of rolls that will hit * (average damage + x*handedness_multiplier)
ratio of rolls that will threaten * (average critical damage + x*handedness_multiplier*critical multiplier) * ratio of rolls that will confirm a critical
ratio of rolls that will threaten * (average damage + x*handedness_multiplier) * ratio of rolls that will fail to confirm
rolls that will merely hit = 20 - target AC - all bonuses to hit -1 for critical misses - possibilities of threats
// For anyone who is well-versed in D&D, I have simplified the equation to only count natural 20 threats, and natural 1 critical misses. Further exploration on threat ranges can come later for what I want.
let MERE_HITS = 20 - ( TARGET_AC - 1_FOR_CRITICAL_MISS - (ATTACK BONUS-x) ) - 1_FOR_NAT_20
( MERE_HITS / 20 ) * ( AVG_DAMAGE + x * HANDS_MULT )
( 1 / 20 ) * ( AVG_DAMAGE * CRIT_MULT + x * HANDS_MULT * CRIT_MULT ) * ( ( MERE_HITS + 1 ) / 20 )
( 1 / 20 ) * ( AVG_DAMAGE + x * HANDS_MULT ) * ( (20 - (MERE_HITS + 1)) / 20 )
I know this is a lot to digest, but I would greatly appreciate a more learned set of eyes. I am not a math whiz, and even if I was, I would want external input for something this complex.