Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import _random
- import math
- rnd = _random.Random()
- def getrandint(m):
- return math.ceil(rnd.random()*m)
- def d(N):
- return getrandint(N)
- def nodmg():
- return 0
- def warhammer():
- return d(8)
- def favour():
- return d(4)
- def smite():
- return d(8) + d(8)
- def killNrounds(rounds, hp, eAC, weapon, modif, favor=nodmg, smite=nodmg):
- hasSmited=False
- killcount = 0
- currenthp = hp
- for i in range(rounds):
- d20 = d(20)
- if d20 == 20:
- if not hasSmited:
- currenthp -= weapon() + weapon() + modif + favor() + favor() + smite() + smite()
- hasSmited = True
- else:
- currenthp -= weapon() + weapon() + modif + favor() + favor()
- elif d20 >= eAC:
- if not hasSmited:
- currenthp -= weapon() + modif + favor() + smite()
- hasSmited = True
- else:
- currenthp -= weapon() + modif + favor()
- if currenthp <= 0:
- currenthp = hp
- killcount+=1
- return killcount + (hp-currenthp)/hp
- def simkillrounds(tries, *prm):
- tests = [0]*tries
- for i in range(tries):
- tests[i] = killNrounds(*prm)
- return sum(tests)/tries
- favourtest = [ 8, warhammer, 4, favour]
- smitetest = [8, warhammer, 4, nodmg, smite]
- # hps = [5, 10, 15, 20]
- # hps = [5, 7, 9, 12, 15, 18, 22, 26, 30, 35]
- #hps = [6, 8]
- # hps = [40,50,60,70,80,90,100,120]
- hps = [5, 6, 7, 8, 9, 10, 12, 15, 18, 22, 26, 30, 35, 40, 50,60,70,80,90,100,120]
- testtries = 1000000
- def runfor(testtries, testprm, hps, filepath='paladin/output.txt'):
- f = open(filepath, 'a+')
- f.write(str(testprm)+'\n')
- f.write('r\t' + '\t'.join(map(str,hps)))
- for i in range(1, 11):
- f.write('\n' + str(i) + '\t')
- for hp in hps:
- f.write(str(simkillrounds(testtries, i, hp, *testprm))+'\t')
- f.write('\n')
- f.close()
- runfor(testtries, favourtest, hps)
- runfor(testtries, smitetest, hps)
Add Comment
Please, Sign In to add comment