Page 1 of 1

Script for calculating GDR effectiveness

PostPosted: Saturday, 27th August 2016, 09:19
by kuniqs
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.

Re: Script for calculating GDR effectiveness

PostPosted: Saturday, 27th August 2016, 09:36
by goodcoolguy
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

Re: Script for calculating GDR effectiveness

PostPosted: Saturday, 27th August 2016, 10:53
by kuniqs
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.

Re: Script for calculating GDR effectiveness

PostPosted: Saturday, 27th August 2016, 11:22
by goodcoolguy
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.

Re: Script for calculating GDR effectiveness

PostPosted: Saturday, 27th August 2016, 12:22
by kuniqs
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)

Re: Script for calculating GDR effectiveness

PostPosted: Saturday, 27th August 2016, 12:23
by goodcoolguy
The wikipedia page isn't bad...

Re: Script for calculating GDR effectiveness

PostPosted: Saturday, 27th August 2016, 17:24
by Airwolf
You could plot histograms (or kernel density estimates) and look at the tails.