Advertisement
_PoY

multi-hit odds calc

Aug 3rd, 2022
1,308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.11 KB | None | 0 0
  1. def calc_odds(moves):
  2.     tmp_rolls = { 0:1 }
  3.     for move in moves :
  4.         total_rolls = { }
  5.         for move_dmg, move_roll in move.items() :
  6.             for tmp_dmg, tmp_roll in tmp_rolls.items() :
  7.                 new_dmg = move_dmg+tmp_dmg
  8.                 added_roll = move_roll*tmp_roll
  9.                 if not new_dmg in total_rolls:
  10.                     total_rolls[new_dmg] = added_roll
  11.                 else :
  12.                     total_rolls[new_dmg] += added_roll
  13.         tmp_rolls = total_rolls.copy()
  14.     return total_rolls
  15.    
  16. def OHKO_odds(hp, moves, total_rolls):
  17.     ko = 0
  18.     total_odds = 39**(len(moves))
  19.     for dmg, roll in total_rolls.items():
  20.         if(dmg >= hp) :
  21.             ko += roll
  22.     return 10000*ko/total_odds // 100
  23.  
  24. MS = { 6:7, 7:31, 8:1 }
  25. #R1 = { 17:13, 18:13, 19:12, 20:1 }
  26. #R2 = { 34:7, 35:6, 36:6, 37:7, 38:6, 39:6, 40:1 }
  27. D = { 17:13, 18:13, 19:12, 20:1 }
  28. D_1 = { 25:4, 26:9, 27:8, 28:9, 29:8, 30:1 }
  29.  
  30. hp = 69
  31. moves = [ MS, MS, MS, MS, MS, D, D ] # [D_1, D_1, D_1]
  32.  
  33. rolls = calc_odds(moves)
  34. ohko = OHKO_odds(hp, moves, rolls)
  35.            
  36. print(rolls)
  37. print(ohko)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement