@rian8337/osu-rebalance-difficulty-calculator 4.0.0-beta.0 → 4.0.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -207,10 +207,9 @@ class DifficultyHitObject {
207
207
  *
208
208
  * @param time The time to calculate the hitobject's opacity at.
209
209
  * @param isHidden Whether Hidden mod is used.
210
- * @param mode The gamemode to calculate the opacity for.
211
210
  * @returns The opacity of the hitobject at the given time.
212
211
  */
213
- opacityAt(time, isHidden, mode) {
212
+ opacityAt(time, isHidden) {
214
213
  if (time > this.object.startTime) {
215
214
  // Consider a hitobject as being invisible when its start time is passed.
216
215
  // In reality the hitobject will be visible beyond its start time up until its hittable window has passed,
@@ -221,10 +220,7 @@ class DifficultyHitObject {
221
220
  const fadeInDuration = this.timeFadeIn;
222
221
  if (isHidden) {
223
222
  const fadeOutStartTime = fadeInStartTime + fadeInDuration;
224
- const fadeOutDuration = this.baseTimePreempt *
225
- (mode === osuBase.Modes.droid
226
- ? 0.35
227
- : osuBase.ModHidden.fadeOutDurationMultiplier);
223
+ const fadeOutDuration = this.baseTimePreempt * osuBase.ModHidden.fadeOutDurationMultiplier;
228
224
  return Math.min(osuBase.MathUtils.clamp((time - fadeInStartTime) / fadeInDuration, 0, 1), 1 -
229
225
  osuBase.MathUtils.clamp((time - fadeOutStartTime) / fadeOutDuration, 0, 1));
230
226
  }
@@ -297,34 +293,16 @@ class DifficultyHitObjectCreator {
297
293
  if (this.mode === osuBase.Modes.droid) {
298
294
  this.maximumSliderRadius = this.normalizedRadius * 2;
299
295
  }
300
- const droidCircleSize = new osuBase.MapStats({
301
- cs: params.circleSize,
302
- mods: params.mods,
303
- }).calculate({ mode: osuBase.Modes.droid }).cs;
304
- const droidScale = (1 - (0.7 * (droidCircleSize - 5)) / 5) / 2;
305
- const osuCircleSize = new osuBase.MapStats({
306
- cs: params.circleSize,
307
- mods: params.mods,
308
- }).calculate({ mode: osuBase.Modes.osu }).cs;
309
- const osuScale = (1 - (0.7 * (osuCircleSize - 5)) / 5) / 2;
310
- params.objects[0].droidScale = droidScale;
311
- params.objects[0].osuScale = osuScale;
312
296
  const scalingFactor = this.getScalingFactor(params.objects[0].getRadius(this.mode));
313
297
  const difficultyObjects = [];
314
298
  for (let i = 0; i < params.objects.length; ++i) {
315
299
  const object = new DifficultyHitObject(params.objects[i], difficultyObjects);
316
300
  object.index = difficultyObjects.length - 1;
317
- object.object.droidScale = droidScale;
318
- object.object.osuScale = osuScale;
319
301
  object.timePreempt = params.preempt;
320
302
  object.baseTimePreempt = params.preempt * params.speedMultiplier;
321
303
  if (object.object instanceof osuBase.Slider) {
322
304
  object.velocity =
323
305
  object.object.velocity * params.speedMultiplier;
324
- object.object.nestedHitObjects.forEach((o) => {
325
- o.droidScale = droidScale;
326
- o.osuScale = osuScale;
327
- });
328
306
  this.calculateSliderCursorPosition(object.object);
329
307
  object.travelDistance = object.object.lazyTravelDistance;
330
308
  // Bonus for repeat sliders until a better per nested object strain system can be achieved.
@@ -367,9 +345,6 @@ class DifficultyHitObjectCreator {
367
345
  object.endTime + object.timePreempt) {
368
346
  break;
369
347
  }
370
- // Future objects do not have their scales set, so we set them here.
371
- o.droidScale = droidScale;
372
- o.osuScale = osuScale;
373
348
  nextVisibleObjects.push(o);
374
349
  }
375
350
  for (let j = 0; j < object.index; ++j) {
@@ -620,7 +595,6 @@ class DifficultyCalculator {
620
595
  speed: [],
621
596
  flashlight: [],
622
597
  };
623
- sectionLength = 400;
624
598
  /**
625
599
  * Constructs a new instance of the calculator.
626
600
  *
@@ -654,6 +628,7 @@ class DifficultyCalculator {
654
628
  speedMultiplier: options?.stats?.speedMultiplier ?? 1,
655
629
  oldStatistics: options?.stats?.oldStatistics ?? false,
656
630
  }).calculate({ mode: this.mode });
631
+ this.preProcess();
657
632
  this.populateDifficultyAttributes();
658
633
  this.generateDifficultyHitObjects();
659
634
  this.calculateAll();
@@ -673,6 +648,11 @@ class DifficultyCalculator {
673
648
  preempt: osuBase.MapStats.arToMS(this.stats.ar),
674
649
  }));
675
650
  }
651
+ /**
652
+ * Performs some pre-processing before proceeding with difficulty calculation.
653
+ */
654
+ preProcess() {
655
+ }
676
656
  /**
677
657
  * Calculates the skills provided.
678
658
  *
@@ -701,6 +681,7 @@ class DifficultyCalculator {
701
681
  this.attributes.overallDifficulty = this.stats.od;
702
682
  this.attributes.sliderCount = this.beatmap.hitObjects.sliders;
703
683
  this.attributes.spinnerCount = this.beatmap.hitObjects.spinners;
684
+ this.attributes.clockRate = this.stats.speedMultiplier;
704
685
  }
705
686
  /**
706
687
  * Calculates the star rating value of a difficulty.
@@ -860,7 +841,8 @@ class DroidAimEvaluator extends AimEvaluator {
860
841
  velocityChangeBonus * this.velocityChangeMultiplier);
861
842
  // Add in additional slider velocity bonus.
862
843
  if (withSliders) {
863
- strain += sliderBonus * this.sliderMultiplier;
844
+ strain +=
845
+ Math.pow(1 + sliderBonus * this.sliderMultiplier, 1.25) - 1;
864
846
  }
865
847
  return strain;
866
848
  }
@@ -915,7 +897,6 @@ class StrainSkill extends Skill {
915
897
  strainPeaks = [];
916
898
  sectionLength = 400;
917
899
  currentSectionEnd = 0;
918
- isFirstObject = true;
919
900
  /**
920
901
  * Calculates the strain value of a hitobject and stores the value in it. This value is affected by previously processed objects.
921
902
  *
@@ -923,11 +904,10 @@ class StrainSkill extends Skill {
923
904
  */
924
905
  process(current) {
925
906
  // The first object doesn't generate a strain, so we begin with an incremented section end
926
- if (this.isFirstObject) {
907
+ if (current.index === 0) {
927
908
  this.currentSectionEnd =
928
909
  Math.ceil(current.startTime / this.sectionLength) *
929
910
  this.sectionLength;
930
- this.isFirstObject = false;
931
911
  }
932
912
  while (current.startTime > this.currentSectionEnd) {
933
913
  this.saveCurrentPeak();
@@ -1062,7 +1042,6 @@ class DroidTapEvaluator extends SpeedEvaluator {
1062
1042
  current.isOverlapping(false)) {
1063
1043
  return 0;
1064
1044
  }
1065
- let strainTime = current.strainTime;
1066
1045
  let doubletapness = 1;
1067
1046
  if (considerCheesability) {
1068
1047
  const greatWindowFull = greatWindow * 2;
@@ -1077,16 +1056,14 @@ class DroidTapEvaluator extends SpeedEvaluator {
1077
1056
  const windowRatio = Math.pow(Math.min(1, currentDeltaTime / greatWindowFull), 2);
1078
1057
  doubletapness = Math.pow(speedRatio, 1 - windowRatio);
1079
1058
  }
1080
- // Cap deltatime to the OD 300 hitwindow.
1081
- // 0.58 is derived from making sure 260 BPM 1/4 OD5 streams aren't nerfed harshly, whilst 0.91 limits the effect of the cap.
1082
- strainTime /= osuBase.MathUtils.clamp(strainTime / greatWindowFull / 0.58, 0.91, 1);
1083
1059
  }
1084
1060
  let speedBonus = 1;
1085
- if (strainTime < this.minSpeedBonus) {
1061
+ if (current.strainTime < this.minSpeedBonus) {
1086
1062
  speedBonus +=
1087
- 0.75 * Math.pow((this.minSpeedBonus - strainTime) / 40, 2);
1063
+ 0.75 *
1064
+ Math.pow(osuBase.ErrorFunction.erf((this.minSpeedBonus - current.strainTime) / 40), 2);
1088
1065
  }
1089
- return (speedBonus * doubletapness) / strainTime;
1066
+ return (speedBonus * Math.pow(doubletapness, 1.5)) / current.strainTime;
1090
1067
  }
1091
1068
  }
1092
1069
 
@@ -1190,7 +1167,7 @@ class DroidFlashlightEvaluator extends FlashlightEvaluator {
1190
1167
  const opacityBonus = 1 +
1191
1168
  this.maxOpacityBonus *
1192
1169
  (1 -
1193
- current.opacityAt(currentObject.object.startTime, isHiddenMod, osuBase.Modes.droid));
1170
+ current.opacityAt(currentObject.object.startTime, isHiddenMod));
1194
1171
  result +=
1195
1172
  (stackNerf * opacityBonus * scalingFactor * jumpDistance) /
1196
1173
  cumulativeStrainTime;
@@ -1233,11 +1210,11 @@ class DroidFlashlightEvaluator extends FlashlightEvaluator {
1233
1210
  * Represents the skill required to memorize and hit every object in a beatmap with the Flashlight mod enabled.
1234
1211
  */
1235
1212
  class DroidFlashlight extends DroidSkill {
1236
- skillMultiplier = 0.125;
1213
+ skillMultiplier = 0.052;
1237
1214
  strainDecayBase = 0.15;
1238
1215
  reducedSectionCount = 0;
1239
1216
  reducedSectionBaseline = 1;
1240
- starsPerDouble = 1.05;
1217
+ starsPerDouble = 1.06;
1241
1218
  isHidden;
1242
1219
  withSliders;
1243
1220
  constructor(mods, withSliders) {
@@ -1262,6 +1239,9 @@ class DroidFlashlight extends DroidSkill {
1262
1239
  current.flashlightStrainWithoutSliders = this.currentStrain;
1263
1240
  }
1264
1241
  }
1242
+ difficultyValue() {
1243
+ return Math.pow(this.strainPeaks.reduce((a, v) => a + v, 0) * this.starsPerDouble, 0.8);
1244
+ }
1265
1245
  }
1266
1246
 
1267
1247
  /**
@@ -1453,7 +1433,8 @@ class DroidVisualEvaluator {
1453
1433
  static evaluateDifficultyOf(current, isHiddenMod, withSliders) {
1454
1434
  if (current.object instanceof osuBase.Spinner ||
1455
1435
  // Exclude overlapping objects that can be tapped at once.
1456
- current.isOverlapping(true)) {
1436
+ current.isOverlapping(true) ||
1437
+ current.index === 0) {
1457
1438
  return 0;
1458
1439
  }
1459
1440
  // Start with base density and give global bonus for Hidden.
@@ -1480,7 +1461,7 @@ class DroidVisualEvaluator {
1480
1461
  }
1481
1462
  strain +=
1482
1463
  (1 -
1483
- current.opacityAt(previous.object.startTime, isHiddenMod, osuBase.Modes.droid)) /
1464
+ current.opacityAt(previous.object.startTime, isHiddenMod)) /
1484
1465
  4;
1485
1466
  }
1486
1467
  // Scale the value with overlapping factor.
@@ -1516,44 +1497,6 @@ class DroidVisualEvaluator {
1516
1497
  Math.min(1, 300 / cumulativeStrainTime);
1517
1498
  }
1518
1499
  }
1519
- // Reward for rhythm changes.
1520
- if (current.rhythmMultiplier > 1) {
1521
- let rhythmBonus = (current.rhythmMultiplier - 1) / 20;
1522
- // Rhythm changes are harder to read in Hidden.
1523
- // Add additional bonus for Hidden.
1524
- if (isHiddenMod) {
1525
- rhythmBonus += (current.rhythmMultiplier - 1) / 25;
1526
- }
1527
- // Rhythm changes are harder to read when objects are stacked together.
1528
- // Scale rhythm bonus based on the stack of past objects.
1529
- const diameter = 2 * current.object.getRadius(osuBase.Modes.droid);
1530
- let cumulativeStrainTime = 0;
1531
- for (let i = 0; i < Math.min(current.index, 5); ++i) {
1532
- const previous = current.previous(i);
1533
- if (previous.object instanceof osuBase.Spinner ||
1534
- // Exclude overlapping objects that can be tapped at once.
1535
- previous.isOverlapping(true)) {
1536
- continue;
1537
- }
1538
- const jumpDistance = current.object
1539
- .getStackedPosition(osuBase.Modes.droid)
1540
- .getDistance(previous.object.getStackedEndPosition(osuBase.Modes.droid));
1541
- cumulativeStrainTime += previous.strainTime;
1542
- rhythmBonus +=
1543
- // Scale the bonus with diameter.
1544
- osuBase.MathUtils.clamp((0.5 - jumpDistance / diameter) / 10, 0, 0.05) *
1545
- // Scale with cumulative strain time to avoid overbuffing past objects.
1546
- Math.min(1, 300 / cumulativeStrainTime);
1547
- // Give a larger bonus for Hidden.
1548
- if (isHiddenMod) {
1549
- rhythmBonus +=
1550
- (1 -
1551
- current.opacityAt(previous.object.startTime, isHiddenMod, osuBase.Modes.droid)) /
1552
- 20;
1553
- }
1554
- }
1555
- strain += rhythmBonus;
1556
- }
1557
1500
  return strain;
1558
1501
  }
1559
1502
  }
@@ -1578,7 +1521,7 @@ class DroidVisual extends DroidSkill {
1578
1521
  this.currentStrain *= this.strainDecay(current.deltaTime);
1579
1522
  this.currentStrain +=
1580
1523
  DroidVisualEvaluator.evaluateDifficultyOf(current, this.isHidden, this.withsliders) * this.skillMultiplier;
1581
- return this.currentStrain;
1524
+ return this.currentStrain * (1 + (current.rhythmMultiplier - 1) / 5);
1582
1525
  }
1583
1526
  saveToHitObject(current) {
1584
1527
  if (this.withsliders) {
@@ -1632,15 +1575,21 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
1632
1575
  flashlightDifficulty: 0,
1633
1576
  speedNoteCount: 0,
1634
1577
  sliderFactor: 0,
1578
+ clockRate: 1,
1635
1579
  approachRate: 0,
1636
1580
  overallDifficulty: 0,
1637
1581
  hitCircleCount: 0,
1638
1582
  sliderCount: 0,
1639
1583
  spinnerCount: 0,
1584
+ aimDifficultStrainCount: 0,
1585
+ tapDifficultStrainCount: 0,
1586
+ flashlightDifficultStrainCount: 0,
1587
+ visualDifficultStrainCount: 0,
1640
1588
  flashlightSliderFactor: 0,
1641
1589
  visualSliderFactor: 0,
1642
1590
  possibleThreeFingeredSections: [],
1643
1591
  difficultSliders: [],
1592
+ averageSpeedDeltaTime: 0,
1644
1593
  };
1645
1594
  difficultyMultiplier = 0.18;
1646
1595
  mode = osuBase.Modes.droid;
@@ -1762,9 +1711,6 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
1762
1711
  }
1763
1712
  this.calculateTotal();
1764
1713
  }
1765
- /**
1766
- * Returns a string representative of the class.
1767
- */
1768
1714
  toString() {
1769
1715
  return (this.total.toFixed(2) +
1770
1716
  " stars (" +
@@ -1779,9 +1725,13 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
1779
1725
  this.visual.toFixed(2) +
1780
1726
  " visual)");
1781
1727
  }
1782
- /**
1783
- * Creates skills to be calculated.
1784
- */
1728
+ preProcess() {
1729
+ const scale = osuBase.CircleSizeCalculator.standardCSToStandardScale(this.stats.cs);
1730
+ for (const object of this.beatmap.hitObjects.objects) {
1731
+ object.droidScale = scale;
1732
+ }
1733
+ osuBase.HitObjectStackEvaluator.applyDroidStacking(this.beatmap.hitObjects.objects, this.beatmap.general.stackLeniency);
1734
+ }
1785
1735
  createSkills() {
1786
1736
  return [
1787
1737
  new DroidAim(this.mods, true),
@@ -1822,33 +1772,39 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
1822
1772
  calculateAimAttributes() {
1823
1773
  const objectStrains = [];
1824
1774
  let maxStrain = 0;
1825
- // Take the top 15% most difficult sliders based on velocity.
1826
1775
  const topDifficultSliders = [];
1827
1776
  for (let i = 0; i < this.objects.length; ++i) {
1828
1777
  const object = this.objects[i];
1829
1778
  objectStrains.push(object.aimStrainWithSliders);
1830
1779
  maxStrain = Math.max(maxStrain, object.aimStrainWithSliders);
1831
- if (object.object instanceof osuBase.Slider) {
1780
+ const velocity = object.travelDistance / object.travelTime;
1781
+ if (velocity > 0) {
1832
1782
  topDifficultSliders.push({
1833
1783
  index: i,
1834
- velocity: object.travelDistance / object.travelTime,
1784
+ velocity: velocity,
1835
1785
  });
1836
- topDifficultSliders.sort((a, b) => b.velocity - a.velocity);
1837
- while (topDifficultSliders.length >
1838
- Math.floor(0.15 * this.objects.length)) {
1839
- topDifficultSliders.pop();
1840
- }
1841
1786
  }
1842
1787
  }
1843
1788
  if (maxStrain) {
1844
1789
  this.attributes.aimNoteCount = objectStrains.reduce((total, next) => total + 1 / (1 + Math.exp(-((next / maxStrain) * 12 - 6))), 0);
1790
+ this.attributes.aimDifficultStrainCount = objectStrains.reduce((total, next) => total + Math.pow(next / maxStrain, 4), 0);
1845
1791
  }
1846
1792
  const velocitySum = topDifficultSliders.reduce((a, v) => a + v.velocity, 0);
1847
1793
  for (const slider of topDifficultSliders) {
1848
- this.attributes.difficultSliders.push({
1849
- index: slider.index,
1850
- difficultyRating: slider.velocity / velocitySum,
1851
- });
1794
+ const difficultyRating = slider.velocity / velocitySum;
1795
+ // Only consider sliders that are fast enough.
1796
+ if (difficultyRating > 0.02) {
1797
+ this.attributes.difficultSliders.push({
1798
+ index: slider.index,
1799
+ difficultyRating: slider.velocity / velocitySum,
1800
+ });
1801
+ }
1802
+ }
1803
+ this.attributes.difficultSliders.sort((a, b) => b.difficultyRating - a.difficultyRating);
1804
+ // Take the top 15% most difficult sliders.
1805
+ while (this.attributes.difficultSliders.length >
1806
+ Math.ceil(0.15 * this.beatmap.hitObjects.sliders)) {
1807
+ this.attributes.difficultSliders.pop();
1852
1808
  }
1853
1809
  }
1854
1810
  /**
@@ -1867,6 +1823,7 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
1867
1823
  this.attributes.possibleThreeFingeredSections = [];
1868
1824
  const tempSections = [];
1869
1825
  const objectStrains = [];
1826
+ const objectDeltaTimes = [];
1870
1827
  let maxStrain = 0;
1871
1828
  const maxSectionDeltaTime = 2000;
1872
1829
  const minSectionObjectCount = 5;
@@ -1876,8 +1833,10 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
1876
1833
  const next = this.objects[i + 1];
1877
1834
  if (i === 0) {
1878
1835
  objectStrains.push(current.tapStrain);
1836
+ objectDeltaTimes.push(current.deltaTime);
1879
1837
  }
1880
1838
  objectStrains.push(next.tapStrain);
1839
+ objectDeltaTimes.push(next.deltaTime);
1881
1840
  maxStrain = Math.max(current.tapStrain, maxStrain);
1882
1841
  const realDeltaTime = next.object.startTime - current.object.endTime;
1883
1842
  if (realDeltaTime >= maxSectionDeltaTime) {
@@ -1916,6 +1875,10 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
1916
1875
  if (inSpeedSection &&
1917
1876
  current.originalTapStrain < threeFingerStrainThreshold) {
1918
1877
  inSpeedSection = false;
1878
+ // Ignore sections that don't meet object count requirement.
1879
+ if (i - newFirstObjectIndex < minSectionObjectCount) {
1880
+ continue;
1881
+ }
1919
1882
  this.attributes.possibleThreeFingeredSections.push({
1920
1883
  firstObjectIndex: newFirstObjectIndex,
1921
1884
  lastObjectIndex: i,
@@ -1924,7 +1887,10 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
1924
1887
  }
1925
1888
  }
1926
1889
  // Don't forget to manually add the last beatmap section, which would otherwise be ignored.
1927
- if (inSpeedSection) {
1890
+ // Ignore sections that don't meet object count requirement.
1891
+ if (inSpeedSection &&
1892
+ section.lastObjectIndex - newFirstObjectIndex >=
1893
+ minSectionObjectCount) {
1928
1894
  this.attributes.possibleThreeFingeredSections.push({
1929
1895
  firstObjectIndex: newFirstObjectIndex,
1930
1896
  lastObjectIndex: section.lastObjectIndex,
@@ -1934,6 +1900,16 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
1934
1900
  }
1935
1901
  if (maxStrain) {
1936
1902
  this.attributes.speedNoteCount = objectStrains.reduce((total, next) => total + 1 / (1 + Math.exp(-((next / maxStrain) * 12 - 6))), 0);
1903
+ this.attributes.averageSpeedDeltaTime =
1904
+ objectDeltaTimes.reduce((total, next, index) => total +
1905
+ (next * 1) /
1906
+ (1 +
1907
+ Math.exp(-((objectStrains[index] / maxStrain) *
1908
+ 25 -
1909
+ 20))), 0) /
1910
+ objectStrains.reduce((total, next) => total +
1911
+ 1 / (1 + Math.exp(-((next / maxStrain) * 25 - 20))), 0);
1912
+ this.attributes.tapDifficultStrainCount = objectStrains.reduce((total, next) => total + Math.pow(next / maxStrain, 4), 0);
1937
1913
  }
1938
1914
  }
1939
1915
  /**
@@ -1976,6 +1952,12 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
1976
1952
  if (this.mods.some((m) => m instanceof osuBase.ModRelax)) {
1977
1953
  this.flashlight *= 0.7;
1978
1954
  }
1955
+ const objectStrains = this.objects.map((v) => v.flashlightStrainWithSliders);
1956
+ const maxStrain = Math.max(...objectStrains);
1957
+ if (maxStrain) {
1958
+ this.attributes.flashlightDifficultStrainCount =
1959
+ objectStrains.reduce((total, next) => total + Math.pow(next / maxStrain, 4), 0);
1960
+ }
1979
1961
  this.attributes.flashlightDifficulty = this.flashlight;
1980
1962
  }
1981
1963
  /**
@@ -1993,6 +1975,11 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
1993
1975
  this.starValue(visualSkillWithoutSliders.difficultyValue()) /
1994
1976
  this.visual;
1995
1977
  }
1978
+ const objectStrains = this.objects.map((v) => v.flashlightStrainWithSliders);
1979
+ const maxStrain = Math.max(...objectStrains);
1980
+ if (maxStrain) {
1981
+ this.attributes.visualDifficultStrainCount = objectStrains.reduce((total, next) => total + Math.pow(next / maxStrain, 4), 0);
1982
+ }
1996
1983
  }
1997
1984
  }
1998
1985
 
@@ -2115,7 +2102,7 @@ class PerformanceCalculator {
2115
2102
  if (this.difficultyAttributes.sliderCount > 0) {
2116
2103
  // We assume 15% of sliders in a beatmap are difficult since there's no way to tell from the performance calculator.
2117
2104
  const estimateDifficultSliders = this.difficultyAttributes.sliderCount * 0.15;
2118
- const estimateSliderEndsDropped = osuBase.MathUtils.clamp(Math.min(this.computedAccuracy.n300 +
2105
+ const estimateSliderEndsDropped = osuBase.MathUtils.clamp(Math.min(this.computedAccuracy.n100 +
2119
2106
  this.computedAccuracy.n50 +
2120
2107
  this.computedAccuracy.nmiss, maxCombo - combo), 0, estimateDifficultSliders);
2121
2108
  this.sliderNerfFactor =
@@ -2130,6 +2117,7 @@ class PerformanceCalculator {
2130
2117
  * Calculates the amount of misses + sliderbreaks from combo.
2131
2118
  */
2132
2119
  calculateEffectiveMissCount(combo, maxCombo) {
2120
+ // Guess the number of misses + slider breaks from combo.
2133
2121
  let comboBasedMissCount = 0;
2134
2122
  if (this.difficultyAttributes.sliderCount > 0) {
2135
2123
  const fullComboThreshold = maxCombo - 0.1 * this.difficultyAttributes.sliderCount;
@@ -2188,33 +2176,6 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2188
2176
  get tapDeviation() {
2189
2177
  return this._tapDeviation;
2190
2178
  }
2191
- /**
2192
- * The "true" deviation ability of the score.
2193
- *
2194
- * This is estimated from deviation with respect to the amount of circles of the beatmap. Using
2195
- * {@link https://en.wikipedia.org/wiki/Hypergeometric_distribution hypergeometric distribution},
2196
- * the amount of retries required to get a "desired run" in a beatmap is estimated.
2197
- *
2198
- * The metric is then used to estimate the "true" deviation ability of the player using the
2199
- * {@link https://en.wikipedia.org/wiki/Quantile_function inverse cumulative density function} of
2200
- * {@link https://en.wikipedia.org/wiki/Normal_distribution Gaussian distribution}.
2201
- */
2202
- get deviationAbility() {
2203
- return this._deviationAbility;
2204
- }
2205
- /**
2206
- * The "true" tap deviation ability of the score.
2207
- *
2208
- * This is estimated from deviation with respect to the amount of circles of the beatmap. Using
2209
- * {@link https://en.wikipedia.org/wiki/Hypergeometric_distribution hypergeometric distribution},
2210
- * the amount of retries required to get a "desired run" in a beatmap is estimated, which is then
2211
- * used to estimate the "true" deviation ability of the player using the
2212
- * {@link https://en.wikipedia.org/wiki/Quantile_function inverse cumulative density function} of
2213
- * {@link https://en.wikipedia.org/wiki/Normal_distribution Gaussian distribution}.
2214
- */
2215
- get tapDeviationAbility() {
2216
- return this._tapDeviationAbility;
2217
- }
2218
2179
  /**
2219
2180
  * The penalty used to penalize the aim performance value.
2220
2181
  *
@@ -2248,8 +2209,6 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2248
2209
  _tapPenalty = 1;
2249
2210
  _deviation = 0;
2250
2211
  _tapDeviation = 0;
2251
- _deviationAbility = 0;
2252
- _tapDeviationAbility = 0;
2253
2212
  /**
2254
2213
  * @param difficultyAttributes The difficulty attributes to calculate.
2255
2214
  */
@@ -2280,20 +2239,20 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2280
2239
  *
2281
2240
  * The aim and total performance value will be recalculated afterwards.
2282
2241
  *
2283
- * @param value The slider cheese penalty value. Must be between than 0 (exclusive) and 1 (inclusive).
2242
+ * @param value The slider cheese penalty value. Must be between than 0 and 1.
2284
2243
  */
2285
2244
  applyAimSliderCheesePenalty(value) {
2286
- if (value <= 0) {
2287
- throw new RangeError("New aim slider cheese penalty must be greater than zero.");
2245
+ if (value < 0) {
2246
+ throw new RangeError("New aim slider cheese penalty must be greater than or equal to zero.");
2288
2247
  }
2289
2248
  if (value > 1) {
2290
- throw new RangeError("New visual slider cheese penalty must be less than or equal to one.");
2249
+ throw new RangeError("New aim slider cheese penalty must be less than or equal to one.");
2291
2250
  }
2292
2251
  if (value === this._aimSliderCheesePenalty) {
2293
2252
  return;
2294
2253
  }
2295
- this.aim *= this._aimSliderCheesePenalty / value;
2296
2254
  this._aimSliderCheesePenalty = value;
2255
+ this.calculateAimValue();
2297
2256
  this.calculateTotalValue();
2298
2257
  }
2299
2258
  /**
@@ -2301,11 +2260,11 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2301
2260
  *
2302
2261
  * The flashlight and total performance value will be recalculated afterwards.
2303
2262
  *
2304
- * @param value The slider cheese penalty value. Must be between 0 (exclusive) and 1 (inclusive).
2263
+ * @param value The slider cheese penalty value. Must be between 0 and 1.
2305
2264
  */
2306
2265
  applyFlashlightSliderCheesePenalty(value) {
2307
- if (value <= 0) {
2308
- throw new RangeError("New flashlight slider cheese penalty must be greater than zero.");
2266
+ if (value < 0) {
2267
+ throw new RangeError("New flashlight slider cheese penalty must be greater than or equal to zero.");
2309
2268
  }
2310
2269
  if (value > 1) {
2311
2270
  throw new RangeError("New flashlight slider cheese penalty must be less than or equal to one.");
@@ -2313,8 +2272,8 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2313
2272
  if (value === this._flashlightSliderCheesePenalty) {
2314
2273
  return;
2315
2274
  }
2316
- this.flashlight *= this._flashlightSliderCheesePenalty / value;
2317
2275
  this._flashlightSliderCheesePenalty = value;
2276
+ this.calculateFlashlightValue();
2318
2277
  this.calculateTotalValue();
2319
2278
  }
2320
2279
  /**
@@ -2322,11 +2281,11 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2322
2281
  *
2323
2282
  * The visual and total performance value will be recalculated afterwards.
2324
2283
  *
2325
- * @param value The slider cheese penalty value. Must be between 0 (exclusive) and 1 (inclusive).
2284
+ * @param value The slider cheese penalty value. Must be between 0 and 1.
2326
2285
  */
2327
2286
  applyVisualSliderCheesePenalty(value) {
2328
- if (value <= 0) {
2329
- throw new RangeError("New visual slider cheese penalty must be greater than zero.");
2287
+ if (value < 0) {
2288
+ throw new RangeError("New visual slider cheese penalty must be greater than or equal to zero.");
2330
2289
  }
2331
2290
  if (value > 1) {
2332
2291
  throw new RangeError("New visual slider cheese penalty must be less than or equal to one.");
@@ -2334,15 +2293,13 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2334
2293
  if (value === this._visualSliderCheesePenalty) {
2335
2294
  return;
2336
2295
  }
2337
- this.visual *= this._visualSliderCheesePenalty / value;
2338
2296
  this._visualSliderCheesePenalty = value;
2297
+ this.calculateVisualValue();
2339
2298
  this.calculateTotalValue();
2340
2299
  }
2341
2300
  calculateValues() {
2342
2301
  this._deviation = this.calculateDeviation();
2343
2302
  this._tapDeviation = this.calculateTapDeviation();
2344
- this._deviationAbility = this.calculateDeviationAbility(this._deviation);
2345
- this._tapDeviationAbility = this.calculateDeviationAbility(this._tapDeviation);
2346
2303
  this.calculateAimValue();
2347
2304
  this.calculateTapValue();
2348
2305
  this.calculateAccuracyValue();
@@ -2371,16 +2328,7 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2371
2328
  */
2372
2329
  calculateAimValue() {
2373
2330
  this.aim = this.baseValue(Math.pow(this.difficultyAttributes.aimDifficulty, 0.8));
2374
- if (this.effectiveMissCount > 0) {
2375
- // Penalize misses by assessing # of misses relative to the total # of objects.
2376
- // Default a 3% reduction for any # of misses.
2377
- this.aim *=
2378
- 0.97 *
2379
- Math.pow(1 -
2380
- Math.pow(this.effectiveMissCount / this.totalHits, 0.775), this.effectiveMissCount);
2381
- }
2382
- // Combo scaling
2383
- this.aim *= this.comboPenalty;
2331
+ this.aim *= this.calculateMissPenalty(this.difficultyAttributes.aimDifficultStrainCount);
2384
2332
  // Scale the aim value with slider factor to nerf very likely dropped sliderends.
2385
2333
  this.aim *= this.sliderNerfFactor;
2386
2334
  // Scale the aim value with slider cheese penalty.
@@ -2388,27 +2336,30 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2388
2336
  // Scale the aim value with deviation.
2389
2337
  this.aim *=
2390
2338
  1.05 *
2391
- Math.pow(osuBase.ErrorFunction.erf(32.0625 / (Math.SQRT2 * this._deviationAbility)), 1.5);
2339
+ Math.pow(osuBase.ErrorFunction.erf(32.0625 / (Math.SQRT2 * this._deviation)), 1.5);
2392
2340
  }
2393
2341
  /**
2394
2342
  * Calculates the tap performance value of the beatmap.
2395
2343
  */
2396
2344
  calculateTapValue() {
2397
2345
  this.tap = this.baseValue(this.difficultyAttributes.tapDifficulty);
2398
- if (this.effectiveMissCount > 0) {
2399
- // Penalize misses by assessing # of misses relative to the total # of objects.
2400
- // Default a 3% reduction for any # of misses.
2401
- this.tap *=
2402
- 0.97 *
2403
- Math.pow(1 -
2404
- Math.pow(this.effectiveMissCount / this.totalHits, 0.775), Math.pow(this.effectiveMissCount, 0.875));
2405
- }
2406
- // Combo scaling
2407
- this.tap *= this.comboPenalty;
2346
+ this.tap *= this.calculateMissPenalty(this.difficultyAttributes.tapDifficultStrainCount);
2347
+ // Normalize the deviation to 300 BPM.
2348
+ const normalizedDeviation = this.tapDeviation *
2349
+ Math.max(1, 50 / this.difficultyAttributes.averageSpeedDeltaTime);
2350
+ // We expect the player to get 7500/x deviation when doubletapping x BPM.
2351
+ // Using this expectation, we penalize scores with deviation above 25.
2352
+ const averageBPM = 60000 / 4 / this.difficultyAttributes.averageSpeedDeltaTime;
2353
+ const adjustedDeviation = normalizedDeviation *
2354
+ (1 +
2355
+ 1 /
2356
+ (1 +
2357
+ Math.exp(-(normalizedDeviation - 7500 / averageBPM) /
2358
+ ((2 * 300) / averageBPM))));
2408
2359
  // Scale the tap value with tap deviation.
2409
2360
  this.tap *=
2410
2361
  1.1 *
2411
- Math.pow(osuBase.ErrorFunction.erf(25 / (Math.SQRT2 * this._tapDeviationAbility)), 1.25);
2362
+ Math.pow(osuBase.ErrorFunction.erf(25 / (Math.SQRT2 * adjustedDeviation)), 1.25);
2412
2363
  // Scale the tap value with three-fingered penalty.
2413
2364
  this.tap /= this._tapPenalty;
2414
2365
  }
@@ -2423,9 +2374,14 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2423
2374
  }
2424
2375
  this.accuracy =
2425
2376
  650 *
2426
- Math.exp(-0.125 * this._deviationAbility) *
2377
+ Math.exp(-0.1 * this._deviation) *
2427
2378
  // The following function is to give higher reward for deviations lower than 25 (250 UR).
2428
- (15 / (this._deviationAbility + 15) + 0.65);
2379
+ (15 / (this._deviation + 15) + 0.65);
2380
+ // Bonus for many hitcircles - it's harder to keep good accuracy up for longer.
2381
+ const ncircles = this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModScoreV2)
2382
+ ? this.totalHits - this.difficultyAttributes.spinnerCount
2383
+ : this.difficultyAttributes.hitCircleCount;
2384
+ this.accuracy *= Math.min(1.15, Math.sqrt(Math.log(1 + ((Math.E - 1) * ncircles) / 1000)));
2429
2385
  // Scale the accuracy value with rhythm complexity.
2430
2386
  this.accuracy *=
2431
2387
  1.5 /
@@ -2445,15 +2401,7 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2445
2401
  }
2446
2402
  this.flashlight =
2447
2403
  Math.pow(this.difficultyAttributes.flashlightDifficulty, 1.6) * 25;
2448
- // Combo scaling
2449
- this.flashlight *= this.comboPenalty;
2450
- if (this.effectiveMissCount > 0) {
2451
- // Penalize misses by assessing # of misses relative to the total # of objects. Default a 3% reduction for any # of misses.
2452
- this.flashlight *=
2453
- 0.97 *
2454
- Math.pow(1 -
2455
- Math.pow(this.effectiveMissCount / this.totalHits, 0.775), Math.pow(this.effectiveMissCount, 0.875));
2456
- }
2404
+ this.flashlight *= this.calculateMissPenalty(this.difficultyAttributes.flashlightDifficultStrainCount);
2457
2405
  // Account for shorter maps having a higher ratio of 0 combo/100 combo flashlight radius.
2458
2406
  this.flashlight *=
2459
2407
  0.7 +
@@ -2464,7 +2412,7 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2464
2412
  // Scale the flashlight value with slider cheese penalty.
2465
2413
  this.flashlight *= this._flashlightSliderCheesePenalty;
2466
2414
  // Scale the flashlight value with deviation.
2467
- this.flashlight *= osuBase.ErrorFunction.erf(50 / (Math.SQRT2 * this._deviationAbility));
2415
+ this.flashlight *= osuBase.ErrorFunction.erf(50 / (Math.SQRT2 * this._deviation));
2468
2416
  }
2469
2417
  /**
2470
2418
  * Calculates the visual performance value of the beatmap.
@@ -2472,15 +2420,7 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2472
2420
  calculateVisualValue() {
2473
2421
  this.visual =
2474
2422
  Math.pow(this.difficultyAttributes.visualDifficulty, 1.6) * 22.5;
2475
- if (this.effectiveMissCount > 0) {
2476
- // Penalize misses by assessing # of misses relative to the total # of objects. Default a 3% reduction for any # of misses.
2477
- this.visual *=
2478
- 0.97 *
2479
- Math.pow(1 -
2480
- Math.pow(this.effectiveMissCount / this.totalHits, 0.775), this.effectiveMissCount);
2481
- }
2482
- // Combo scaling
2483
- this.visual *= this.comboPenalty;
2423
+ this.visual *= this.calculateMissPenalty(this.difficultyAttributes.visualDifficultStrainCount);
2484
2424
  // Scale the visual value with object count to penalize short maps.
2485
2425
  this.visual *= Math.min(1, 1.650668 +
2486
2426
  (0.4845796 - 1.650668) /
@@ -2490,7 +2430,22 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2490
2430
  // Scale the visual value with deviation.
2491
2431
  this.visual *=
2492
2432
  1.065 *
2493
- Math.pow(osuBase.ErrorFunction.erf(30 / (Math.SQRT2 * this._deviationAbility)), 1.75);
2433
+ Math.pow(osuBase.ErrorFunction.erf(30 / (Math.SQRT2 * this._deviation)), 1.75);
2434
+ }
2435
+ /**
2436
+ * Calculates miss penalty.
2437
+ *
2438
+ * Miss penalty assumes that a player will miss on the hardest parts of a map,
2439
+ * so we use the amount of relatively difficult sections to adjust miss penalty
2440
+ * to make it more punishing on maps with lower amount of hard sections.
2441
+ */
2442
+ calculateMissPenalty(difficultStrainCount) {
2443
+ if (this.effectiveMissCount === 0) {
2444
+ return 1;
2445
+ }
2446
+ return (0.94 /
2447
+ (this.effectiveMissCount / (2 * Math.sqrt(difficultStrainCount)) +
2448
+ 1));
2494
2449
  }
2495
2450
  /**
2496
2451
  * Estimates the player's tap deviation based on the OD, number of circles and sliders,
@@ -2511,17 +2466,16 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2511
2466
  return Number.POSITIVE_INFINITY;
2512
2467
  }
2513
2468
  const hitWindow300 = new osuBase.OsuHitWindow(this.difficultyAttributes.overallDifficulty).hitWindowFor300();
2514
- // Obtain the 50 hit window for droid.
2515
- const clockRate = new osuBase.MapStats({
2516
- mods: this.difficultyAttributes.mods,
2517
- }).calculate().speedMultiplier;
2518
- const realHitWindow300 = hitWindow300 * clockRate;
2469
+ // Obtain the 50 and 100 hit window for droid.
2470
+ const realHitWindow300 = hitWindow300 * this.difficultyAttributes.clockRate;
2519
2471
  const droidHitWindow = new osuBase.DroidHitWindow(osuBase.OsuHitWindow.hitWindow300ToOD(realHitWindow300));
2520
- const hitWindow50 = droidHitWindow.hitWindowFor50(this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModPrecise)) / clockRate;
2521
- const greatCountOnCircles = this.difficultyAttributes.hitCircleCount -
2522
- this.computedAccuracy.n100 -
2523
- this.computedAccuracy.n50 -
2524
- this.computedAccuracy.nmiss;
2472
+ const isPrecise = this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModPrecise);
2473
+ const hitWindow50 = droidHitWindow.hitWindowFor50(isPrecise) /
2474
+ this.difficultyAttributes.clockRate;
2475
+ const hitWindow100 = droidHitWindow.hitWindowFor100(isPrecise) /
2476
+ this.difficultyAttributes.clockRate;
2477
+ const { n300, n100, n50, nmiss } = this.computedAccuracy;
2478
+ const greatCountOnCircles = this.difficultyAttributes.hitCircleCount - n100 - n50 - nmiss;
2525
2479
  // The probability that a player hits a circle is unknown, but we can estimate it to be
2526
2480
  // the number of greats on circles divided by the number of circles, and then add one
2527
2481
  // to the number of circles as a bias correction / bayesian prior.
@@ -2540,10 +2494,32 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2540
2494
  if (greatProbabilityCircle === 0 && greatProbabilitySlider === 0) {
2541
2495
  return Number.POSITIVE_INFINITY;
2542
2496
  }
2543
- const deviationOnCircles = hitWindow300 /
2544
- (Math.SQRT2 * osuBase.ErrorFunction.erfInv(greatProbabilityCircle));
2545
- const deviationOnSliders = hitWindow50 /
2546
- (Math.SQRT2 * osuBase.ErrorFunction.erfInv(greatProbabilitySlider));
2497
+ const calculateDeviation = (mainHitWindow, probability) => {
2498
+ if (probability === 0) {
2499
+ return Number.POSITIVE_INFINITY;
2500
+ }
2501
+ // Start with normal deviation.
2502
+ const normalDeviation = mainHitWindow /
2503
+ (Math.SQRT2 * osuBase.ErrorFunction.erfInv(probability));
2504
+ // Get the variance of the truncated variable.
2505
+ const truncatedVariance = Math.pow(normalDeviation, 2) -
2506
+ (Math.SQRT2 *
2507
+ hitWindow100 *
2508
+ normalDeviation *
2509
+ Math.exp(-0.5 * Math.pow(hitWindow100 / normalDeviation, 2))) /
2510
+ (Math.sqrt(Math.PI) *
2511
+ osuBase.ErrorFunction.erf(hitWindow100 / (Math.SQRT2 * normalDeviation)));
2512
+ // Add 50s by assuming they are uniformly distributed.
2513
+ return Math.sqrt((1 / (n300 + n100 + n50)) *
2514
+ ((n300 + n100) * truncatedVariance +
2515
+ (n50 *
2516
+ (Math.pow(hitWindow50, 2) +
2517
+ hitWindow100 * hitWindow50 +
2518
+ Math.pow(hitWindow100, 2))) /
2519
+ 3));
2520
+ };
2521
+ const deviationOnCircles = calculateDeviation(hitWindow300, greatProbabilityCircle);
2522
+ const deviationOnSliders = calculateDeviation(hitWindow50, greatProbabilitySlider);
2547
2523
  return Math.min(deviationOnCircles, deviationOnSliders);
2548
2524
  }
2549
2525
  /**
@@ -2557,33 +2533,48 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2557
2533
  return Number.POSITIVE_INFINITY;
2558
2534
  }
2559
2535
  const hitWindow300 = new osuBase.OsuHitWindow(this.difficultyAttributes.overallDifficulty).hitWindowFor300();
2560
- const relevantTotalDiff = this.totalHits - this.difficultyAttributes.speedNoteCount;
2561
- const relevantCountGreat = Math.max(0, this.computedAccuracy.n300 - relevantTotalDiff);
2536
+ // Obtain the 50 and 100 hit window for droid.
2537
+ const realHitWindow300 = hitWindow300 * this.difficultyAttributes.clockRate;
2538
+ const droidHitWindow = new osuBase.DroidHitWindow(osuBase.OsuHitWindow.hitWindow300ToOD(realHitWindow300));
2539
+ const isPrecise = this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModPrecise);
2540
+ const hitWindow50 = droidHitWindow.hitWindowFor50(isPrecise) /
2541
+ this.difficultyAttributes.clockRate;
2542
+ const hitWindow100 = droidHitWindow.hitWindowFor100(isPrecise) /
2543
+ this.difficultyAttributes.clockRate;
2544
+ const { n300, n100, n50, nmiss } = this.computedAccuracy;
2545
+ // Assume a fixed ratio of non-300s hit in speed notes based on speed note count ratio and OD.
2546
+ // Graph: https://www.desmos.com/calculator/31argjcxqc
2547
+ const speedNoteRatio = this.difficultyAttributes.speedNoteCount / this.totalHits;
2548
+ const nonGreatCount = n100 + n50 + nmiss;
2549
+ const nonGreatRatio = 1 -
2550
+ (Math.pow(Math.exp(Math.sqrt(hitWindow300)) + 1, 1 - speedNoteRatio) -
2551
+ 1) /
2552
+ Math.exp(Math.sqrt(hitWindow300));
2553
+ const relevantCountGreat = Math.max(0, this.difficultyAttributes.speedNoteCount -
2554
+ nonGreatCount * nonGreatRatio);
2562
2555
  if (relevantCountGreat === 0) {
2563
2556
  return Number.POSITIVE_INFINITY;
2564
2557
  }
2565
2558
  const greatProbability = relevantCountGreat / (this.difficultyAttributes.speedNoteCount + 1);
2566
- return (hitWindow300 / (Math.SQRT2 * osuBase.ErrorFunction.erfInv(greatProbability)));
2567
- }
2568
- /**
2569
- * Estimates the player's "true UR ability".
2570
- *
2571
- * This is done by estimating the expected number of retries required to
2572
- * get a "desired run" under a hypergeometric distribution, which is then used
2573
- * to estimate the player's "true UR ability" with beatmap statistics in mind.
2574
- *
2575
- * @param deviation The deviation of the score.
2576
- */
2577
- calculateDeviationAbility(deviation) {
2578
- const accuracyHits = this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModScoreV2)
2579
- ? this.totalHits - this.difficultyAttributes.spinnerCount
2580
- : this.difficultyAttributes.hitCircleCount;
2581
- // It is assumed for a worst case scenario that a player will "retry" a map 25000/n times where n is the circle count.
2582
- // This is the expected significance level of a score a player will achieve after retrying that amount.
2583
- // As an example, for a beatmap with 100 circles, the significance level is 0.996015936255, meaning
2584
- // that we expect a player to realistically "go for" a score that beats out 99.6% of their scores.
2585
- const expectedRetries = 1 - 1 / (Math.max(1, 25000 / accuracyHits) + 1);
2586
- return osuBase.NormalDistribution.invCDF(deviation, deviation / Math.sqrt(2 * accuracyHits), expectedRetries);
2559
+ // Start with normal deviation.
2560
+ const normalDeviation = hitWindow300 /
2561
+ (Math.SQRT2 * osuBase.ErrorFunction.erfInv(greatProbability));
2562
+ // Get the variance of the truncated variable.
2563
+ const truncatedVariance = Math.pow(normalDeviation, 2) -
2564
+ (Math.SQRT2 *
2565
+ hitWindow100 *
2566
+ normalDeviation *
2567
+ Math.exp(-0.5 * Math.pow(hitWindow100 / normalDeviation, 2))) /
2568
+ (Math.sqrt(Math.PI) *
2569
+ osuBase.ErrorFunction.erf(hitWindow100 / (Math.SQRT2 * normalDeviation)));
2570
+ // Add 50s by assuming they are uniformly distributed.
2571
+ return Math.sqrt((1 / (n300 + n100 + n50)) *
2572
+ ((n300 + n100) * truncatedVariance +
2573
+ (n50 *
2574
+ (Math.pow(hitWindow50, 2) +
2575
+ hitWindow100 * hitWindow50 +
2576
+ Math.pow(hitWindow100, 2))) /
2577
+ 3));
2587
2578
  }
2588
2579
  toString() {
2589
2580
  return (this.total.toFixed(2) +
@@ -2978,8 +2969,6 @@ class OsuSpeed extends OsuSkill {
2978
2969
  decayWeight = 0.9;
2979
2970
  currentSpeedStrain = 0;
2980
2971
  currentRhythm = 0;
2981
- // ~200 1/4 BPM streams
2982
- minSpeedBonus = 75;
2983
2972
  greatWindow;
2984
2973
  constructor(mods, greatWindow) {
2985
2974
  super(mods);
@@ -3048,7 +3037,7 @@ class OsuFlashlightEvaluator extends FlashlightEvaluator {
3048
3037
  const opacityBonus = 1 +
3049
3038
  this.maxOpacityBonus *
3050
3039
  (1 -
3051
- current.opacityAt(currentObject.object.startTime, isHiddenMod, osuBase.Modes.osu));
3040
+ current.opacityAt(currentObject.object.startTime, isHiddenMod));
3052
3041
  result +=
3053
3042
  (stackNerf * opacityBonus * scalingFactor * jumpDistance) /
3054
3043
  cumulativeStrainTime;
@@ -3140,6 +3129,7 @@ class OsuDifficultyCalculator extends DifficultyCalculator {
3140
3129
  flashlightDifficulty: 0,
3141
3130
  speedNoteCount: 0,
3142
3131
  sliderFactor: 0,
3132
+ clockRate: 1,
3143
3133
  approachRate: 0,
3144
3134
  overallDifficulty: 0,
3145
3135
  hitCircleCount: 0,
@@ -3227,9 +3217,6 @@ class OsuDifficultyCalculator extends DifficultyCalculator {
3227
3217
  this.postCalculateFlashlight(flashlightSkill);
3228
3218
  this.calculateTotal();
3229
3219
  }
3230
- /**
3231
- * Returns a string representative of the class.
3232
- */
3233
3220
  toString() {
3234
3221
  return (this.total.toFixed(2) +
3235
3222
  " stars (" +
@@ -3240,9 +3227,17 @@ class OsuDifficultyCalculator extends DifficultyCalculator {
3240
3227
  this.flashlight.toFixed(2) +
3241
3228
  " flashlight)");
3242
3229
  }
3243
- /**
3244
- * Creates skills to be calculated.
3245
- */
3230
+ preProcess() {
3231
+ const scale = osuBase.CircleSizeCalculator.standardCSToStandardScale(this.stats.cs);
3232
+ for (const object of this.beatmap.hitObjects.objects) {
3233
+ object.osuScale = scale;
3234
+ }
3235
+ const ar = new osuBase.MapStats({
3236
+ ar: this.beatmap.difficulty.ar,
3237
+ mods: osuBase.ModUtil.removeSpeedChangingMods(this.mods),
3238
+ }).calculate().ar;
3239
+ osuBase.HitObjectStackEvaluator.applyStandardStacking(this.beatmap.formatVersion, this.beatmap.hitObjects.objects, ar, this.beatmap.general.stackLeniency);
3240
+ }
3246
3241
  createSkills() {
3247
3242
  return [
3248
3243
  new OsuAim(this.mods, true),
@@ -3436,7 +3431,7 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
3436
3431
  // Scale the aim value with slider factor to nerf very likely dropped sliderends.
3437
3432
  this.aim *= this.sliderNerfFactor;
3438
3433
  // Scale the aim value with accuracy.
3439
- this.aim *= this.computedAccuracy.value(this.totalHits);
3434
+ this.aim *= this.computedAccuracy.value();
3440
3435
  // It is also important to consider accuracy difficulty when doing that.
3441
3436
  const odScaling = Math.pow(this.difficultyAttributes.overallDifficulty, 2) / 2500;
3442
3437
  this.aim *= 0.98 + odScaling;
@@ -3484,15 +3479,14 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
3484
3479
  n300: Math.max(0, countGreat - relevantTotalDiff),
3485
3480
  n100: Math.max(0, countOk - Math.max(0, relevantTotalDiff - countGreat)),
3486
3481
  n50: Math.max(0, countMeh - Math.max(0, relevantTotalDiff - countGreat - countOk)),
3487
- nmiss: this.effectiveMissCount,
3488
3482
  });
3489
3483
  // Scale the speed value with accuracy and OD.
3490
3484
  this.speed *=
3491
3485
  (0.95 +
3492
3486
  Math.pow(this.difficultyAttributes.overallDifficulty, 2) /
3493
3487
  750) *
3494
- Math.pow((this.computedAccuracy.value(this.totalHits) +
3495
- relevantAccuracy.value()) /
3488
+ Math.pow((this.computedAccuracy.value() +
3489
+ relevantAccuracy.value(this.difficultyAttributes.speedNoteCount)) /
3496
3490
  2, (14.5 -
3497
3491
  Math.max(this.difficultyAttributes.overallDifficulty, 8)) /
3498
3492
  2);
@@ -3522,7 +3516,8 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
3522
3516
  // Considering to use derivation from perfect accuracy in a probabilistic manner - assume normal distribution
3523
3517
  this.accuracy =
3524
3518
  Math.pow(1.52163, this.difficultyAttributes.overallDifficulty) *
3525
- Math.pow(realAccuracy.value(ncircles), 24) *
3519
+ // It is possible to reach a negative accuracy with this formula. Cap it at zero - zero points.
3520
+ Math.pow(realAccuracy.n300 < 0 ? 0 : realAccuracy.value(), 24) *
3526
3521
  2.83;
3527
3522
  // Bonus for many hitcircles - it's harder to keep good accuracy up for longer
3528
3523
  this.accuracy *= Math.min(1.15, Math.pow(ncircles / 1000, 0.3));
@@ -3560,8 +3555,7 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
3560
3555
  ? 0.2 * Math.min(1, (this.totalHits - 200) / 200)
3561
3556
  : 0);
3562
3557
  // Scale the flashlight value with accuracy slightly.
3563
- this.flashlight *=
3564
- 0.5 + this.computedAccuracy.value(this.totalHits) / 2;
3558
+ this.flashlight *= 0.5 + this.computedAccuracy.value() / 2;
3565
3559
  // It is also important to consider accuracy difficulty when doing that.
3566
3560
  const odScaling = Math.pow(this.difficultyAttributes.overallDifficulty, 2) / 2500;
3567
3561
  this.flashlight *= 0.98 + odScaling;