Skip to content

Instantly share code, notes, and snippets.

@btquanto
Last active October 12, 2021 20:37
Show Gist options
  • Save btquanto/315570f5fffbd83023add7fbc8d78d2b to your computer and use it in GitHub Desktop.
Save btquanto/315570f5fffbd83023add7fbc8d78d2b to your computer and use it in GitHub Desktop.
Genshin Impact drop rate simulation reverse engineer
import os
from random import randint
SIMULATIONS = 1000000000
RATE = 6 # The base rate to get a 5* item is 0.6%
chances = dict([(i, 0) for i in range(1, 91)])
times = 0
for i in range(SIMULATIONS):
if i % (SIMULATIONS / 10000) == 0:
# Tracking simulation progress
print("Simulating: {}%".format("%.2f" % (i / SIMULATIONS * 100)), end='\r', flush=True)
if times < 75:
# For the first 75 pulls, the rate remain constant
chance = randint(1, 1000)
else:
# The rate increases gradually to 100% for the last 15 pulls
chance = randint(1, 95 - times)
if chance <= RATE:
# Successfully got a 5* item
chances[times + 1] += 1
times = 0
else:
times += 1
total = sum(chances.values())
percents = [(key, value / total * 100) for key, value in chances.items()]
for values in zip(*[percents[i:i + 15] for i in range(0, len(percents), 15)]):
print("\t".join(["{}: {}%".format(str(k).rjust(2, " "), "%.6f" % v) for k, v in values]))
print("\n=======\nConsolidated 5* rate including pity: {}%\n".format("%.5f" % (total / SIMULATIONS * 100)))
@btquanto
Copy link
Author

btquanto commented Feb 2, 2021

Result

 1: 0.600619%   16: 0.566975%   31: 0.498439%   46: 0.434888%   61: 0.439250%   76: 19.060940%
 2: 0.591274%   17: 0.542053%   32: 0.510900%   47: 0.470402%   62: 0.420558%   77: 13.972499%
 3: 0.594389%   18: 0.534576%   33: 0.513392%   48: 0.452334%   63: 0.410589%   78: 10.080311%
 4: 0.593766%   19: 0.526476%   34: 0.501555%   49: 0.479125%   64: 0.424919%   79: 7.133912%
 5: 0.592520%   20: 0.546414%   35: 0.508408%   50: 0.439873%   65: 0.412458%   80: 4.923334%
 6: 0.616819%   21: 0.533330%   36: 0.494078%   51: 0.460433%   66: 0.392521%   81: 3.289699%
 7: 0.584420%   22: 0.550152%   37: 0.480371%   52: 0.429281%   67: 0.415574%   82: 2.117744%
 8: 0.574451%   23: 0.560121%   38: 0.503424%   53: 0.414328%   68: 0.383175%   83: 1.271020%
 9: 0.620557%   24: 0.536445%   39: 0.461056%   54: 0.453580%   69: 0.409966%   84: 0.751397%
10: 0.585666%   25: 0.521492%   40: 0.495324%   55: 0.437380%   70: 0.422427%   85: 0.425543%
11: 0.566352%   26: 0.490963%   41: 0.462925%   56: 0.430527%   71: 0.398128%   86: 0.214952%
12: 0.510277%   27: 0.537691%   42: 0.485978%   57: 0.445480%   72: 0.396259%   87: 0.081619%
13: 0.557006%   28: 0.508408%   43: 0.457941%   58: 0.443611%   73: 0.395013%   88: 0.035514%
14: 0.554514%   29: 0.523984%   44: 0.441742%   59: 0.399998%   74: 0.371337%   89: 0.008100%
15: 0.554514%   30: 0.495324%   45: 0.461679%   60: 0.431773%   75: 0.366353%   90: 0.003115%

=======
Consolidated 5* rate including pity: 1.60501%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment