Simplify the damage formula


Although the central place for design discussion is ##crawl-dev on freenode, some may find it helpful to discuss requests and suggestions here first.

Snake Sneak

Posts: 116

Joined: Monday, 2nd July 2018, 16:47

Location: United States

Post Wednesday, 13th February 2019, 21:33

Simplify the damage formula

The scope of this proposal is the initial damage calculation before AC and brand application.

The current damage formula has a lot of separate rolling, and at least one nested roll, and random rounding occurs many times. This makes the distribution complicated and pretty much impossible to visualize. I think it would be much better if we could reduce this to a uniform distribution or something very close to it. This would be much easier to visualize, as most people are familiar with the concept of dice, and would help people compare the relative values of skills and equipment. (For example, some people don't realize that strength is about as good as - or potentially, better than - slaying on characters with big weapons and high skills, and make bad equipment choices as a result.)

Here's how to achieve this: instead of calculating each bonus (skill, slaying, etc) with a roll and then adding or multiplying it to your rolled base damage, have each bonus be a deterministic addend or factor, and have each bonus be "inside" the base damage roll.

For a simple picture, the new damage formula would look something like:
  Code:
damage = 1d( randomRound( base * strBonus * skillBonus + slayingBonus ))

base = base damage of weapon
strBonus = 0.75 + strength * 0.025
skillBonus = 1 + weaponSkill * 0.02 + fightingSkill * 5/300
slayingBonus = weaponEnchantment + totalSlaying + corrosion


There are many more possible modifiers (such as might) that would be applied in the same way (either a multiplier of the base, or an addition to the multiplied base). There are some total damage modifiers (such as indirect cleave) that would be a multiplier wrapping all of the above, but still be "inside" the roll and the random round.

Random rounding would only occur once; after all modifiers are calculated and before the dice is rolled.

The resulting distribution is nearly uniform. The only way in which it differs from uniform is: the maximum value is less likely than the rest of the values, because the random round makes it so that sometimes your dice doesn't have that maximum value on it.

General version of the formula:
  Code:
damage = 1d( randomRound( product(totalDamageMultipliers) * (baseDamage * product(baseDamageMultipliers) + sum(damageBonuses)) ))

totalDamageMultipliers is a list/array including items such as the indirect cleave modifier, shadow form modifier, etc
baseDamageMultipliers is a list/array including the strength modifier and skill modifier
damageBonuses is a list/array including the enchantment modifier, corrosion modifier, starvation modifier, etc

For this message the author stormdragon has received thanks: 4
chequers, duvessa, PseudoLoneWolf, VeryAngryFelid

Ziggurat Zagger

Posts: 8627

Joined: Sunday, 5th May 2013, 08:25

Post Wednesday, 13th February 2019, 23:06

Re: Simplify the damage formula

Don't forget to do this with weapon-using monsters too.
User avatar

Shoals Surfer

Posts: 284

Joined: Friday, 19th August 2016, 21:21

Post Wednesday, 13th February 2019, 23:18

Re: Simplify the damage formula

This results in a pretty large variance. Is it a desired behaviour? How does that compared with the variance of the original formula (I mean an estimation, since like you said its awful to calculate analytically)? Maybe make it a normal dist, or some other skewed distr?
make food great again

Ziggurat Zagger

Posts: 8627

Joined: Sunday, 5th May 2013, 08:25

Post Wednesday, 13th February 2019, 23:26

Re: Simplify the damage formula

The current formula has higher variance than a uniform distribution until it applies enchantment/slaying.
User avatar

Shoals Surfer

Posts: 284

Joined: Friday, 19th August 2016, 21:21

Post Thursday, 14th February 2019, 00:24

Re: Simplify the damage formula

ah yes I seem to remember you mentioning it had a very large right tail
make food great again

Ziggurat Zagger

Posts: 4341

Joined: Friday, 8th May 2015, 17:51

Post Thursday, 14th February 2019, 07:41

Re: Simplify the damage formula

The suggested change would make it possible to give meaningful feedback to player. Something like "With your current skills and equipment increasing Strength by 1 will increase your melee damage by 5%", "With your current skills and equipment increasing Polearms skill by 1 will increase your melee damage by 7%" etc.
Underestimated: cleaving, Deep Elf, Formicid, Vehumet, EV
Overestimated: AC, GDS
Twin account of Sandman25

Ziggurat Zagger

Posts: 8627

Joined: Sunday, 5th May 2013, 08:25

Post Thursday, 14th February 2019, 09:23

Re: Simplify the damage formula

you can give that exact same feedback with the current formula too...

Vaults Vanquisher

Posts: 472

Joined: Thursday, 16th August 2018, 21:19

Post Thursday, 14th February 2019, 14:44

Re: Simplify the damage formula

I think the suggested change to weapon damage would be nice.
I would like to be able to see the number which is the max damage with the new damage formula, quite regardless of whether the new formula gets implemented, because it is twice the average damage either way.
That way I could figure out the information suggested by VeryAngryFelid, the same way I can examine the effect of equiptment, Strength and Dodging on EV.

Ziggurat Zagger

Posts: 4341

Joined: Friday, 8th May 2015, 17:51

Post Thursday, 14th February 2019, 14:57

Re: Simplify the damage formula

duvessa wrote:you can give that exact same feedback with the current formula too...


Really? I thought that the existing formula is so complicated that nobody is going to write code to calculate data for the feedback.
While with new formula it is straightforward to do.
Underestimated: cleaving, Deep Elf, Formicid, Vehumet, EV
Overestimated: AC, GDS
Twin account of Sandman25

Vaults Vanquisher

Posts: 472

Joined: Thursday, 16th August 2018, 21:19

Post Thursday, 14th February 2019, 15:27

Re: Simplify the damage formula

The old formula functions like a product of (uniformly distributed) random variables, added to a sum of random variables, with complicated rounding rules. The complicated rounding changed the distribution, but doesn't change the average. The same goes for the way the product of random variables is taken. Hence it is fairly easy to check that the original system and the formula in the OP have the same average. (Assuming the wiki is correct.)
Since they have the same average, you can give the same feedback.

For this message the author petercordia has received thanks:
duvessa

Ziggurat Zagger

Posts: 6134

Joined: Tuesday, 30th October 2012, 19:06

Post Thursday, 14th February 2019, 17:43

Re: Simplify the damage formula

VeryAngryFelid wrote:
duvessa wrote:you can give that exact same feedback with the current formula too...


Really? I thought that the existing formula is so complicated that nobody is going to write code to calculate data for the feedback.
While with new formula it is straightforward to do.

I believe that's only a small part of the issue the other parts are:

1. nobody with commit rights is convinced that it's an interesting and useful sort of feedback that needs to be given (at least to the point where they're inspired to do so)

2. average and max damage aren't directly proportional, so the feedback of just listing one or the other is incomplete, and putting both in there seems awkward and possibly confusing.

3. If someone writes code to do this, it needs to be consistently maintained to retain parity with changes to attack, which introduces later overhead and drag on future changes.

(The OP's suggestion for a formula change would at fix issue #2, and reduce the burden of #3)

I don't think it's primarily (or even tertiarily) because "it's hard to write such code, because damage is complicated" DCSS devs are generally pretty smart and capable, and the math isn't really that hard to implement in code.
Spoiler: show
This high quality signature has been hidden for your protection. To unlock it's secret, send 3 easy payments of $9.99 to me, by way of your nearest theta band or ley line. Complete your transmission by midnight tonight for a special free gift!

For this message the author Siegurt has received thanks:
duvessa
User avatar

Shoals Surfer

Posts: 284

Joined: Friday, 19th August 2016, 21:21

Post Thursday, 14th February 2019, 20:01

Re: Simplify the damage formula

I think both new and veteran players would stand to gain if they could see in a simple format the damage a weapon does. A uniform distribution really helps there. I'd be able to examine a weapon and see displayed:

"Broad axe of freezing. It does 10-25 damage + 5-8 fire per turn, given your current skills, buffs and attributes. This may be further mitigated due to your foe's defences, such as AC or resistances".

The min-max damage displayed implies a uniform distribution, and is more or less standard for other similar games, so new players would feel right at home.

Implementation is probably a big headache because of all the balancing needed: You'd want to make sure a player still, on average, damages and gets damaged in the same manner as before the changes. Statistics from before/after would need to be gathered for a set of representative scenarios, and numbers adjusted accordingly.
make food great again

For this message the author pedritolo has received thanks: 3
PseudoLoneWolf, TheMeInTeam, VeryAngryFelid

Ziggurat Zagger

Posts: 4341

Joined: Friday, 8th May 2015, 17:51

Post Friday, 15th February 2019, 05:39

Re: Simplify the damage formula

Siegurt wrote:
VeryAngryFelid wrote:
duvessa wrote:you can give that exact same feedback with the current formula too...


Really? I thought that the existing formula is so complicated that nobody is going to write code to calculate data for the feedback.
While with new formula it is straightforward to do.

I believe that's only a small part of the issue the other parts are:

1. nobody with commit rights is convinced that it's an interesting and useful sort of feedback that needs to be given (at least to the point where they're inspired to do so)

2. average and max damage aren't directly proportional, so the feedback of just listing one or the other is incomplete, and putting both in there seems awkward and possibly confusing.

3. If someone writes code to do this, it needs to be consistently maintained to retain parity with changes to attack, which introduces later overhead and drag on future changes.

(The OP's suggestion for a formula change would at fix issue #2, and reduce the burden of #3)

I don't think it's primarily (or even tertiarily) because "it's hard to write such code, because damage is complicated" DCSS devs are generally pretty smart and capable, and the math isn't really that hard to implement in code.
IMHO you have just confirmed my point. Not interested ENOUGH, does not make MUCH sense and is not EASY to support is exactly what I meant.
Underestimated: cleaving, Deep Elf, Formicid, Vehumet, EV
Overestimated: AC, GDS
Twin account of Sandman25

Vaults Vanquisher

Posts: 472

Joined: Thursday, 16th August 2018, 21:19

Post Friday, 15th February 2019, 20:26

Re: Simplify the damage formula

Just imagine, if the weapon damage distribution get characterised by a single number, as suggested in the OP, you could display ATtack / To Hit / attack DElay in the same way the game currently displays Armour Class / EVasion / SHield. I'd really like that.

As a side note, does crawl use the unrounded values of AC etc internally, in a similar way as is suggested by the OP? (ie, by using the randomly rounded value)
User avatar

Spider Stomper

Posts: 249

Joined: Thursday, 1st November 2018, 02:33

Post Tuesday, 19th February 2019, 11:23

Re: Simplify the damage formula

This would certainly be simpler than the current player damage formula, though I'm a bit skeptical about how well it would reproduce existing combat dynamics. This would make the tail quite a bit fatter, I think.

I'm skeptical about the idea overall for other reasons though. For one, you're not getting away from dice formulas, which are bad imo, you're just using simpler dice formulas. You're not incorporating AC or hit rolls into your formula either, so all that complexity remains untouched. You need to take a broader view of the problem to get to something qualitatively better than the current system. The current system is actually pretty good considering how goofy and ad hoc it looks from the formulas. (Of course it would also be good to deal with monster and player damage in a more uniform way.)

In broad terms, to get to something better than the current system, you need to stop thinking in terms of dice formulas and start thinking in terms of user-facing "statistics." For melee and ranged weapons, average and maximum damage are appropriate parameters to start with. You need to build your model out from there, trying to replicate the qualitative behavior of the current system, using easily conveyable formulas to describe the relationship between things like stats, skills, weapon properties, etc. and combat parameters like average and maximum damage. Of course, there are a lot of choices to make there and there is some potentially tricky math to work out and implement, but that, to my mind, is the general shape of the problem.
This is where mechanical excellence and one-thousand four-hundred horsepower pays off.

Elite Crawl Power Player -- Pro Advice, Superior Design Opinion

For this message the author tealizard has received thanks:
duvessa

Ziggurat Zagger

Posts: 4341

Joined: Friday, 8th May 2015, 17:51

Post Tuesday, 19th February 2019, 15:58

Re: Simplify the damage formula

Current system is bad because it results in lots of actions when you deal 0 damage. Having chance to miss is fine, having min weapon damage 0 is fine, having monsters with AC > 0 is fine but having all 3 in the same game is awful especially with non-linear damage formula of crawl. You deal 0 damage during first 10 attacks vs curse toe (carefully checking situation after every action of course) and then you kill it in 2 attacks, wtf? At least simplify damage formula (like OP suggests) and give some meaningful feedback to player how it can be improved with skills/weapon etc. if you insist on keeping it this way.
Underestimated: cleaving, Deep Elf, Formicid, Vehumet, EV
Overestimated: AC, GDS
Twin account of Sandman25
User avatar

Spider Stomper

Posts: 249

Joined: Thursday, 1st November 2018, 02:33

Post Tuesday, 19th February 2019, 18:01

Re: Simplify the damage formula

Actually, doing zero damage is good.
This is where mechanical excellence and one-thousand four-hundred horsepower pays off.

Elite Crawl Power Player -- Pro Advice, Superior Design Opinion

For this message the author tealizard has received thanks:
duvessa

Ziggurat Zagger

Posts: 4341

Joined: Friday, 8th May 2015, 17:51

Post Wednesday, 20th February 2019, 05:42

Re: Simplify the damage formula

tealizard wrote:Actually, doing zero damage is good.
10 times in a row? Why?
Underestimated: cleaving, Deep Elf, Formicid, Vehumet, EV
Overestimated: AC, GDS
Twin account of Sandman25

For this message the author VeryAngryFelid has received thanks:
njvack

Ziggurat Zagger

Posts: 8627

Joined: Sunday, 5th May 2013, 08:25

Post Wednesday, 20th February 2019, 06:17

Re: Simplify the damage formula

It's good that you aren't guaranteed to kill a monster even if it's low on health.

Ziggurat Zagger

Posts: 4341

Joined: Friday, 8th May 2015, 17:51

Post Wednesday, 20th February 2019, 06:57

Re: Simplify the damage formula

duvessa wrote:It's good that you aren't guaranteed to kill a monster even if it's low on health.


Evoking rage (probably at full HP) vs a monster (probably one at low health) and then dying to it is good? Where is the player's mistake here? Not ignoring the amulet?

I think crawl would be better if it was possible to plan risky actions instead of relying on pure luck. Especially if monsters didn't deal 0 damage so often too.
If I can deal 0-40 damage to stone giant and stone giant can deal 0-60 damage to me, I still can try to melee it exactly like I do in current crawl, there is no need to have consecutive zeroes.

Edit. I play slay the spire. That game has great design: some monsters have randomized attacks but still obey to patterns like "it is guaranteed to not use its most dangerous (or least dangerous) attacks 2 (or 3) times in a row". It allows planning while fights are still somewhat random and not repetitive.
Underestimated: cleaving, Deep Elf, Formicid, Vehumet, EV
Overestimated: AC, GDS
Twin account of Sandman25
User avatar

Spider Stomper

Posts: 249

Joined: Thursday, 1st November 2018, 02:33

Post Wednesday, 20th February 2019, 07:37

Re: Simplify the damage formula

Introducing state information into combat that is not readily apparent from looking at the screen would be bad.

One reason that zeros are good is that you want to have a diversity of combat outcomes on any given turn, even when the combatants are at very low hp as duvessa says. It's also important to match time and length scales of the dungeon to average damage so that combat movement has value comparable to attacking or using other combat effects. In order to do this in a way that produces surprising and dynamic combat, you need a lot of low damage rolls, in particular a lot of zeros. That's just math, folks.
This is where mechanical excellence and one-thousand four-hundred horsepower pays off.

Elite Crawl Power Player -- Pro Advice, Superior Design Opinion

For this message the author tealizard has received thanks:
duvessa

Ziggurat Zagger

Posts: 4341

Joined: Friday, 8th May 2015, 17:51

Post Wednesday, 20th February 2019, 07:57

Re: Simplify the damage formula

In reality this means players just hold tab because no sane person is going to pay attention to typical 5.000+ attacks during a single game. And if for some reason they do (win streaks?), that means several extra hours (1 second per attack results in 1.5 hours per 5.400 attacks)
Underestimated: cleaving, Deep Elf, Formicid, Vehumet, EV
Overestimated: AC, GDS
Twin account of Sandman25

Zot Zealot

Posts: 942

Joined: Tuesday, 4th January 2011, 15:03

Post Wednesday, 20th February 2019, 12:02

Re: Simplify the damage formula

VeryAngryFelid: I think you overestimate the time impact. For example, MrMan's streak games in the tournament are about 3-4 hours long. I do not think he stops for 1 sec for the vast majority of attacks. It is relatively rare that you have to assess situations after every attack so carefully, most monsters are very weak compared to the player. Of course, it needs a lot of expertise to tell which situations are actually dangerous amongst the sea of popcorn, but most of the time dealing 0 damage does not matter because the monster can't really damage you anyway. (One reason many people hate playing felids: they are designed to be watched after every single damn attack. Maybe you only play felids?)

I also do not agree with your evoke rage example, it seems very artificial. A good player can evoke rage with nearly 100% certainty that she will win the battle before rage runs out, and simply will use a consumable in the remaining cases. That's how rage works, and as long as you have a chance to miss with an attack it won't be really any different. Either you have random battle output, where you have a chance to lose even against the odds, or determined battle, without randomness.

You seem to imply that the output of attacks has a too large variance. I personally do not like the very rare very high damage outputs because they are rare thus hard to learn about/predict, but absolutely do not mind the frequent, thus easily learnable, low damage outputs. I also find most battle outcomes are easily predictable, so while individual attacks vary, due to the large number of attacks the battles are not really.

For this message the author sanka has received thanks:
duvessa

Ziggurat Zagger

Posts: 4341

Joined: Friday, 8th May 2015, 17:51

Post Wednesday, 20th February 2019, 12:10

Re: Simplify the damage formula

sanka wrote:VeryAngryFelid: I think you overestimate the time impact. For example, MrMan's streak games in the tournament are about 3-4 hours long. I do not think he stops for 1 sec for the vast majority of attacks. It is relatively rare that you have to assess situations after every attack so carefully, most monsters are very weak compared to the player. Of course, it needs a lot of expertise to tell which situations are actually dangerous amongst the sea of popcorn, but most of the time dealing 0 damage does not matter because the monster can't really damage you anyway. (One reason many people hate playing felids: they are designed to be watched after every single damn attack. Maybe you only play felids?)

I also do not agree with your evoke rage example, it seems very artificial. A good player can evoke rage with nearly 100% certainty that she will win the battle before rage runs out, and simply will use a consumable in the remaining cases. That's how rage works, and as long as you have a chance to miss with an attack it won't be really any different. Either you have random battle output, where you have a chance to lose even against the odds, or determined battle, without randomness.

You seem to imply that the output of attacks has a too large variance. I personally do not like the very rare very high damage outputs because they are rare thus hard to learn about/predict, but absolutely do not mind the frequent, thus easily learnable, low damage outputs. I also find most battle outcomes are easily predictable, so while individual attacks vary, due to the large number of attacks the battles are not really.


I regularly spectate MrMan during this tournament and I am sure he does not check surrounding after every attack, it is not rare to see "no targets are in range" which proves he uses tab a lot.
I don't think my evoke rage example is that artificial, I still remember a game where I was berserked in Spider Nest and killed lightly wounded Wiglaf and several spiders with 10+ attacks. The funny thing is that I was at 1 HP when it started and I had all those monsters adjacent to me. I don't think it is good that it is possible. Low damage outputs do nothing but waste our time and either make us play with tab waiting for "you're are too wounded to attack/there are no targets in range" or be killed with hubris because we stop paying attention to what is going on.
Last edited by VeryAngryFelid on Wednesday, 20th February 2019, 13:33, edited 1 time in total.
Underestimated: cleaving, Deep Elf, Formicid, Vehumet, EV
Overestimated: AC, GDS
Twin account of Sandman25

For this message the author VeryAngryFelid has received thanks:
sanka

Zot Zealot

Posts: 942

Joined: Tuesday, 4th January 2011, 15:03

Post Wednesday, 20th February 2019, 13:26

Re: Simplify the damage formula

Well, at least they result in good tales to tell! :-)

