Cocytus Succeeder
Posts: 2184
Joined: Tuesday, 3rd February 2015, 22:05
Probability of dying on the next turn
Briefly: whenever you take an action, and there are monsters on screen, the game will calculate the probability that you would die after that action.
This is harder than it looks because a monster could torment you, and then some other monster could maul you to death. Or some monster could banish you etc. Also damage numbers in crawl combat are insane.
However, we can calculate a lower bound:
- Ignore torment, hexes, debuffs etc.
- Play out your action. (I think the game considers your action first, and only then the monsters get their turn?) For instance, if you cast a spell or swing an axe, you calculate the damage done on every monster. Do this 10000 times. In each scenario, there will be some subset of monsters still remain alive.
- For each scenario, calculate the total damage done by all alive monsters. This will include weapon damage and spell damage - modified by the chance of casting the particular spell instead of casting another spell, moving or meleeing. Do this calculation 10000 times.
- Check if total damage is more than your HP (for each 10000 trials). If yes, then increment a counter.
- Probability of death = counter / (10000 * 10000).
If the probability of your death on each successive action is p1, p2 etc. then the "total probability of you dying in the whole game" is [1 - (1 - p1) * (1 - p2) * ...]. We can get a lower bound on this number because p1, p2, ... are lower bounds on each turn.
I imagine that this lower bound could be fairly close to the actual probability. We could check, if we had a big enough sample.