PDA

View Full Version : Victory probability by simulating a D&D E5 encounter a few thousand times...



Mastocles
2017-09-27, 03:23 PM
Some time back I wrote a script that thanks to a lot of feedback became an ever changing online tool.
I posted about it here ages back, but now I find myself having to move servers (Openshift 2 > 3 migration) and have a new domain: dnd.matteoferla.com.

The tool uses a Python script that simulates the same encounter over and over (https://github.com/matteoferla/DnD-battler). It has a database of all the non-copyrighted monsters and one can input one's party of heroes or mod a monster. For example a few people have simulated a good tarrasque vs. evil tarrasque with comical names.

The main aim is to determine how doable an encounter actually. The hardness scale in the rulebook is far from a TPK and this simulator is generally spot on when converted into real played encounters *.
With the basecode, I did some analyses such as confirming that a d7+d5 weapon is the same a 2d6. Although I keep meaning to analyse the monster power spread thanks to the cool database of monsters (https://github.com/matteoferla/DnD-battler/blob/master/beastiary.csv) a user kindly wrote for me.

Obviously, it is not perfect.

Both the monsters and the heroes play with a preset wise tactic —no monster comical dumbness or diva munchkin character antics
It does not use a 2D grid (discussed at the site and at the github page).
Unique rules needs to be hardcoded

I have been asked whether I will implement a machine learning/genetic algorithm to improve the tactics, but it turns out that point 1 is actually pretty major. While point 3 would require years of coding for every single splatbook magic ring or hoverboard stolen from an incursion into a D20 Modern dimension.

But people seem to like it. :)

* I have had an email or two about this: a 50% victory probability is for 50% chance of a TPK, not that on average 50% of the party is KO, in fact the latter figure will be higher for vanilla players vs. vanilla monsters.

qube
2017-09-27, 03:38 PM
an oddity ...


{"name":"John","base":"human","alignment":"LG","hp":"60","ac":"15","initiative_bonus":"2","attack_parameters":"[['club',5,0,8]]","healing_spells":"0","healing_dice":"8","healing_bonus":"2","str":"12","dex":"13","con":"15","int":"14","wis":"10","cha":"8"}]


loses all fights against 4 aps, with





Combattant

John



Team

LG



avg damage

-0.52



avg hits

0.21



avg misses

2.66



avg rounds

0.83






considering, as far as I understand he's attacking with a +5 to attack, 0+1d8 damage ... I'd say kudos to John for being able to do negative damage?

Saeviomage
2017-09-27, 07:33 PM
an oddity ...


{"name":"John","base":"human","alignment":"LG","hp":"60","ac":"15","initiative_bonus":"2","attack_parameters":"[['club',5,0,8]]","healing_spells":"0","healing_dice":"8","healing_bonus":"2","str":"12","dex":"13","con":"15","int":"14","wis":"10","cha":"8"}]


loses all fights against 4 aps, with





Combattant

John



Team

LG



avg damage

-0.52



avg hits

0.21



avg misses

2.66



avg rounds

0.83






considering, as far as I understand he's attacking with a +5 to attack, 0+1d8 damage ... I'd say kudos to John for being able to do negative damage?

Is the space in "attack_parameters" present in the source, or did you misformat? If it is, then that's probably the issue.

Mastocles
2017-09-28, 04:34 PM
The value is avg hp at the end of the battles. As he loses he will be negative.
There is an unfixed bug IIRC that if a creature has such poor initiative than does not get at all a turn ever a division by zero happens and is caught but badly.
The online version of the code runs with the parameter that controls who they want to target (TARGET variable) set to 'enemy alive weakest', which if changed to 'ally alive weakest' has odd comical effects, and as it basically is a race for which team can kill themselves fastest, results in some odd values.

Mastocles
2017-09-28, 04:37 PM
Is the space in "attack_parameters" present in the source, or did you misformat? If it is, then that's probably the issue.

Yes, that will not be read properly with a space. But if you add a monster or parameter that makes no sense it will default to commoner or its kit.