For this message the author sanka has received thanks:
VeryAngryFelid

Snake Sneak

Posts: 116

Joined: Monday, 2nd July 2018, 16:47

Location: United States

Post Wednesday, 20th February 2019, 15:16

Re: Simplify the damage formula

VeryAngryFelid wrote:Current system is bad because it results in lots of actions when you deal 0 damage. Having chance to miss is fine, having min weapon damage 0 is fine, having monsters with AC > 0 is fine but having all 3 in the same game is awful especially with non-linear damage formula of crawl. You deal 0 damage during first 10 attacks vs curse toe (carefully checking situation after every action of course) and then you kill it in 2 attacks, wtf? At least simplify damage formula (like OP suggests) and give some meaningful feedback to player how it can be improved with skills/weapon etc. if you insist on keeping it this way.

The proposal would not change this; all it would do is make it easier for the player to get a sense of the odds of 0 damage happening. The topic of whether or not 0 damage is good is irrelevant.

For this message the author stormdragon has received thanks: 2
duvessa, VeryAngryFelid

Ziggurat Zagger

Posts: 5287

Joined: Friday, 25th November 2011, 07:36

Post Friday, 22nd February 2019, 18:26

Re: Simplify the damage formula

There have been previous threads about this where someone (Was it berder? bloax? I think it started with a B) went ahead and actually wrote an anydice.com simulator which showed the distribution of the current formula. If you wanted to visualize crawl damage, that'd do it, although I'm having trouble searching for it.

Edit: I have found some things:

Melee weapon (not unarmed) damage simulator:
viewtopic.php?f=17&t=15669

Bloax crawl fork: (main feature: combat damage averaging)
viewtopic.php?f=17&t=13896

Ziggurat Zagger

Posts: 5287

Joined: Friday, 25th November 2011, 07:36

Post Friday, 22nd February 2019, 18:59

Re: Simplify the damage formula

To give an example from that old calculator, you have a 58% chance to hit for zero damage (the monster has a fairly high AC value here), but if you do hit for at least 1 damage, the most likely amount you hit for is either 7 or 8 damage. Yet the max damage that can be done goes all the way up to 64. But any hit over 40 is so rare as to basically not exist.

The exact code there is of course out of date, and some things (like strength/dex weighting) have been removed. I think it was also before the multiplier for strength got buffed. In short, lots of little things have changed, but I think the overall big picture, and crawl damage being fairly heavily skewed to the left, are still true to this day.

Ziggurat Zagger

Posts: 4341

Joined: Friday, 8th May 2015, 17:51

Post Saturday, 23rd February 2019, 19:47

Re: Simplify the damage formula

tasonir wrote:To give an example from that old calculator, you have a 58% chance to hit for zero damage (the monster has a fairly high AC value here), but if you do hit for at least 1 damage, the most likely amount you hit for is either 7 or 8 damage. Yet the max damage that can be done goes all the way up to 64. But any hit over 40 is so rare as to basically not exist.

