mirror of
https://github.com/283375/arcaea-offline.git
synced 2025-04-17 21:30:18 +00:00
feat(calc): calculate constants from potential
This commit is contained in:
parent
64fd328ff8
commit
f72410d0bc
@ -1,5 +1,7 @@
|
|||||||
|
from dataclasses import dataclass
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from math import floor
|
from math import floor
|
||||||
|
from typing import Tuple, Union
|
||||||
|
|
||||||
|
|
||||||
def calculate_score_range(notes: int, pure: int, far: int):
|
def calculate_score_range(notes: int, pure: int, far: int):
|
||||||
@ -11,17 +13,51 @@ def calculate_score_range(notes: int, pure: int, far: int):
|
|||||||
return (actual_score, actual_score + pure)
|
return (actual_score, actual_score + pure)
|
||||||
|
|
||||||
|
|
||||||
|
def calculate_score_modifier(score: int) -> Decimal:
|
||||||
|
if score >= 10000000:
|
||||||
|
return Decimal(2)
|
||||||
|
elif score >= 9800000:
|
||||||
|
return Decimal(1) + (Decimal(score - 9800000) / 200000)
|
||||||
|
else:
|
||||||
|
return Decimal(score - 9500000) / 300000
|
||||||
|
|
||||||
|
|
||||||
def calculate_potential(_constant: float, score: int) -> Decimal:
|
def calculate_potential(_constant: float, score: int) -> Decimal:
|
||||||
constant = Decimal(_constant)
|
constant = Decimal(_constant)
|
||||||
if score >= 10000000:
|
score_modifier = calculate_score_modifier(score)
|
||||||
return constant + 2
|
return max(Decimal(0), constant + score_modifier)
|
||||||
elif score >= 9800000:
|
|
||||||
return constant + 1 + (Decimal(score - 9800000) / 200000)
|
|
||||||
else:
|
|
||||||
return max(Decimal(0), constant + (Decimal(score - 9500000) / 300000))
|
|
||||||
|
|
||||||
|
|
||||||
def calculate_shiny_pure(notes: int, score: int, pure: int, far: int) -> int:
|
def calculate_shiny_pure(notes: int, score: int, pure: int, far: int) -> int:
|
||||||
single_note_score = 10000000 / Decimal(notes)
|
single_note_score = 10000000 / Decimal(notes)
|
||||||
actual_score = single_note_score * pure + single_note_score * Decimal(0.5) * far
|
actual_score = single_note_score * pure + single_note_score * Decimal(0.5) * far
|
||||||
return score - floor(actual_score)
|
return score - floor(actual_score)
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class ConstantsFromPotentialResult:
|
||||||
|
EXPlus: Tuple[Decimal, Decimal]
|
||||||
|
EX: Tuple[Decimal, Decimal]
|
||||||
|
AA: Tuple[Decimal, Decimal]
|
||||||
|
A: Tuple[Decimal, Decimal]
|
||||||
|
B: Tuple[Decimal, Decimal]
|
||||||
|
C: Tuple[Decimal, Decimal]
|
||||||
|
|
||||||
|
|
||||||
|
def calculate_constants_from_potential(potential: Union[Decimal, str, float, int]):
|
||||||
|
potential = Decimal(potential)
|
||||||
|
|
||||||
|
ranges = []
|
||||||
|
for upperScore, lowerScore in [
|
||||||
|
(10000000, 9900000),
|
||||||
|
(9899999, 9800000),
|
||||||
|
(9799999, 9500000),
|
||||||
|
(9499999, 9200000),
|
||||||
|
(9199999, 8900000),
|
||||||
|
(8899999, 8600000),
|
||||||
|
]:
|
||||||
|
upperScoreModifier = calculate_score_modifier(upperScore)
|
||||||
|
lowerScoreModifier = calculate_score_modifier(lowerScore)
|
||||||
|
ranges.append((potential - upperScoreModifier, potential - lowerScoreModifier))
|
||||||
|
|
||||||
|
return ConstantsFromPotentialResult(*ranges)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user