prkill - script to calculate %-to-kill
Moderator: Forum Moderators
prkill - script to calculate %-to-kill
Here is a a perl script to calculate exact probabilities that units A and B kill each other during a skirmish. A is the attacker, while B defends.
prkill calculates the joint probability function of the number of hitpoints each unit has remaining after each swing. After the last swing, the probabilities that A kills B, B kills A, and both survive are then printed. The joint probability function is also printed (the hitpoints of A are along the X axis, of B along the Y axis), unless neither unit is likely to survive. The output should be identical to the earlier versions (pre-1.9), which used the binomial distribution of number of hits, but couldn't handle "drain". The new method is currently slower for units with many hitpoints, but is more general and hopefully easier to understand.
The method in prkill version 1.5 is used by the game currently (since 0.9.1+cvs). This is available in-game from the "Damage Calculations" option in the Attack menu. The new method in version 1.9 is scheduled to be implemented in-game but only after 1.0 is released.
Please note that the in-game display will not show these statistics if one of the units has drain, or if one of the units has slow on its attack and the skirmish involves berserk, since these cases are not properly dealt with yet. The script has the same limitation on "berserk+slow", but it does now support drain.
For each of the two units involved in the skirmish, you need to specify commandline options for %-to-hit, number of swings, damage per swing (you will need to modify the base damage by the time of day and any resistances/vulnerabilities against the given damage type), and the hitpoints each unit has before the skirmish. You can also specify if "berserk" is active for this skirmish, and if B has firststrike active during this skirmish (ie. B has firststrike on this attack type but A doesn't). In addition, you can specify if either A or B has drain on its attack (or both do).
Run prkill --help to see the list of command line options.
As an example, to calculate the probabilities for a a slightly injured Ulfserker attacking a Thief, both standing in grassland during the day: And here is a Wraith attacking an Ulfserker, both on mountains at dawn:
Finally, the same situation but the Wraith against an injured Goblin Spearman:
History:
1.1 initial release
1.2 fixes a problem in reduce() which gave incorrect results for Troll vs. Revenant at night, but most results should still be very similar
1.3-1.4 unreleased
1.5 simplified calculations, made option names more rational, added --help, added firststrike support
1.6-1.8 unreleased
1.9 changed to new method, now supports drain
Planned is pod documentation (ie. a man page), and support for "berserk+slow", which is not currently handled. Possible enhancements include calculating the damage-per-swing based on time of day, alignment, leadership, resistances and specials like backstab or charge: but don't hold your breath, this is likely to be a separate script.
prkill calculates the joint probability function of the number of hitpoints each unit has remaining after each swing. After the last swing, the probabilities that A kills B, B kills A, and both survive are then printed. The joint probability function is also printed (the hitpoints of A are along the X axis, of B along the Y axis), unless neither unit is likely to survive. The output should be identical to the earlier versions (pre-1.9), which used the binomial distribution of number of hits, but couldn't handle "drain". The new method is currently slower for units with many hitpoints, but is more general and hopefully easier to understand.
The method in prkill version 1.5 is used by the game currently (since 0.9.1+cvs). This is available in-game from the "Damage Calculations" option in the Attack menu. The new method in version 1.9 is scheduled to be implemented in-game but only after 1.0 is released.
Please note that the in-game display will not show these statistics if one of the units has drain, or if one of the units has slow on its attack and the skirmish involves berserk, since these cases are not properly dealt with yet. The script has the same limitation on "berserk+slow", but it does now support drain.
For each of the two units involved in the skirmish, you need to specify commandline options for %-to-hit, number of swings, damage per swing (you will need to modify the base damage by the time of day and any resistances/vulnerabilities against the given damage type), and the hitpoints each unit has before the skirmish. You can also specify if "berserk" is active for this skirmish, and if B has firststrike active during this skirmish (ie. B has firststrike on this attack type but A doesn't). In addition, you can specify if either A or B has drain on its attack (or both do).
Run prkill --help to see the list of command line options.
As an example, to calculate the probabilities for a a slightly injured Ulfserker attacking a Thief, both standing in grassland during the day:
Code: Select all
prkill -p 0.4 -P 0.7 -n 4 -N 3 -d 5 -D 4 -h 36 -H 24 -x
A: 36hp, 5-4, B: 24hp, 4-3 berserk
Pr[A kills B] = 81.3392%
Pr[B kills A] = 18.6608%
Pr[both survive] = 0.0000%
Code: Select all
prkill -p 0.5 -P 0.5 -n 4 -N 4 -d 5 -D 2 -h 25 -H 40 -x
A: 25hp, 5-4 (2 drain), B: 40hp, 2-4 berserk
Pr[A kills B] = 99.9449%
Pr[B kills A] = 0.0550%
Pr[both survive] = 0.0000%
Code: Select all
prkill -p 0.4 -P 0.5 -n 4 -N 3 -d 7 -D 4 -h 25 -H 14 -r -y
A: 25hp, 7-4 (3 drain), B: 14hp, 4-3 firststrike
Pr[A kills B] = 52.4800%
Pr[B kills A] = 0.0000%
Pr[both survive] = 47.5200%
1.1 initial release
1.2 fixes a problem in reduce() which gave incorrect results for Troll vs. Revenant at night, but most results should still be very similar
1.3-1.4 unreleased
1.5 simplified calculations, made option names more rational, added --help, added firststrike support
1.6-1.8 unreleased
1.9 changed to new method, now supports drain
Planned is pod documentation (ie. a man page), and support for "berserk+slow", which is not currently handled. Possible enhancements include calculating the damage-per-swing based on time of day, alignment, leadership, resistances and specials like backstab or charge: but don't hold your breath, this is likely to be a separate script.
- Attachments
-
- prkill19.zip
- perl script to calculate %-to-kill
- (2.13 KiB) Downloaded 2957 times
Last edited by ott on July 10th, 2005, 4:28 pm, edited 3 times in total.
This quote is not attributable to Antoine de Saint-Exupéry.
Re: prkill - script to calculate %-to-kill
Well, nice script!ott wrote: An energetic C++ coder should be able to add this easily to the in-game "Show defence calculations" dialogue box.
However, I am against this what I have quoted ... Well, I think players should think by themselfes, not using scripts that will prognose them shall they win or lose an unit ... Ofcourse, I like your script (although i haven't tested it yet - I know what it does) because it is good for learning ... but, in game ... I preffer brain thinking
- Elvish_Pillager
- Posts: 8137
- Joined: May 28th, 2004, 10:21 am
- Location: Everywhere you think, nowhere you can possibly imagine.
- Contact:
Re: prkill - script to calculate %-to-kill
I am against any concealing of information from the player, especially when the player could get that information by a more frustrating process, so I support the inclusion of this in the attack dialog.freecraft wrote:Well, I think players should think by themselfes, not using scripts that will prognose them shall they win or lose an unit ...
It's all fun and games until someone loses a lawsuit. Oh, and by the way, sending me private messages won't work. :/ If you must contact me, there's an e-mail address listed on the website in my profile.
Re: prkill - script to calculate %-to-kill
Agreed.Elvish Pillager wrote:I am against any concealing of information from the player, especially when the player could get that information by a more frustrating process, so I support the inclusion of this in the attack dialog.freecraft wrote:Well, I think players should think by themselfes, not using scripts that will prognose them shall they win or lose an unit ...
This is why I also support showing gold values for non fog/shroud games. AFAIK, this has yet to be done.
For I am Turin Turambar - Master of Doom, by doom mastered. On permanent Wesbreak. Will not respond to private messages. Sorry!
And I hate stupid people.
The World of Orbivm
And I hate stupid people.
The World of Orbivm
Re: prkill - script to calculate %-to-kill
Agreed.Elvish Pillager wrote:I am against any concealing of information from the player, especially when the player could get that information by a more frustrating process, so I support the inclusion of this in the attack dialog.freecraft wrote:Well, I think players should think by themselfes, not using scripts that will prognose them shall they win or lose an unit ...
- Elvish_Pillager
- Posts: 8137
- Joined: May 28th, 2004, 10:21 am
- Location: Everywhere you think, nowhere you can possibly imagine.
- Contact:
Well, I've played with it, and I'm actually pretty disappointed. I could get a pretty good estimate just by thinking, and since it's in Damage Calculations, it's rather inconvenient to reach.
If it was on the main attack screen, it would be much more useful to me.
I'll try to cook up a sample image of where it could go, soon.
EDIT: also another problem I forgot. It *shouldn't* say "Both should survive" when an Elvish Archer shoots (6-4) at a 22HP, 70%, Thief. (0.81% ctk)
If it was on the main attack screen, it would be much more useful to me.
I'll try to cook up a sample image of where it could go, soon.
EDIT: also another problem I forgot. It *shouldn't* say "Both should survive" when an Elvish Archer shoots (6-4) at a 22HP, 70%, Thief. (0.81% ctk)
It's all fun and games until someone loses a lawsuit. Oh, and by the way, sending me private messages won't work. :/ If you must contact me, there's an e-mail address listed on the website in my profile.
Well an alternative is to distinguish between 0% and 0.0005% and by calling one 0% and the other 0+% o
similarly 100% could be '100%' and 99.9995% could be '99+%'
Then you can round to nearest for values inbetween.
You could come up with english phrases which would describe those 0+ and 99+ states better, but then you have to translate them.
similarly 100% could be '100%' and 99.9995% could be '99+%'
Then you can round to nearest for values inbetween.
You could come up with english phrases which would describe those 0+ and 99+ states better, but then you have to translate them.
I'm glad to hear EP found the feature disappointing. I would be very worried if the routine gave different results to the intuitive calculations of an experienced player!
The Damage Calculations dialog is perhaps not ideal, but it seemed the most logical place to put it at the time. A mockup of another place it could go would be welcome, though it might have to wait until post-1.0.
Saying "both should survive" seems reasonable if the probability that this doesn't happen is very small -- perhaps the cutoff is too high, though.
Thanks to js138 for the 0+/99+ idea, something like that would make sense.
The Damage Calculations dialog is perhaps not ideal, but it seemed the most logical place to put it at the time. A mockup of another place it could go would be welcome, though it might have to wait until post-1.0.
Saying "both should survive" seems reasonable if the probability that this doesn't happen is very small -- perhaps the cutoff is too high, though.
Thanks to js138 for the 0+/99+ idea, something like that would make sense.
This quote is not attributable to Antoine de Saint-Exupéry.
- Elvish_Pillager
- Posts: 8137
- Joined: May 28th, 2004, 10:21 am
- Location: Everywhere you think, nowhere you can possibly imagine.
- Contact:
Even if you want to preserve this for extremely low chances, I think that it should say "Both will survive" when it's a guarantee.ott wrote:Saying "both should survive" seems reasonable if the probability that this doesn't happen is very small -- perhaps the cutoff is too high, though.
P.S.:
- Attachments
-
- chance to kill.png (77.73 KiB) Viewed 11308 times
It's all fun and games until someone loses a lawsuit. Oh, and by the way, sending me private messages won't work. :/ If you must contact me, there's an e-mail address listed on the website in my profile.
You put the "35% chance to kill" text in the space where the attack special goes! How is that going to work?
For I am Turin Turambar - Master of Doom, by doom mastered. On permanent Wesbreak. Will not respond to private messages. Sorry!
And I hate stupid people.
The World of Orbivm
And I hate stupid people.
The World of Orbivm
- Elvish_Pillager
- Posts: 8137
- Joined: May 28th, 2004, 10:21 am
- Location: Everywhere you think, nowhere you can possibly imagine.
- Contact:
turin wrote:You put the "35% chance to kill" text in the space where the attack special goes! How is that going to work?
- Attachments
-
- Woot! Attack of the magic sword!
- chance to kill.png (78.7 KiB) Viewed 11448 times
It's all fun and games until someone loses a lawsuit. Oh, and by the way, sending me private messages won't work. :/ If you must contact me, there's an e-mail address listed on the website in my profile.
Well, that is a good setup.
For I am Turin Turambar - Master of Doom, by doom mastered. On permanent Wesbreak. Will not respond to private messages. Sorry!
And I hate stupid people.
The World of Orbivm
And I hate stupid people.
The World of Orbivm