IMHO it proves that current distribution is rather bad and there should not be preserved when simplifying the damage formula.
Underestimated: cleaving, Deep Elf, Formicid, Vehumet, EV
Overestimated: AC, GDS
Twin account of Sandman25

Shoals Surfer

Posts: 323

Joined: Tuesday, 11th December 2018, 19:14

Post Tuesday, 26th February 2019, 21:05

Re: Simplify the damage formula

tasonir wrote:To give an example from that old calculator, you have a 58% chance to hit for zero damage (the monster has a fairly high AC value here), but if you do hit for at least 1 damage, the most likely amount you hit for is either 7 or 8 damage. Yet the max damage that can be done goes all the way up to 64. But any hit over 40 is so rare as to basically not exist.

The exact code there is of course out of date, and some things (like strength/dex weighting) have been removed. I think it was also before the multiplier for strength got buffed. In short, lots of little things have changed, but I think the overall big picture, and crawl damage being fairly heavily skewed to the left, are still true to this day.


Getting some hit > 40 in that example has a bit more than .3% chance of happening. Across a 3 rune game we should expect to see such an outcome happening several dozen times, depending on build type it could be significantly more or less (player might swing a weaker weapon more times, similarly seeing more enemy attacks = more odds of an outlier hit).

I don't mind 0 damage hits though. I'm all for more intuitive representation of expected average damage by players/monsters. This lets a diligent but relatively new player make threat assessments closer to experienced players if they take the time to consider each enemy on screen + potential adds.

Return to Game Design Discussion

Who is online

Users browsing this forum: No registered users and 4 guests

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.