Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2024
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.04 KB | None | 0 0
  1. import numpy as np
  2. import seaborn as sns
  3. import matplotlib.pyplot as plt
  4.  
  5. np.random.seed(1234)
  6.  
  7. # [02/07 18:30] Whisper from [Owner] Blah: gold can roll from 1375 to 2000, even % chance for every integer. A total
  8. # boost up to 200% is added to that roll consisting of the % sums of resistances, mob debuff and elemental distribution
  9. # [02/07 18:31] Whisper from [Owner] Blah: Resistances can roll from 5% to 40%, mob debuff from 5% to -15%, elemental
  10. # can roll from 5% to 30% (for elemental it is the distance away from 30% that is the boost)
  11. # [02/07 18:31] Whisper from [Owner] Blah: so ultimately 40% * 3 + 5% + 25% * 3 which should total to 200%
  12.  
  13. # Theoretical max: 2000 * (1 + 0.4 + 0.4 + 0.4 + 0.05 + 0.25 + 0.25 + 0.25) = 6000
  14. # Theoretical min: 1375 * (1 + 0.05 + 0.05 + 0.05 - 0.15 + 0.0 + 0.0 + 0.0) = 1375
  15.  
  16. num_simulations = 1_000_000
  17. sim = []
  18.  
  19. for i in range(num_simulations):
  20.    
  21.     base_gold = np.random.randint(1375, 2000 + 1)
  22.     water_res = np.random.randint(5, 41) / 100.0
  23.     fire_res = np.random.randint(5, 41) / 100.0
  24.     thunder_res = np.random.randint(5, 41) / 100.0
  25.     mob_debuff = np.random.randint(-15, 6) / 100.0
  26.     water_dis = 0.3 - np.random.randint(5, 31) / 100.0
  27.     fire_dis = 0.3 - np.random.randint(5, 31) / 100.0
  28.     thunder_dis = 0.3 - np.random.randint(5, 31) / 100.0
  29.  
  30.     roll_gold = base_gold * (1 + water_res + fire_res + thunder_res + mob_debuff + water_dis + fire_dis + thunder_dis)
  31.     sim.append(roll_gold)
  32.  
  33. mu = np.mean(sim)
  34. std = np.std(sim)
  35.  
  36. print(f'min: {np.min(sim)}')
  37. print(f'max: {np.max(sim)}')
  38.  
  39. fake_data = np.random.normal(loc=mu, scale=std, size=num_simulations)
  40.  
  41. fig, ax = plt.subplots(figsize=(9, 7), dpi=80)
  42. sns.histplot(sim, color=colors[0], kde=True, edgecolor=None, alpha=0.4, ax=ax,  bins=50)
  43. plt.xlim(1375, 6000)
  44. plt.title('Catacomb base gold probability analysis', fontsize=14)
  45. plt.xlabel('Base gold', fontsize=12)
  46. plt.ylabel('Count', fontsize=12)
  47.  
  48. plt.subplots_adjust(bottom=0.3)
  49. plt.gcf().text(0.66, 0.89, f'Theoretical min: {1375}', fontsize=12, family='monospace')
  50. plt.gcf().text(0.66, 0.86, f'Theoretical max: {6000}', fontsize=12, family='monospace')
  51.  
  52. plt.gcf().text(0.66, 0.81, f'P(gold) > {np.percentile(sim, 50):.2f} = 50%', fontsize=12, family='monospace')
  53. plt.gcf().text(0.66, 0.78, f'P(gold) > {np.percentile(sim, 80):.2f} = 20%', fontsize=12, family='monospace')
  54. plt.gcf().text(0.66, 0.75, f'P(gold) > {np.percentile(sim, 90):.2f} = 10%', fontsize=12, family='monospace')
  55. plt.gcf().text(0.66, 0.72, f'P(gold) > {np.percentile(sim, 95):.2f} = 5%', fontsize=12, family='monospace')
  56. plt.gcf().text(0.66, 0.69, f'P(gold) > {np.percentile(sim, 97.5):.2f} = 2.5%', fontsize=12, family='monospace')
  57. plt.gcf().text(0.66, 0.66, f'P(gold) > {np.percentile(sim, 99):.2f} = 1%', fontsize=12, family='monospace')
  58. plt.gcf().text(0.66, 0.63, f'P(gold) > {np.percentile(sim, 99.9):.2f} = 0.1%', fontsize=12, family='monospace')
  59. plt.gcf().text(0.66, 0.60, f'P(gold) > {np.percentile(sim, 99.99):.2f} = 0.01%', fontsize=12, family='monospace')
  60. plt.gcf().text(0.66, 0.57, f'P(gold) > {np.percentile(sim, 99.999):.2f} = 0.001%', fontsize=12, family='monospace')
  61.  
  62. plt.gcf().text(0.66, 0.52, f'P(gold) > 4000 = {(1-(np.array(sim) < 4000).astype(int).mean())*100:.3f}%', fontsize=12, family='monospace')
  63. plt.gcf().text(0.66, 0.49, f'P(gold) > 4250 = {(1-(np.array(sim) < 4250).astype(int).mean())*100:.3f}%', fontsize=12, family='monospace')
  64. plt.gcf().text(0.66, 0.46, f'P(gold) > 4500 = {(1-(np.array(sim) < 4500).astype(int).mean())*100:.3f}%', fontsize=12, family='monospace')
  65. plt.gcf().text(0.66, 0.43, f'P(gold) > 4750 = {(1-(np.array(sim) < 4750).astype(int).mean())*100:.3f}%', fontsize=12, family='monospace')
  66. plt.gcf().text(0.66, 0.40, f'P(gold) > 5000 = {(1-(np.array(sim) < 5000).astype(int).mean())*100:.3f}%', fontsize=12, family='monospace')
  67. plt.gcf().text(0.66, 0.37, f'P(gold) > 5250 = {(1-(np.array(sim) < 5250).astype(int).mean())*100:.3f}%', fontsize=12, family='monospace')
  68.  
  69. plt.gcf().text(0.84, 0.02, 'Player data: anfneub', fontsize=8)
  70.  
  71. plt.tight_layout()
  72. plt.savefig('cata_gold.png')
  73.  
  74.  
Tags: Queslar
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement