-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgacha.py
More file actions
35 lines (31 loc) · 1.06 KB
/
gacha.py
File metadata and controls
35 lines (31 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import os
import numpy as np
class GachaSimulator:
def __init__(self, base_prob=0.5, prob_increment=0.2, increase_after=0, last_count=0):
self.increase_after = increase_after
self.base_prob = base_prob
self.prob_increment = prob_increment
self.max_prob = 1
self.count = last_count
self.bigcount = 0
def draw(self):
prob = min(self.base_prob + max(self.count-self.increase_after,0) * self.prob_increment, self.max_prob)
result = np.random.rand() < prob
self.count = 0 if result else self.count + 1
if result:
if self.bigcount < 1:
self.bigcount +=1
return int(np.random.choice([1,2]))
else:
self.bigcount = 0
return 2
else:
return 0
def get_count(self):
return self.count
if __name__ == "__main__":
simulator = GachaSimulator()
draws = 10
for _ in range(10):
results = [simulator.draw() for _ in range(draws)]
print(results)