Improve gacha accuracy and rate up logic
This commit is contained in:
parent
36518583c2
commit
71320f820c
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
__pycache__
|
||||
venv
|
||||
venv
|
||||
/students.py
|
55
roll.py
55
roll.py
@ -1,10 +1,13 @@
|
||||
import random
|
||||
from students import *
|
||||
import logging
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
def determine_rarity(roll_number, sr_guarantee):
|
||||
if roll_number > (SR_WEIGHT + R_WEIGHT):
|
||||
return 'SSR'
|
||||
elif roll_number > (R_WEIGHT) or sr_guarantee:
|
||||
elif roll_number > R_WEIGHT or sr_guarantee:
|
||||
return 'SR'
|
||||
else:
|
||||
return 'R'
|
||||
@ -19,7 +22,6 @@ def regular(sr_guarantee=False):
|
||||
|
||||
student_pool_roll_number = random.randint(0, len(student_pool) - 1)
|
||||
|
||||
# return [student_pool[student_pool_roll_number]]
|
||||
return [
|
||||
{
|
||||
'name': student_pool[student_pool_roll_number],
|
||||
@ -46,44 +48,31 @@ def rate_up(ssr_student, sr_guarantee=False, sr_student=None):
|
||||
|
||||
student_pool = STUDENTS[rarity]
|
||||
|
||||
# TODO: Improve this
|
||||
if rarity == 'SSR':
|
||||
rateup_weight = int(total_weight / SSR_WEIGHT * SSR_RATE_UP_PERCENT / ROLL_PERCENT_ACCURACY)
|
||||
rateup_roll = random.randint(1, int(100 / ROLL_PERCENT_ACCURACY))
|
||||
if rateup_roll < rateup_weight:
|
||||
return [
|
||||
{
|
||||
'name': ssr_student,
|
||||
'rarity': rarity,
|
||||
'pickup': True
|
||||
}
|
||||
]
|
||||
if ssr_student not in student_pool:
|
||||
student_pool.remove(ssr_student)
|
||||
if rarity == 'SSR' or (rarity == 'SR' and sr_student):
|
||||
ssr = rarity == 'SSR'
|
||||
multiplier = 10 ** ROLL_PERCENT_ACCURACY
|
||||
one_per_one_percent = 100
|
||||
weight = SSR_WEIGHT if ssr else SR_WEIGHT
|
||||
rate_up_percent = SSR_RATE_UP_PERCENT if ssr else SR_RATE_UP_PERCENT
|
||||
|
||||
student_pool_roll_number = random.randint(0, len(student_pool) - 1)
|
||||
|
||||
return [
|
||||
{
|
||||
'name': student_pool[student_pool_roll_number],
|
||||
'rarity': rarity,
|
||||
'pickup': False
|
||||
}
|
||||
]
|
||||
elif rarity == 'SR' and sr_student:
|
||||
rateup_weight = int(total_weight / SR_WEIGHT * SR_RATE_UP_PERCENT / ROLL_PERCENT_ACCURACY)
|
||||
rateup_roll = random.randint(1, int(100 / ROLL_PERCENT_ACCURACY))
|
||||
if rateup_roll < rateup_weight:
|
||||
rate_up_weight = int(total_weight / weight * rate_up_percent * multiplier)
|
||||
rate_up_roll = random.randint(1, int(one_per_one_percent * multiplier))
|
||||
if rate_up_roll < rate_up_weight:
|
||||
return [
|
||||
{
|
||||
'name': sr_student,
|
||||
'name': ssr_student if ssr else sr_student,
|
||||
'rarity': rarity,
|
||||
'pickup': True
|
||||
}
|
||||
]
|
||||
|
||||
if sr_student not in student_pool:
|
||||
student_pool.remove(sr_student)
|
||||
|
||||
if ssr:
|
||||
if ssr_student not in student_pool:
|
||||
student_pool.remove(ssr_student)
|
||||
else:
|
||||
if sr_student not in student_pool:
|
||||
student_pool.remove(sr_student)
|
||||
|
||||
student_pool_roll_number = random.randint(0, len(student_pool) - 1)
|
||||
|
||||
return [
|
||||
|
@ -9,15 +9,15 @@ CURRENT_BANNER = [
|
||||
}
|
||||
]
|
||||
|
||||
R_WEIGHT = 785
|
||||
R_WEIGHT = 78500000
|
||||
|
||||
SR_WEIGHT = 185
|
||||
SR_WEIGHT = 18500000
|
||||
SR_RATE_UP_PERCENT = 3
|
||||
|
||||
SSR_WEIGHT = 30
|
||||
SSR_WEIGHT = 3000000
|
||||
SSR_RATE_UP_PERCENT = 0.7
|
||||
|
||||
ROLL_PERCENT_ACCURACY = 1/100
|
||||
ROLL_PERCENT_ACCURACY = 6
|
||||
|
||||
STUDENTS = {
|
||||
'R': [
|
||||
|
Loading…
Reference in New Issue
Block a user