# Bard Quiver/Invis

Jun 27th, 2020
304
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import _random
2. import math
3.
4. rnd = _random.Random()
5. def getrandint(m):
6.     return math.ceil(rnd.random()*m)
7. def d(N):
8.     return getrandint(N)
9.
10. def handcb():
11.     return d(6)
12.
13. def simturn(numattacks, adv, ac, hitmod, dmgdice, dmgmod):
14.     dmg = 0
15.     for i in range(numattacks):
16.         hitroll = 0
18.             hitroll = max(d(20), d(20))
19.         else:
20.             hitroll = d(20)
21.         if hitroll == 20:
22.             dmg += dmgdice() + dmgdice() + dmgmod
23.         elif hitroll != 1 and hitroll >= ac - hitmod:
24.             dmg += dmgdice() + dmgmod
25.     return dmg
26.
27. def simdpr(runnumber, params):
28.     tests = [0]*runnumber
29.     for i in range(runnumber):
30.         tests[i] = simturn(*params)
31.     return sum(tests)/runnumber
32.
33. def runforacs(runnumber, params, ACarr):
34.     runprm = params
35.     dpr = []
36.     for ac in ACarr:
37.         runprm[2] = ac
38.         dpr.append(simdpr(runnumber, runprm))
39.     return dpr
40.
41. ACtests = range(10, 30)
42. teststrength = 100000
43.
44. ginvisprm = [3, True, 15, 10, handcb, 5]
45. ginvisprm_sharp = [3, True, 15, 5, handcb, 15]
46.
47. swiftprm = [4, False, 15, 10, handcb, 5]
48. swiftprm_sharp = [4, False, 15, 5, handcb, 15]
49.
50. #print(simturn(*ginvisprm))
51. #print(simdpr(teststrength, ginvisprm))
52.
53. f = open('bardquiver/output.txt', 'a+')
54. f.write('AC\t'+'\t'.join(map(str,ACtests))+'\n')
55. f.write('GI\t'+'\t'.join(map(str,runforacs(teststrength, ginvisprm, ACtests)))+'\n')
56. f.write('GIS\t'+'\t'.join(map(str,runforacs(teststrength, ginvisprm_sharp, ACtests)))+'\n')
57.
58. f.write('SQ\t'+'\t'.join(map(str,runforacs(teststrength, swiftprm, ACtests)))+'\n')
59. f.write('SQS\t'+'\t'.join(map(str,runforacs(teststrength, swiftprm_sharp, ACtests)))+'\n')
60.
61. f.close()
RAW Paste Data