Script for calculating GDR effectiveness


Ask fellow adventurers how to stay alive in the deep, dark, dangerous dungeon below, or share your own accumulated wisdom.

Crypt Cleanser

Posts: 724

Joined: Tuesday, 29th November 2011, 11:04

Post Saturday, 27th August 2016, 09:19

Script for calculating GDR effectiveness

https://www.sendspace.com/file/a62olg

It uses the Monte Carlo method (i.e. sums up hundreds of thousands random damage vs. AC calculations and gets the average from it).

If anyone wants some additional functionality from the script, post here, I will update the script. It's 1 page long, so don't be intimidated to make your own changes.

Turns out GDR works differently than I thought; it doesn't help blocking damage that much, but it reduces AVERAGE melee damage dealt to you significantly.

  Code:
tries = 10000
x = 1
blocked = 0
blockedbygdr = 0
ac = 40
dam = 40
gdr = 0.39

math.randomseed(os.time())
R = math.random

print("ac?: ")
ac = io.read('*n')

print("damage?: ")
dam = io.read('*n')

print("gdr?: ")
gdr = io.read('*n')

maximumpotentialdamage = dam*gdr
if maximumpotentialdamage > ac/2 then
   maximumpotentialdamage = ac/2
end
maximumpotentialdamage = math.floor(maximumpotentialdamage)

damagetotal = 0
damagetotalgdr = 0

while x < tries do
   local damagerolled = R(1,dam)
   local acrolled = R(0,ac)

   if acrolled >= damagerolled then
      blocked = blocked+1
   else
      damagetotal = damagetotal + damagerolled - acrolled
      if acrolled < maximumpotentialdamage then
         acrolled = maximumpotentialdamage
      end

      if acrolled >= damagerolled then
         blockedbygdr = blockedbygdr + 1
      else
         damagetotalgdr = damagetotalgdr + damagerolled - acrolled
      end
   end

   x = x+1
end

print("blocks / +gdr = " .. math.floor((blocked/tries)*100+0.5) .. "% / " .. math.floor(((blocked/tries)*100 + (blockedbygdr/tries)*100)+0.5) .. "%")
print("damage on average / with gdr = " .. (damagetotal/tries) .. " / " .. (damagetotalgdr/tries))
print("gdr reduced average damage by " .. math.floor(100-((damagetotalgdr/tries)/(damagetotal/tries))*100+0.5) .."%")
os.execute('pause')




BTW. I'd like to make a webpage with such functionality so people without Lua could use it, I just don't know where to start. I'm kinda a Web retard. Little help? Is there a free hosting somewhere where I can simply upload a page and get a link to share with others? Without making accounts, passwords and all that bullshit.
"Damned, damned be the legions of the damned..."
User avatar

Blades Runner

Posts: 546

Joined: Friday, 2nd October 2015, 14:42

Post Saturday, 27th August 2016, 09:36

Re: Script for calculating GDR effectiveness

You should try computing higher moments. This is where gdr really shines and you'll see things other people's simulations have ignored.

edit: also worth noting there is no need to do Monte Carlo here. You can just iterate over all possible rolls. See script in this thread:

viewtopic.php?f=5&t=14714
The Original Discourse Respecter

Crypt Cleanser

Posts: 724

Joined: Tuesday, 29th November 2011, 11:04

Post Saturday, 27th August 2016, 10:53

Re: Script for calculating GDR effectiveness

What are "higher moments"? Do you mean higher ac values?

I want something easily understandable. The results in the thread you linked are rather confusing.
"Damned, damned be the legions of the damned..."
User avatar

Blades Runner

Posts: 546

Joined: Friday, 2nd October 2015, 14:42

Post Saturday, 27th August 2016, 11:22

Re: Script for calculating GDR effectiveness

Higher moments are essentially averages of higher powers. The first moment is the mean, second moment is related to variance, third moment to skewness, other higher moments are related to thickness of tails and so on. If you just look at averages, you're not getting anything you couldn't learn from fsim. The higher moments stuff is what really shows the difference between 30/35, 40/25, and 50/15 defenses, which is mostly lost in average damage analysis. Like, how often am I going to take a lot of damage to a really bad roll? How good a feel am I getting for how much damage a monster can hit me for based on short term averages without any especially big rolls? The answer to these question is in higher moments.

re: the link, the tables are not easy to read, but the code is.
The Original Discourse Respecter

For this message the author goodcoolguy has received thanks:
Arrhythmia

Crypt Cleanser

Posts: 724

Joined: Tuesday, 29th November 2011, 11:04

Post Saturday, 27th August 2016, 12:22

Re: Script for calculating GDR effectiveness

Sorry, do you recommend a learning resource for this arcane knowledge of yours?
(It's statistics, I know. I'd like something more compressed than a 300+ page book)
"Damned, damned be the legions of the damned..."
User avatar

Blades Runner

Posts: 546

Joined: Friday, 2nd October 2015, 14:42

Post Saturday, 27th August 2016, 12:23

Re: Script for calculating GDR effectiveness

The wikipedia page isn't bad...
The Original Discourse Respecter

Abyss Ambulator

Posts: 1193

Joined: Friday, 16th January 2015, 20:20

Post Saturday, 27th August 2016, 17:24

Re: Script for calculating GDR effectiveness

You could plot histograms (or kernel density estimates) and look at the tails.

For this message the author Airwolf has received thanks:
goodcoolguy

Return to Dungeon Crawling Advice

Who is online

Users browsing this forum: No registered users and 27 guests

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