@rian8337/osu-rebalance-difficulty-calculator 4.0.0-beta.11 → 4.0.0-beta.13

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
@@ -616,6 +616,7 @@ class DifficultyCalculator {
616
616
  * beginning of the new chunk.
617
617
  *
618
618
  * @param options Options for the difficulty calculation.
619
+ * @returns The current instance.
619
620
  */
620
621
  calculate(options) {
621
622
  this.mods = options?.mods ?? [];
@@ -660,15 +661,11 @@ class DifficultyCalculator {
660
661
  */
661
662
  calculateSkills(...skills) {
662
663
  // The first object doesn't generate a strain, so we begin calculating from the second object.
663
- this.objects.slice(1).forEach((h, i) => {
664
- skills.forEach((skill) => {
665
- skill.process(h);
666
- if (i === this.objects.length - 2) {
667
- // Don't forget to save the last strain peak, which would otherwise be ignored.
668
- skill.saveCurrentPeak();
669
- }
670
- });
671
- });
664
+ for (const object of this.objects.slice(1)) {
665
+ for (const skill of skills) {
666
+ skill.process(object);
667
+ }
668
+ }
672
669
  }
673
670
  /**
674
671
  * Populates the stored difficulty attributes with necessary data.
@@ -708,12 +705,9 @@ class DroidAimEvaluator extends AimEvaluator {
708
705
  static wideAngleMultiplier = 1.65;
709
706
  static sliderMultiplier = 1.5;
710
707
  static velocityChangeMultiplier = 0.85;
711
- /**
712
- * Spacing threshold for a single hitobject spacing.
713
- */
714
- static SINGLE_SPACING_THRESHOLD = 175;
715
- // ~200 1/2 BPM jumps
716
- static minSpeedBonus = 150;
708
+ static singleSpacingThreshold = 100;
709
+ // 200 1/4 BPM delta time
710
+ static minSpeedBonus = 75;
717
711
  /**
718
712
  * Evaluates the difficulty of aiming the current object, based on:
719
713
  *
@@ -731,13 +725,13 @@ class DroidAimEvaluator extends AimEvaluator {
731
725
  current.isOverlapping(true)) {
732
726
  return 0;
733
727
  }
734
- return (this.aimStrainOf(current, withSliders) +
735
- this.movementStrainOf(current));
728
+ return (this.snapAimStrainOf(current, withSliders) +
729
+ this.flowAimStrainOf(current));
736
730
  }
737
731
  /**
738
- * Calculates the aim strain of a hitobject.
732
+ * Calculates the snap aim strain of a hitobject.
739
733
  */
740
- static aimStrainOf(current, withSliders) {
734
+ static snapAimStrainOf(current, withSliders) {
741
735
  if (current.index <= 1 ||
742
736
  current.previous(0)?.object instanceof osuBase.Spinner) {
743
737
  return 0;
@@ -847,21 +841,18 @@ class DroidAimEvaluator extends AimEvaluator {
847
841
  return strain;
848
842
  }
849
843
  /**
850
- * Calculates the movement strain of a hitobject.
844
+ * Calculates the flow aim strain of a hitobject.
851
845
  */
852
- static movementStrainOf(current) {
846
+ static flowAimStrainOf(current) {
853
847
  let speedBonus = 1;
854
848
  if (current.strainTime < this.minSpeedBonus) {
855
849
  speedBonus +=
856
850
  0.75 *
857
- Math.pow((this.minSpeedBonus - current.strainTime) / 45, 2);
851
+ Math.pow((this.minSpeedBonus - current.strainTime) / 40, 2);
858
852
  }
859
853
  const travelDistance = current.previous(0)?.travelDistance ?? 0;
860
- const distance = Math.min(this.SINGLE_SPACING_THRESHOLD, travelDistance + current.minimumJumpDistance);
861
- return ((50 *
862
- speedBonus *
863
- Math.pow(distance / this.SINGLE_SPACING_THRESHOLD, 5)) /
864
- current.strainTime);
854
+ const shortDistancePenalty = Math.pow(Math.min(this.singleSpacingThreshold, travelDistance + current.minimumJumpDistance) / this.singleSpacingThreshold, 3.5);
855
+ return (200 * speedBonus * shortDistancePenalty) / current.strainTime;
865
856
  }
866
857
  }
867
858
 
@@ -883,25 +874,14 @@ class Skill {
883
874
  * and to calculate a final difficulty value representing the difficulty of hitting all the processed objects.
884
875
  */
885
876
  class StrainSkill extends Skill {
886
- /**
887
- * The strain of currently calculated hitobject.
888
- */
889
- currentStrain = 0;
890
- /**
891
- * The current section's strain peak.
892
- */
893
- currentSectionPeak = 0;
894
877
  /**
895
878
  * Strain peaks are stored here.
896
879
  */
897
880
  strainPeaks = [];
898
881
  sectionLength = 400;
882
+ currentStrain = 0;
883
+ currentSectionPeak = 0;
899
884
  currentSectionEnd = 0;
900
- /**
901
- * Calculates the strain value of a hitobject and stores the value in it. This value is affected by previously processed objects.
902
- *
903
- * @param current The hitobject to process.
904
- */
905
885
  process(current) {
906
886
  // The first object doesn't generate a strain, so we begin with an incremented section end
907
887
  if (current.index === 0) {
@@ -918,6 +898,10 @@ class StrainSkill extends Skill {
918
898
  this.currentStrain = this.strainValueAt(current);
919
899
  this.saveToHitObject(current);
920
900
  this.currentSectionPeak = Math.max(this.currentStrain, this.currentSectionPeak);
901
+ if (!current.next(0)) {
902
+ // Don't forget to save the last strain peak, which would otherwise be ignored.
903
+ this.saveCurrentPeak();
904
+ }
921
905
  }
922
906
  /**
923
907
  * Saves the current peak strain level to the list of strain peaks, which will be used to calculate an overall difficulty.
@@ -936,15 +920,13 @@ class StrainSkill extends Skill {
936
920
  /**
937
921
  * Sets the initial strain level for a new section.
938
922
  *
939
- * @param offset The beginning of the new section in milliseconds, adjusted by speed multiplier.
923
+ * @param time The beginning of the new section in milliseconds.
940
924
  * @param current The current hitobject.
941
925
  */
942
- startNewSectionFrom(offset, current) {
943
- // The maximum strain of the new section is not zero by default, strain decays as usual regardless of section boundaries.
926
+ startNewSectionFrom(time, current) {
927
+ // The maximum strain of the new section is not zero by default.
944
928
  // This means we need to capture the strain level at the beginning of the new section, and use that as the initial peak level.
945
- this.currentSectionPeak =
946
- this.currentStrain *
947
- this.strainDecay(offset - current.previous(0).startTime);
929
+ this.currentSectionPeak = this.calculateInitialStrain(time, current);
948
930
  }
949
931
  }
950
932
 
@@ -978,35 +960,37 @@ class DroidSkill extends StrainSkill {
978
960
  * Represents the skill required to correctly aim at every object in the map with a uniform CircleSize and normalized distances.
979
961
  */
980
962
  class DroidAim extends DroidSkill {
981
- skillMultiplier = 24.55;
982
963
  strainDecayBase = 0.15;
983
964
  reducedSectionCount = 10;
984
965
  reducedSectionBaseline = 0.75;
985
966
  starsPerDouble = 1.05;
967
+ skillMultiplier = 24.55;
986
968
  withSliders;
969
+ currentAimStrain = 0;
987
970
  constructor(mods, withSliders) {
988
971
  super(mods);
989
972
  this.withSliders = withSliders;
990
973
  }
991
- /**
992
- * @param current The hitobject to calculate.
993
- */
994
974
  strainValueAt(current) {
995
- this.currentStrain *= this.strainDecay(current.deltaTime);
996
- this.currentStrain +=
975
+ this.currentAimStrain *= this.strainDecay(current.deltaTime);
976
+ this.currentAimStrain +=
997
977
  DroidAimEvaluator.evaluateDifficultyOf(current, this.withSliders) *
998
978
  this.skillMultiplier;
999
- return this.currentStrain;
979
+ return this.currentAimStrain;
980
+ }
981
+ calculateInitialStrain(time, current) {
982
+ return (this.currentAimStrain *
983
+ this.strainDecay(time - (current.previous(0)?.startTime ?? 0)));
1000
984
  }
1001
985
  /**
1002
986
  * @param current The hitobject to save to.
1003
987
  */
1004
988
  saveToHitObject(current) {
1005
989
  if (this.withSliders) {
1006
- current.aimStrainWithSliders = this.currentStrain;
990
+ current.aimStrainWithSliders = this.currentAimStrain;
1007
991
  }
1008
992
  else {
1009
- current.aimStrainWithoutSliders = this.currentStrain;
993
+ current.aimStrainWithoutSliders = this.currentAimStrain;
1010
994
  }
1011
995
  }
1012
996
  }
@@ -1044,10 +1028,10 @@ class DroidTapEvaluator extends SpeedEvaluator {
1044
1028
  }
1045
1029
  let doubletapness = 1;
1046
1030
  if (considerCheesability) {
1047
- const greatWindowFull = greatWindow * 2;
1048
1031
  // Nerf doubletappable doubles.
1049
1032
  const next = current.next(0);
1050
1033
  if (next) {
1034
+ const greatWindowFull = greatWindow * 2;
1051
1035
  const currentDeltaTime = Math.max(1, current.deltaTime);
1052
1036
  const nextDeltaTime = Math.max(1, next.deltaTime);
1053
1037
  const deltaDifference = Math.abs(nextDeltaTime - currentDeltaTime);
@@ -1071,38 +1055,44 @@ class DroidTapEvaluator extends SpeedEvaluator {
1071
1055
  * Represents the skill required to press keys or tap with regards to keeping up with the speed at which objects need to be hit.
1072
1056
  */
1073
1057
  class DroidTap extends DroidSkill {
1074
- skillMultiplier = 1375;
1075
1058
  reducedSectionCount = 10;
1076
1059
  reducedSectionBaseline = 0.75;
1077
1060
  strainDecayBase = 0.3;
1078
1061
  starsPerDouble = 1.1;
1079
1062
  currentTapStrain = 0;
1080
- currentOriginalTapStrain = 0;
1063
+ currentRhythmMultiplier = 0;
1064
+ skillMultiplier = 1375;
1081
1065
  greatWindow;
1082
- constructor(mods, overallDifficulty) {
1066
+ considerCheesability;
1067
+ constructor(mods, overallDifficulty, considerCheesability) {
1083
1068
  super(mods);
1084
1069
  this.greatWindow = new osuBase.OsuHitWindow(overallDifficulty).hitWindowFor300();
1070
+ this.considerCheesability = considerCheesability;
1085
1071
  }
1086
- /**
1087
- * @param current The hitobject to calculate.
1088
- */
1089
1072
  strainValueAt(current) {
1090
1073
  const decay = this.strainDecay(current.strainTime);
1091
1074
  this.currentTapStrain *= decay;
1092
1075
  this.currentTapStrain +=
1093
- DroidTapEvaluator.evaluateDifficultyOf(current, this.greatWindow, true) * this.skillMultiplier;
1094
- this.currentOriginalTapStrain *= decay;
1095
- this.currentOriginalTapStrain +=
1096
- DroidTapEvaluator.evaluateDifficultyOf(current, this.greatWindow, false) * this.skillMultiplier;
1097
- this.currentOriginalTapStrain *= current.rhythmMultiplier;
1076
+ DroidTapEvaluator.evaluateDifficultyOf(current, this.greatWindow, this.considerCheesability) * this.skillMultiplier;
1077
+ this.currentRhythmMultiplier = current.rhythmMultiplier;
1098
1078
  return this.currentTapStrain * current.rhythmMultiplier;
1099
1079
  }
1080
+ calculateInitialStrain(time, current) {
1081
+ return (this.currentTapStrain *
1082
+ this.currentRhythmMultiplier *
1083
+ this.strainDecay(time - (current.previous(0)?.startTime ?? 0)));
1084
+ }
1100
1085
  /**
1101
1086
  * @param current The hitobject to save to.
1102
1087
  */
1103
1088
  saveToHitObject(current) {
1104
- current.tapStrain = this.currentStrain;
1105
- current.originalTapStrain = this.currentOriginalTapStrain;
1089
+ const strain = this.currentTapStrain * this.currentRhythmMultiplier;
1090
+ if (this.considerCheesability) {
1091
+ current.tapStrain = strain;
1092
+ }
1093
+ else {
1094
+ current.originalTapStrain = strain;
1095
+ }
1106
1096
  }
1107
1097
  }
1108
1098
 
@@ -1210,33 +1200,36 @@ class DroidFlashlightEvaluator extends FlashlightEvaluator {
1210
1200
  * Represents the skill required to memorize and hit every object in a beatmap with the Flashlight mod enabled.
1211
1201
  */
1212
1202
  class DroidFlashlight extends DroidSkill {
1213
- skillMultiplier = 0.052;
1214
1203
  strainDecayBase = 0.15;
1215
1204
  reducedSectionCount = 0;
1216
1205
  reducedSectionBaseline = 1;
1217
1206
  starsPerDouble = 1.06;
1207
+ skillMultiplier = 0.052;
1218
1208
  isHidden;
1219
1209
  withSliders;
1210
+ currentFlashlightStrain = 0;
1220
1211
  constructor(mods, withSliders) {
1221
1212
  super(mods);
1222
1213
  this.isHidden = mods.some((m) => m instanceof osuBase.ModHidden);
1223
1214
  this.withSliders = withSliders;
1224
1215
  }
1225
- /**
1226
- * @param current The hitobject to calculate.
1227
- */
1228
1216
  strainValueAt(current) {
1229
- this.currentStrain *= this.strainDecay(current.deltaTime);
1230
- this.currentStrain +=
1217
+ this.currentFlashlightStrain *= this.strainDecay(current.deltaTime);
1218
+ this.currentFlashlightStrain +=
1231
1219
  DroidFlashlightEvaluator.evaluateDifficultyOf(current, this.isHidden, this.withSliders) * this.skillMultiplier;
1232
- return this.currentStrain;
1220
+ return this.currentFlashlightStrain;
1221
+ }
1222
+ calculateInitialStrain(time, current) {
1223
+ return (this.currentFlashlightStrain *
1224
+ this.strainDecay(time - (current.previous(0)?.startTime ?? 0)));
1233
1225
  }
1234
1226
  saveToHitObject(current) {
1235
1227
  if (this.withSliders) {
1236
- current.flashlightStrainWithSliders = this.currentStrain;
1228
+ current.flashlightStrainWithSliders = this.currentFlashlightStrain;
1237
1229
  }
1238
1230
  else {
1239
- current.flashlightStrainWithoutSliders = this.currentStrain;
1231
+ current.flashlightStrainWithoutSliders =
1232
+ this.currentFlashlightStrain;
1240
1233
  }
1241
1234
  }
1242
1235
  difficultyValue() {
@@ -1310,8 +1303,8 @@ class DroidRhythmEvaluator extends RhythmEvaluator {
1310
1303
  Math.min(0.5, Math.pow(Math.sin(Math.PI /
1311
1304
  (Math.min(prevDelta, currentDelta) /
1312
1305
  Math.max(prevDelta, currentDelta))), 2));
1313
- const windowPenalty = Math.min(1, Math.max(0, Math.abs(prevDelta - currentDelta) - greatWindow * 0.4) /
1314
- (greatWindow * 0.4));
1306
+ const windowPenalty = Math.min(1, Math.max(0, Math.abs(prevDelta - currentDelta) - greatWindow * 0.6) /
1307
+ (greatWindow * 0.6));
1315
1308
  let effectiveRatio = windowPenalty * currentRatio;
1316
1309
  if (firstDeltaSwitch) {
1317
1310
  if (prevDelta <= 1.25 * currentDelta &&
@@ -1388,26 +1381,31 @@ class DroidRhythmEvaluator extends RhythmEvaluator {
1388
1381
  * Represents the skill required to properly follow a beatmap's rhythm.
1389
1382
  */
1390
1383
  class DroidRhythm extends DroidSkill {
1391
- skillMultiplier = 1;
1392
1384
  reducedSectionCount = 5;
1393
1385
  reducedSectionBaseline = 0.75;
1394
1386
  strainDecayBase = 0.3;
1395
1387
  starsPerDouble = 1.75;
1396
- currentRhythm = 1;
1388
+ currentRhythmStrain = 0;
1389
+ currentRhythmMultiplier = 1;
1397
1390
  hitWindow;
1398
1391
  constructor(mods, overallDifficulty) {
1399
1392
  super(mods);
1400
1393
  this.hitWindow = new osuBase.OsuHitWindow(overallDifficulty);
1401
1394
  }
1402
1395
  strainValueAt(current) {
1403
- this.currentRhythm = DroidRhythmEvaluator.evaluateDifficultyOf(current, this.hitWindow.hitWindowFor300());
1404
- this.currentStrain *= this.strainDecay(current.deltaTime);
1405
- this.currentStrain += this.currentRhythm - 1;
1406
- return this.currentStrain;
1396
+ this.currentRhythmMultiplier =
1397
+ DroidRhythmEvaluator.evaluateDifficultyOf(current, this.hitWindow.hitWindowFor300());
1398
+ this.currentRhythmStrain *= this.strainDecay(current.deltaTime);
1399
+ this.currentRhythmStrain += this.currentRhythmMultiplier - 1;
1400
+ return this.currentRhythmStrain;
1401
+ }
1402
+ calculateInitialStrain(time, current) {
1403
+ return (this.currentRhythmStrain *
1404
+ this.strainDecay(time - (current.previous(0)?.startTime ?? 0)));
1407
1405
  }
1408
1406
  saveToHitObject(current) {
1409
- current.rhythmStrain = this.currentStrain;
1410
- current.rhythmMultiplier = this.currentRhythm;
1407
+ current.rhythmStrain = this.currentRhythmStrain;
1408
+ current.rhythmMultiplier = this.currentRhythmMultiplier;
1411
1409
  }
1412
1410
  }
1413
1411
 
@@ -1472,12 +1470,14 @@ class DroidVisualEvaluator {
1472
1470
  }
1473
1471
  if (current.object instanceof osuBase.Slider && withSliders) {
1474
1472
  const scalingFactor = 50 / current.object.getRadius(osuBase.Modes.droid);
1475
- // Reward sliders based on velocity.
1473
+ // Invert the scaling factor to determine the true travel distance independent of circle size.
1474
+ const pixelTravelDistance = current.object.lazyTravelDistance / scalingFactor;
1475
+ const currentVelocity = pixelTravelDistance / current.travelTime;
1476
1476
  strain +=
1477
- // Avoid overbuffing extremely fast sliders.
1478
- Math.min(6, current.velocity * 1.5) *
1479
- // Scale with distance travelled to avoid overbuffing fast sliders with short distance.
1480
- Math.min(1, current.travelDistance / scalingFactor / 125);
1477
+ // Reward sliders based on velocity, while also avoiding overbuffing extremely fast sliders.
1478
+ Math.min(6, currentVelocity * 1.5) *
1479
+ // Longer sliders require more reading.
1480
+ (pixelTravelDistance / 100);
1481
1481
  let cumulativeStrainTime = 0;
1482
1482
  // Reward for velocity changes based on last few sliders.
1483
1483
  for (let i = 0; i < Math.min(current.index, 4); ++i) {
@@ -1488,12 +1488,16 @@ class DroidVisualEvaluator {
1488
1488
  last.isOverlapping(true)) {
1489
1489
  continue;
1490
1490
  }
1491
+ // Invert the scaling factor to determine the true travel distance independent of circle size.
1492
+ const pixelTravelDistance = last.object.lazyTravelDistance / scalingFactor;
1493
+ const lastVelocity = pixelTravelDistance / last.travelTime;
1491
1494
  strain +=
1492
- // Avoid overbuffing extremely fast velocity changes.
1493
- Math.min(10, 2.5 * Math.abs(current.velocity - last.velocity)) *
1494
- // Scale with distance travelled to avoid overbuffing fast sliders with short distance.
1495
- Math.min(1, last.travelDistance / scalingFactor / 100) *
1496
- // Scale with cumulative strain time to avoid overbuffing past sliders.
1495
+ // Reward past sliders based on velocity changes, while also
1496
+ // avoiding overbuffing extremely fast velocity changes.
1497
+ Math.min(10, 2.5 * Math.abs(currentVelocity - lastVelocity)) *
1498
+ // Longer sliders require more reading.
1499
+ (pixelTravelDistance / 125) *
1500
+ // Avoid overbuffing past sliders.
1497
1501
  Math.min(1, 300 / cumulativeStrainTime);
1498
1502
  }
1499
1503
  }
@@ -1508,27 +1512,36 @@ class DroidVisual extends DroidSkill {
1508
1512
  starsPerDouble = 1.025;
1509
1513
  reducedSectionCount = 10;
1510
1514
  reducedSectionBaseline = 0.75;
1511
- skillMultiplier = 10;
1512
1515
  strainDecayBase = 0.1;
1513
1516
  isHidden;
1514
- withsliders;
1517
+ withSliders;
1518
+ currentVisualStrain = 0;
1519
+ currentRhythmMultiplier = 1;
1520
+ skillMultiplier = 10;
1515
1521
  constructor(mods, withSliders) {
1516
1522
  super(mods);
1517
1523
  this.isHidden = mods.some((m) => m instanceof osuBase.ModHidden);
1518
- this.withsliders = withSliders;
1524
+ this.withSliders = withSliders;
1519
1525
  }
1520
1526
  strainValueAt(current) {
1521
- this.currentStrain *= this.strainDecay(current.deltaTime);
1522
- this.currentStrain +=
1523
- DroidVisualEvaluator.evaluateDifficultyOf(current, this.isHidden, this.withsliders) * this.skillMultiplier;
1524
- return this.currentStrain * (1 + (current.rhythmMultiplier - 1) / 5);
1527
+ this.currentVisualStrain *= this.strainDecay(current.deltaTime);
1528
+ this.currentVisualStrain +=
1529
+ DroidVisualEvaluator.evaluateDifficultyOf(current, this.isHidden, this.withSliders) * this.skillMultiplier;
1530
+ this.currentRhythmMultiplier = current.rhythmMultiplier;
1531
+ return this.currentVisualStrain * this.currentRhythmMultiplier;
1532
+ }
1533
+ calculateInitialStrain(time, current) {
1534
+ return (this.currentVisualStrain *
1535
+ this.currentRhythmMultiplier *
1536
+ this.strainDecay(time - (current.previous(0)?.startTime ?? 0)));
1525
1537
  }
1526
1538
  saveToHitObject(current) {
1527
- if (this.withsliders) {
1528
- current.visualStrainWithSliders = this.currentStrain;
1539
+ const strain = this.currentVisualStrain * this.currentRhythmMultiplier;
1540
+ if (this.withSliders) {
1541
+ current.visualStrainWithSliders = strain;
1529
1542
  }
1530
1543
  else {
1531
- current.visualStrainWithoutSliders = this.currentStrain;
1544
+ current.visualStrainWithoutSliders = strain;
1532
1545
  }
1533
1546
  }
1534
1547
  }
@@ -1606,25 +1619,16 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
1606
1619
  * Calculates the tap star rating of the beatmap and stores it in this instance.
1607
1620
  */
1608
1621
  calculateTap() {
1609
- const tapSkill = new DroidTap(this.mods, this.stats.od);
1610
- this.calculateSkills(tapSkill);
1611
- if (this.mods.some((m) => m instanceof osuBase.ModRelax)) {
1612
- this.tap = this.attributes.tapDifficulty = 0;
1613
- this.attributes.possibleThreeFingeredSections = [];
1614
- }
1615
- else {
1616
- this.postCalculateTap(tapSkill);
1617
- }
1618
- this.calculateSpeedAttributes();
1622
+ const od = this.stats.od;
1623
+ const tapSkillCheese = new DroidTap(this.mods, od, true);
1624
+ const tapSkillNoCheese = new DroidTap(this.mods, od, false);
1625
+ this.calculateSkills(tapSkillCheese, tapSkillNoCheese);
1626
+ this.postCalculateTap(tapSkillCheese);
1619
1627
  }
1620
1628
  /**
1621
1629
  * Calculates the rhythm star rating of the beatmap and stores it in this instance.
1622
1630
  */
1623
1631
  calculateRhythm() {
1624
- if (this.mods.some((m) => m instanceof osuBase.ModRelax)) {
1625
- this.rhythm = this.attributes.rhythmDifficulty = 0;
1626
- return;
1627
- }
1628
1632
  const rhythmSkill = new DroidRhythm(this.mods, this.stats.od);
1629
1633
  this.calculateSkills(rhythmSkill);
1630
1634
  this.postCalculateRhythm(rhythmSkill);
@@ -1676,39 +1680,21 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
1676
1680
  }
1677
1681
  calculateAll() {
1678
1682
  const skills = this.createSkills();
1679
- const isRelax = this.mods.some((m) => m instanceof osuBase.ModRelax);
1680
- if (isRelax) {
1681
- // Remove visual skills to reduce overhead.
1682
- skills.pop();
1683
- skills.pop();
1684
- }
1685
1683
  this.calculateSkills(...skills);
1686
1684
  const aimSkill = skills[0];
1687
1685
  const aimSkillWithoutSliders = skills[1];
1688
1686
  const rhythmSkill = skills[2];
1689
- const tapSkill = skills[3];
1690
- const flashlightSkill = skills[4];
1691
- const flashlightSkillWithoutSliders = skills[5];
1692
- const visualSkill = skills[6] ?? null;
1693
- const visualSkillWithoutSliders = skills[7] ?? null;
1687
+ const tapSkillCheese = skills[3];
1688
+ const flashlightSkill = skills[5];
1689
+ const flashlightSkillWithoutSliders = skills[6];
1690
+ const visualSkill = skills[7];
1691
+ const visualSkillWithoutSliders = skills[8];
1694
1692
  this.postCalculateAim(aimSkill, aimSkillWithoutSliders);
1695
- if (isRelax) {
1696
- this.tap = this.attributes.tapDifficulty = 0;
1697
- }
1698
- else {
1699
- this.postCalculateTap(tapSkill);
1700
- }
1701
- this.calculateSpeedAttributes();
1702
- if (!isRelax) {
1703
- this.postCalculateRhythm(rhythmSkill);
1704
- }
1693
+ this.postCalculateTap(tapSkillCheese);
1694
+ this.calculateTapAttributes();
1695
+ this.postCalculateRhythm(rhythmSkill);
1705
1696
  this.postCalculateFlashlight(flashlightSkill, flashlightSkillWithoutSliders);
1706
- if (visualSkill && visualSkillWithoutSliders) {
1707
- this.postCalculateVisual(visualSkill, visualSkillWithoutSliders);
1708
- }
1709
- else {
1710
- this.visual = this.attributes.visualDifficulty = 0;
1711
- }
1697
+ this.postCalculateVisual(visualSkill, visualSkillWithoutSliders);
1712
1698
  this.calculateTotal();
1713
1699
  }
1714
1700
  toString() {
@@ -1733,12 +1719,14 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
1733
1719
  osuBase.HitObjectStackEvaluator.applyDroidStacking(this.beatmap.hitObjects.objects, this.beatmap.general.stackLeniency);
1734
1720
  }
1735
1721
  createSkills() {
1722
+ const od = this.stats.od;
1736
1723
  return [
1737
1724
  new DroidAim(this.mods, true),
1738
1725
  new DroidAim(this.mods, false),
1739
1726
  // Tap skill depends on rhythm skill, so we put it first
1740
- new DroidRhythm(this.mods, this.stats.od),
1741
- new DroidTap(this.mods, this.stats.od),
1727
+ new DroidRhythm(this.mods, od),
1728
+ new DroidTap(this.mods, od, true),
1729
+ new DroidTap(this.mods, od, false),
1742
1730
  new DroidFlashlight(this.mods, true),
1743
1731
  new DroidFlashlight(this.mods, false),
1744
1732
  new DroidVisual(this.mods, true),
@@ -1810,16 +1798,23 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
1810
1798
  /**
1811
1799
  * Called after tap skill calculation.
1812
1800
  *
1813
- * @param tapSkill The tap skill.
1801
+ * @param tapSkillCheese The tap skill that considers cheesing.
1814
1802
  */
1815
- postCalculateTap(tapSkill) {
1816
- this.strainPeaks.speed = tapSkill.strainPeaks;
1817
- this.tap = this.attributes.tapDifficulty = this.starValue(tapSkill.difficultyValue());
1803
+ postCalculateTap(tapSkillCheese) {
1804
+ this.strainPeaks.speed = tapSkillCheese.strainPeaks;
1805
+ if (this.mods.some((m) => m instanceof osuBase.ModRelax)) {
1806
+ this.tap = this.attributes.tapDifficulty = 0;
1807
+ this.attributes.possibleThreeFingeredSections = [];
1808
+ }
1809
+ else {
1810
+ this.tap = this.attributes.tapDifficulty = this.starValue(tapSkillCheese.difficultyValue());
1811
+ }
1812
+ this.calculateTapAttributes();
1818
1813
  }
1819
1814
  /**
1820
- * Calculates speed-related attributes.
1815
+ * Calculates tap-related attributes.
1821
1816
  */
1822
- calculateSpeedAttributes() {
1817
+ calculateTapAttributes() {
1823
1818
  this.attributes.possibleThreeFingeredSections = [];
1824
1819
  const tempSections = [];
1825
1820
  const objectStrains = [];
@@ -2016,7 +2011,7 @@ class PerformanceCalculator {
2016
2011
  calculate(options) {
2017
2012
  this.handleOptions(options);
2018
2013
  this.calculateValues();
2019
- this.calculateTotalValue();
2014
+ this.total = this.calculateTotalValue();
2020
2015
  return this;
2021
2016
  }
2022
2017
  /**
@@ -2230,9 +2225,9 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2230
2225
  if (value === this._tapPenalty) {
2231
2226
  return;
2232
2227
  }
2233
- this.tap *= this._tapPenalty / value;
2234
2228
  this._tapPenalty = value;
2235
- this.calculateTotalValue();
2229
+ this.tap = this.calculateTapValue();
2230
+ this.total = this.calculateTotalValue();
2236
2231
  }
2237
2232
  /**
2238
2233
  * Applies an aim slider cheese penalty value to this calculator.
@@ -2252,8 +2247,8 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2252
2247
  return;
2253
2248
  }
2254
2249
  this._aimSliderCheesePenalty = value;
2255
- this.calculateAimValue();
2256
- this.calculateTotalValue();
2250
+ this.aim = this.calculateAimValue();
2251
+ this.total = this.calculateTotalValue();
2257
2252
  }
2258
2253
  /**
2259
2254
  * Applies a flashlight slider cheese penalty value to this calculator.
@@ -2273,8 +2268,8 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2273
2268
  return;
2274
2269
  }
2275
2270
  this._flashlightSliderCheesePenalty = value;
2276
- this.calculateFlashlightValue();
2277
- this.calculateTotalValue();
2271
+ this.flashlight = this.calculateFlashlightValue();
2272
+ this.total = this.calculateTotalValue();
2278
2273
  }
2279
2274
  /**
2280
2275
  * Applies a visual slider cheese penalty value to this calculator.
@@ -2294,25 +2289,24 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2294
2289
  return;
2295
2290
  }
2296
2291
  this._visualSliderCheesePenalty = value;
2297
- this.calculateVisualValue();
2298
- this.calculateTotalValue();
2292
+ this.visual = this.calculateVisualValue();
2293
+ this.total = this.calculateTotalValue();
2299
2294
  }
2300
2295
  calculateValues() {
2301
2296
  this._deviation = this.calculateDeviation();
2302
2297
  this._tapDeviation = this.calculateTapDeviation();
2303
- this.calculateAimValue();
2304
- this.calculateTapValue();
2305
- this.calculateAccuracyValue();
2306
- this.calculateFlashlightValue();
2307
- this.calculateVisualValue();
2298
+ this.aim = this.calculateAimValue();
2299
+ this.tap = this.calculateTapValue();
2300
+ this.accuracy = this.calculateAccuracyValue();
2301
+ this.flashlight = this.calculateFlashlightValue();
2302
+ this.visual = this.calculateVisualValue();
2308
2303
  }
2309
2304
  calculateTotalValue() {
2310
- this.total =
2311
- Math.pow(Math.pow(this.aim, 1.1) +
2312
- Math.pow(this.tap, 1.1) +
2313
- Math.pow(this.accuracy, 1.1) +
2314
- Math.pow(this.flashlight, 1.1) +
2315
- Math.pow(this.visual, 1.1), 1 / 1.1) * this.finalMultiplier;
2305
+ return (Math.pow(Math.pow(this.aim, 1.1) +
2306
+ Math.pow(this.tap, 1.1) +
2307
+ Math.pow(this.accuracy, 1.1) +
2308
+ Math.pow(this.flashlight, 1.1) +
2309
+ Math.pow(this.visual, 1.1), 1 / 1.1) * this.finalMultiplier);
2316
2310
  }
2317
2311
  handleOptions(options) {
2318
2312
  this._tapPenalty = options?.tapPenalty ?? 1;
@@ -2327,23 +2321,31 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2327
2321
  * Calculates the aim performance value of the beatmap.
2328
2322
  */
2329
2323
  calculateAimValue() {
2330
- this.aim = this.baseValue(Math.pow(this.difficultyAttributes.aimDifficulty, 0.8));
2331
- this.aim *= this.calculateMissPenalty(this.difficultyAttributes.aimDifficultStrainCount);
2324
+ let aimValue = this.baseValue(Math.pow(this.difficultyAttributes.aimDifficulty, 0.8));
2325
+ aimValue *= this.proportionalMissPenalty;
2326
+ // Scale the aim value with estimated full combo deviation.
2327
+ aimValue *= this.calculateDeviationBasedLengthScaling();
2332
2328
  // Scale the aim value with slider factor to nerf very likely dropped sliderends.
2333
- this.aim *= this.sliderNerfFactor;
2329
+ aimValue *= this.sliderNerfFactor;
2334
2330
  // Scale the aim value with slider cheese penalty.
2335
- this.aim *= this._aimSliderCheesePenalty;
2331
+ aimValue *= this._aimSliderCheesePenalty;
2336
2332
  // Scale the aim value with deviation.
2337
- this.aim *=
2333
+ aimValue *=
2338
2334
  1.05 *
2339
- Math.pow(osuBase.ErrorFunction.erf(32.0625 / (Math.SQRT2 * this._deviation)), 1.5);
2335
+ Math.sqrt(osuBase.ErrorFunction.erf(25 / (Math.SQRT2 * this._deviation)));
2336
+ // OD 7 SS stays the same.
2337
+ aimValue *= 0.98 + Math.pow(7, 2) / 2500;
2338
+ return aimValue;
2340
2339
  }
2341
2340
  /**
2342
2341
  * Calculates the tap performance value of the beatmap.
2343
2342
  */
2344
2343
  calculateTapValue() {
2345
- this.tap = this.baseValue(this.difficultyAttributes.tapDifficulty);
2346
- this.tap *= this.calculateMissPenalty(this.difficultyAttributes.tapDifficultStrainCount);
2344
+ let tapValue = this.baseValue(this.difficultyAttributes.tapDifficulty);
2345
+ tapValue *= this.calculateStrainBasedMissPenalty(this.difficultyAttributes.tapDifficultStrainCount);
2346
+ // Scale the tap value with estimated full combo deviation.
2347
+ // Require more objects to be present as object count can rack up easily in tap-oriented beatmaps.
2348
+ tapValue *= this.calculateDeviationBasedLengthScaling(this.totalHits / 1.45);
2347
2349
  // Normalize the deviation to 300 BPM.
2348
2350
  const normalizedDeviation = this.tapDeviation *
2349
2351
  Math.max(1, 50 / this.difficultyAttributes.averageSpeedDeltaTime);
@@ -2357,11 +2359,14 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2357
2359
  Math.exp(-(normalizedDeviation - 7500 / averageBPM) /
2358
2360
  ((2 * 300) / averageBPM))));
2359
2361
  // Scale the tap value with tap deviation.
2360
- this.tap *=
2362
+ tapValue *=
2361
2363
  1.1 *
2362
- Math.pow(osuBase.ErrorFunction.erf(25 / (Math.SQRT2 * adjustedDeviation)), 1.25);
2364
+ Math.pow(osuBase.ErrorFunction.erf(20 / (Math.SQRT2 * adjustedDeviation)), 0.625);
2363
2365
  // Scale the tap value with three-fingered penalty.
2364
- this.tap /= this._tapPenalty;
2366
+ tapValue /= this._tapPenalty;
2367
+ // OD 8 SS stays the same.
2368
+ tapValue *= 0.95 + Math.pow(8, 2) / 750;
2369
+ return tapValue;
2365
2370
  }
2366
2371
  /**
2367
2372
  * Calculates the accuracy performance value of the beatmap.
@@ -2369,77 +2374,75 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2369
2374
  calculateAccuracyValue() {
2370
2375
  if (this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModRelax) ||
2371
2376
  this.totalSuccessfulHits === 0) {
2372
- this.accuracy = 0;
2373
- return;
2377
+ return 0;
2374
2378
  }
2375
- this.accuracy =
2376
- 650 *
2377
- Math.exp(-0.1 * this._deviation) *
2378
- // The following function is to give higher reward for deviations lower than 25 (250 UR).
2379
- (15 / (this._deviation + 15) + 0.65);
2380
- // Bonus for many hitcircles - it's harder to keep good accuracy up for longer.
2379
+ let accuracyValue = 800 * Math.exp(-0.1 * this._deviation);
2381
2380
  const ncircles = this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModScoreV2)
2382
2381
  ? this.totalHits - this.difficultyAttributes.spinnerCount
2383
2382
  : this.difficultyAttributes.hitCircleCount;
2384
- this.accuracy *= Math.min(1.15, Math.sqrt(Math.log(1 + ((Math.E - 1) * ncircles) / 1000)));
2383
+ // Bonus for many hitcircles - it's harder to keep good accuracy up for longer.
2384
+ accuracyValue *= Math.min(1.15, Math.sqrt(Math.log(1 + ((Math.E - 1) * ncircles) / 1000)));
2385
2385
  // Scale the accuracy value with rhythm complexity.
2386
- this.accuracy *=
2386
+ accuracyValue *=
2387
2387
  1.5 /
2388
2388
  (1 +
2389
2389
  Math.exp(-(this.difficultyAttributes.rhythmDifficulty - 1) / 2));
2390
+ // Penalize accuracy pp after the first miss.
2391
+ accuracyValue *= Math.pow(0.97, Math.max(0, this.effectiveMissCount - 1));
2390
2392
  if (this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModFlashlight)) {
2391
- this.accuracy *= 1.02;
2393
+ accuracyValue *= 1.02;
2392
2394
  }
2395
+ return accuracyValue;
2393
2396
  }
2394
2397
  /**
2395
2398
  * Calculates the flashlight performance value of the beatmap.
2396
2399
  */
2397
2400
  calculateFlashlightValue() {
2398
2401
  if (!this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModFlashlight)) {
2399
- this.flashlight = 0;
2400
- return;
2402
+ return 0;
2401
2403
  }
2402
- this.flashlight =
2403
- Math.pow(this.difficultyAttributes.flashlightDifficulty, 1.6) * 25;
2404
- this.flashlight *= this.calculateMissPenalty(this.difficultyAttributes.flashlightDifficultStrainCount);
2404
+ let flashlightValue = Math.pow(this.difficultyAttributes.flashlightDifficulty, 1.6) * 25;
2405
+ flashlightValue *= this.proportionalMissPenalty;
2405
2406
  // Account for shorter maps having a higher ratio of 0 combo/100 combo flashlight radius.
2406
- this.flashlight *=
2407
+ flashlightValue *=
2407
2408
  0.7 +
2408
2409
  0.1 * Math.min(1, this.totalHits / 200) +
2409
2410
  (this.totalHits > 200
2410
2411
  ? 0.2 * Math.min(1, (this.totalHits - 200) / 200)
2411
2412
  : 0);
2412
2413
  // Scale the flashlight value with slider cheese penalty.
2413
- this.flashlight *= this._flashlightSliderCheesePenalty;
2414
+ flashlightValue *= this._flashlightSliderCheesePenalty;
2414
2415
  // Scale the flashlight value with deviation.
2415
- this.flashlight *= osuBase.ErrorFunction.erf(50 / (Math.SQRT2 * this._deviation));
2416
+ flashlightValue *= osuBase.ErrorFunction.erf(50 / (Math.SQRT2 * this._deviation));
2417
+ return flashlightValue;
2416
2418
  }
2417
2419
  /**
2418
2420
  * Calculates the visual performance value of the beatmap.
2419
2421
  */
2420
2422
  calculateVisualValue() {
2421
- this.visual =
2422
- Math.pow(this.difficultyAttributes.visualDifficulty, 1.6) * 22.5;
2423
- this.visual *= this.calculateMissPenalty(this.difficultyAttributes.visualDifficultStrainCount);
2424
- // Scale the visual value with object count to penalize short maps.
2425
- this.visual *= Math.min(1, 1.650668 +
2426
- (0.4845796 - 1.650668) /
2427
- (1 + Math.pow(this.totalHits / 817.9306, 1.147469)));
2423
+ let visualValue = Math.pow(this.difficultyAttributes.visualDifficulty, 1.6) * 22.5;
2424
+ visualValue *= this.proportionalMissPenalty;
2425
+ // Scale the visual value with estimated full combo deviation.
2426
+ // As visual is easily "bypassable" with memorization, punish for memorization.
2427
+ visualValue *= this.calculateDeviationBasedLengthScaling(undefined, true);
2428
2428
  // Scale the visual value with slider cheese penalty.
2429
- this.visual *= this._visualSliderCheesePenalty;
2429
+ visualValue *= this._visualSliderCheesePenalty;
2430
2430
  // Scale the visual value with deviation.
2431
- this.visual *=
2431
+ visualValue *=
2432
2432
  1.065 *
2433
- Math.pow(osuBase.ErrorFunction.erf(30 / (Math.SQRT2 * this._deviation)), 1.75);
2433
+ Math.pow(osuBase.ErrorFunction.erf(25 / (Math.SQRT2 * this._deviation)), 0.8);
2434
+ // OD 5 SS stays the same.
2435
+ visualValue *= 0.98 + Math.pow(5, 2) / 2500;
2436
+ return visualValue;
2434
2437
  }
2435
2438
  /**
2436
- * Calculates miss penalty.
2439
+ * Calculates a strain-based miss penalty.
2437
2440
  *
2438
- * Miss penalty assumes that a player will miss on the hardest parts of a map,
2441
+ * Strain-based miss penalty assumes that a player will miss on the hardest parts of a map,
2439
2442
  * so we use the amount of relatively difficult sections to adjust miss penalty
2440
2443
  * to make it more punishing on maps with lower amount of hard sections.
2441
2444
  */
2442
- calculateMissPenalty(difficultStrainCount) {
2445
+ calculateStrainBasedMissPenalty(difficultStrainCount) {
2443
2446
  if (this.effectiveMissCount === 0) {
2444
2447
  return 1;
2445
2448
  }
@@ -2447,6 +2450,52 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2447
2450
  (this.effectiveMissCount / (2 * Math.sqrt(difficultStrainCount)) +
2448
2451
  1));
2449
2452
  }
2453
+ /**
2454
+ * The object-based proportional miss penalty.
2455
+ */
2456
+ get proportionalMissPenalty() {
2457
+ if (this.effectiveMissCount === 0) {
2458
+ return 1;
2459
+ }
2460
+ const missProportion = (this.totalHits - this.effectiveMissCount) / (this.totalHits + 1);
2461
+ const noMissProportion = this.totalHits / (this.totalHits + 1);
2462
+ return (
2463
+ // Aim deviation-based scale.
2464
+ (osuBase.ErrorFunction.erfInv(missProportion) /
2465
+ osuBase.ErrorFunction.erfInv(noMissProportion)) *
2466
+ // Cheesing-based scale (i.e. 50% misses is deliberately only hitting each other
2467
+ // note, 90% misses is deliberately only hitting 1 note every 10 notes).
2468
+ Math.pow(missProportion, 8));
2469
+ }
2470
+ /**
2471
+ * Calculates the object-based length scaling based on the deviation of a player for a full
2472
+ * combo in this beatmap, taking retries into account.
2473
+ *
2474
+ * @param objectCount The amount of objects to be considered. Defaults to the amount of
2475
+ * objects in this beatmap.
2476
+ * @param punishForMemorization Whether to punish the deviation for memorization. Defaults to `false`.
2477
+ */
2478
+ calculateDeviationBasedLengthScaling(objectCount = this.totalHits, punishForMemorization = false) {
2479
+ // Assume a sample proportion of hits for a full combo to be `(n - 0.5) / n` due to
2480
+ // continuity correction, where `n` is the object count.
2481
+ const calculateProportion = (notes) => (notes - 0.5) / notes;
2482
+ // Keeping `x` notes as the benchmark, assume that a player will retry a beatmap
2483
+ // `max(1, x/n)` times relative to an `x`-note beatmap.
2484
+ const benchmarkNotes = 700;
2485
+ // Calculate the proportion equivalent to the bottom half of retry count percentile of
2486
+ // scores and take it as the player's "real" proportion.
2487
+ const retryProportion = (proportion, notes, tries) => proportion +
2488
+ Math.sqrt((2 * proportion * (1 - proportion)) / notes) *
2489
+ osuBase.ErrorFunction.erfInv(1 / tries - 1);
2490
+ // Using the proportion, we calculate the deviation based off that proportion and again
2491
+ // compared to the hit deviation for proportion `(n - 0.5) / n`.
2492
+ let multiplier = Math.max(0, osuBase.ErrorFunction.erfInv(retryProportion(calculateProportion(objectCount), objectCount, Math.max(1, benchmarkNotes / objectCount))) / osuBase.ErrorFunction.erfInv(calculateProportion(benchmarkNotes)) || 0);
2493
+ // Punish for memorization if needed.
2494
+ if (punishForMemorization) {
2495
+ multiplier *= Math.min(1, Math.sqrt(objectCount / benchmarkNotes));
2496
+ }
2497
+ return multiplier;
2498
+ }
2450
2499
  /**
2451
2500
  * Estimates the player's tap deviation based on the OD, number of circles and sliders,
2452
2501
  * and number of 300s, 100s, 50s, and misses, assuming the player's mean hit error is 0.
@@ -2467,60 +2516,60 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2467
2516
  }
2468
2517
  const hitWindow300 = new osuBase.OsuHitWindow(this.difficultyAttributes.overallDifficulty).hitWindowFor300();
2469
2518
  // Obtain the 50 and 100 hit window for droid.
2470
- const realHitWindow300 = hitWindow300 * this.difficultyAttributes.clockRate;
2471
- const droidHitWindow = new osuBase.DroidHitWindow(osuBase.OsuHitWindow.hitWindow300ToOD(realHitWindow300));
2472
2519
  const isPrecise = this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModPrecise);
2520
+ const droidHitWindow = new osuBase.DroidHitWindow(osuBase.DroidHitWindow.hitWindow300ToOD(hitWindow300 * this.difficultyAttributes.clockRate, isPrecise));
2473
2521
  const hitWindow50 = droidHitWindow.hitWindowFor50(isPrecise) /
2474
2522
  this.difficultyAttributes.clockRate;
2475
2523
  const hitWindow100 = droidHitWindow.hitWindowFor100(isPrecise) /
2476
2524
  this.difficultyAttributes.clockRate;
2477
- const { n300, n100, n50, nmiss } = this.computedAccuracy;
2478
- const greatCountOnCircles = this.difficultyAttributes.hitCircleCount - n100 - n50 - nmiss;
2479
- // The probability that a player hits a circle is unknown, but we can estimate it to be
2480
- // the number of greats on circles divided by the number of circles, and then add one
2481
- // to the number of circles as a bias correction / bayesian prior.
2482
- const greatProbabilityCircle = Math.max(0, greatCountOnCircles / (this.difficultyAttributes.hitCircleCount + 1));
2483
- let greatProbabilitySlider;
2484
- if (greatCountOnCircles < 0) {
2485
- const nonCircleMisses = -greatCountOnCircles;
2486
- greatProbabilitySlider = Math.max(0, (this.difficultyAttributes.sliderCount - nonCircleMisses) /
2487
- (this.difficultyAttributes.sliderCount + 1));
2488
- }
2489
- else {
2490
- greatProbabilitySlider =
2491
- this.difficultyAttributes.sliderCount /
2492
- (this.difficultyAttributes.sliderCount + 1);
2493
- }
2494
- if (greatProbabilityCircle === 0 && greatProbabilitySlider === 0) {
2495
- return Number.POSITIVE_INFINITY;
2496
- }
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));
2525
+ const { n100, n50, nmiss } = this.computedAccuracy;
2526
+ const circleCount = this.difficultyAttributes.hitCircleCount;
2527
+ const missCountCircles = Math.min(nmiss, circleCount);
2528
+ const mehCountCircles = Math.min(n50, circleCount - missCountCircles);
2529
+ const okCountCircles = Math.min(n100, circleCount - missCountCircles - mehCountCircles);
2530
+ const greatCountCircles = Math.max(0, circleCount - missCountCircles - mehCountCircles - okCountCircles);
2531
+ // Assume 100s, 50s, and misses happen on circles. If there are less non-300s on circles than 300s,
2532
+ // compute the deviation on circles.
2533
+ if (greatCountCircles > 0) {
2534
+ // The probability that a player hits a circle is unknown, but we can estimate it to be
2535
+ // the number of greats on circles divided by the number of circles, and then add one
2536
+ // to the number of circles as a bias correction / bayesian prior.
2537
+ const greatProbabilityCircle = Math.max(0, greatCountCircles / (greatCountCircles + okCountCircles + 1));
2538
+ // Compute the deviation assuming 300s and 100s are normally distributed, and 50s are uniformly distributed.
2539
+ // Begin with the normal distribution first.
2540
+ const deviationOnCircles = hitWindow300 /
2541
+ (Math.SQRT2 * osuBase.ErrorFunction.erfInv(greatProbabilityCircle));
2504
2542
  // Get the variance of the truncated variable.
2505
- const truncatedVariance = Math.pow(normalDeviation, 2) -
2506
- (Math.SQRT2 *
2543
+ const truncatedVariance = Math.pow(deviationOnCircles, 2) -
2544
+ (Math.sqrt(2 / Math.PI) *
2507
2545
  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);
2523
- return Math.min(deviationOnCircles, deviationOnSliders);
2546
+ deviationOnCircles *
2547
+ Math.exp(-0.5 * Math.pow(hitWindow100 / deviationOnCircles, 2))) /
2548
+ osuBase.ErrorFunction.erf(hitWindow100 / (Math.SQRT2 * deviationOnCircles));
2549
+ // Then compute the variance for 50s.
2550
+ const mehVariance = (Math.pow(hitWindow50, 2) +
2551
+ hitWindow100 * hitWindow50 +
2552
+ Math.pow(hitWindow100, 2)) /
2553
+ 3;
2554
+ // Find the total deviation.
2555
+ return Math.sqrt(((greatCountCircles + okCountCircles) * truncatedVariance +
2556
+ mehCountCircles * mehVariance) /
2557
+ (greatCountCircles + okCountCircles + mehCountCircles));
2558
+ }
2559
+ // If there are more non-300s than there are circles, compute the deviation on sliders instead.
2560
+ // Here, all that matters is whether or not the slider was missed, since it is impossible
2561
+ // to get a 100 or 50 on a slider by mis-tapping it.
2562
+ const sliderCount = this.difficultyAttributes.sliderCount;
2563
+ const missCountSliders = Math.min(sliderCount, nmiss - missCountCircles);
2564
+ const greatCountSliders = sliderCount - missCountSliders;
2565
+ // We only get here if nothing was hit. In this case, there is no estimate for deviation.
2566
+ // Note that this is never negative, so checking if this is only equal to 0 makes sense.
2567
+ if (greatCountSliders === 0) {
2568
+ return Number.POSITIVE_INFINITY;
2569
+ }
2570
+ const greatProbabilitySlider = greatCountSliders / (sliderCount + 1);
2571
+ return (hitWindow50 /
2572
+ (Math.SQRT2 * osuBase.ErrorFunction.erfInv(greatProbabilitySlider)));
2524
2573
  }
2525
2574
  /**
2526
2575
  * Does the same as {@link calculateDeviation}, but only for notes and inaccuracies that are relevant to tap difficulty.
@@ -2533,15 +2582,7 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2533
2582
  return Number.POSITIVE_INFINITY;
2534
2583
  }
2535
2584
  const hitWindow300 = new osuBase.OsuHitWindow(this.difficultyAttributes.overallDifficulty).hitWindowFor300();
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;
2585
+ const { n100, n50, nmiss } = this.computedAccuracy;
2545
2586
  // Assume a fixed ratio of non-300s hit in speed notes based on speed note count ratio and OD.
2546
2587
  // Graph: https://www.desmos.com/calculator/31argjcxqc
2547
2588
  const speedNoteRatio = this.difficultyAttributes.speedNoteCount / this.totalHits;
@@ -2556,25 +2597,7 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2556
2597
  return Number.POSITIVE_INFINITY;
2557
2598
  }
2558
2599
  const greatProbability = relevantCountGreat / (this.difficultyAttributes.speedNoteCount + 1);
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));
2600
+ return (hitWindow300 / (Math.SQRT2 * osuBase.ErrorFunction.erfInv(greatProbability)));
2578
2601
  }
2579
2602
  toString() {
2580
2603
  return (this.total.toFixed(2) +
@@ -2761,35 +2784,37 @@ class OsuAimEvaluator extends AimEvaluator {
2761
2784
  * Represents the skill required to correctly aim at every object in the map with a uniform CircleSize and normalized distances.
2762
2785
  */
2763
2786
  class OsuAim extends OsuSkill {
2764
- skillMultiplier = 23.55;
2765
2787
  strainDecayBase = 0.15;
2766
2788
  reducedSectionCount = 10;
2767
2789
  reducedSectionBaseline = 0.75;
2768
2790
  decayWeight = 0.9;
2791
+ currentAimStrain = 0;
2792
+ skillMultiplier = 23.55;
2769
2793
  withSliders;
2770
2794
  constructor(mods, withSliders) {
2771
2795
  super(mods);
2772
2796
  this.withSliders = withSliders;
2773
2797
  }
2774
- /**
2775
- * @param current The hitobject to calculate.
2776
- */
2777
2798
  strainValueAt(current) {
2778
- this.currentStrain *= this.strainDecay(current.deltaTime);
2779
- this.currentStrain +=
2799
+ this.currentAimStrain *= this.strainDecay(current.deltaTime);
2800
+ this.currentAimStrain +=
2780
2801
  OsuAimEvaluator.evaluateDifficultyOf(current, this.withSliders) *
2781
2802
  this.skillMultiplier;
2782
- return this.currentStrain;
2803
+ return this.currentAimStrain;
2804
+ }
2805
+ calculateInitialStrain(time, current) {
2806
+ return (this.currentAimStrain *
2807
+ this.strainDecay(time - (current.previous(0)?.startTime ?? 0)));
2783
2808
  }
2784
2809
  /**
2785
2810
  * @param current The hitobject to save to.
2786
2811
  */
2787
2812
  saveToHitObject(current) {
2788
2813
  if (this.withSliders) {
2789
- current.aimStrainWithSliders = this.currentStrain;
2814
+ current.aimStrainWithSliders = this.currentAimStrain;
2790
2815
  }
2791
2816
  else {
2792
- current.aimStrainWithoutSliders = this.currentStrain;
2817
+ current.aimStrainWithoutSliders = this.currentAimStrain;
2793
2818
  }
2794
2819
  }
2795
2820
  }
@@ -2961,7 +2986,6 @@ class OsuRhythmEvaluator extends RhythmEvaluator {
2961
2986
  * Represents the skill required to press keys or tap with regards to keeping up with the speed at which objects need to be hit.
2962
2987
  */
2963
2988
  class OsuSpeed extends OsuSkill {
2964
- skillMultiplier = 1375;
2965
2989
  strainDecayBase = 0.3;
2966
2990
  reducedSectionCount = 5;
2967
2991
  reducedSectionBaseline = 0.75;
@@ -2969,6 +2993,7 @@ class OsuSpeed extends OsuSkill {
2969
2993
  decayWeight = 0.9;
2970
2994
  currentSpeedStrain = 0;
2971
2995
  currentRhythm = 0;
2996
+ skillMultiplier = 1375;
2972
2997
  greatWindow;
2973
2998
  constructor(mods, greatWindow) {
2974
2999
  super(mods);
@@ -2985,11 +3010,16 @@ class OsuSpeed extends OsuSkill {
2985
3010
  this.currentRhythm = OsuRhythmEvaluator.evaluateDifficultyOf(current, this.greatWindow);
2986
3011
  return this.currentSpeedStrain * this.currentRhythm;
2987
3012
  }
3013
+ calculateInitialStrain(time, current) {
3014
+ return (this.currentSpeedStrain *
3015
+ this.currentRhythm *
3016
+ this.strainDecay(time - (current.previous(0)?.startTime ?? 0)));
3017
+ }
2988
3018
  /**
2989
3019
  * @param current The hitobject to save to.
2990
3020
  */
2991
3021
  saveToHitObject(current) {
2992
- current.tapStrain = this.currentStrain;
3022
+ current.tapStrain = this.currentSpeedStrain * this.currentRhythm;
2993
3023
  current.rhythmMultiplier = this.currentRhythm;
2994
3024
  }
2995
3025
  }
@@ -3080,27 +3110,29 @@ class OsuFlashlightEvaluator extends FlashlightEvaluator {
3080
3110
  * Represents the skill required to memorize and hit every object in a beatmap with the Flashlight mod enabled.
3081
3111
  */
3082
3112
  class OsuFlashlight extends OsuSkill {
3083
- skillMultiplier = 0.052;
3084
3113
  strainDecayBase = 0.15;
3085
3114
  reducedSectionCount = 0;
3086
3115
  reducedSectionBaseline = 1;
3087
3116
  decayWeight = 1;
3117
+ currentFlashlightStrain = 0;
3118
+ skillMultiplier = 0.052;
3088
3119
  isHidden;
3089
3120
  constructor(mods) {
3090
3121
  super(mods);
3091
3122
  this.isHidden = mods.some((m) => m instanceof osuBase.ModHidden);
3092
3123
  }
3093
- /**
3094
- * @param current The hitobject to calculate.
3095
- */
3096
3124
  strainValueAt(current) {
3097
- this.currentStrain *= this.strainDecay(current.deltaTime);
3098
- this.currentStrain +=
3125
+ this.currentFlashlightStrain *= this.strainDecay(current.deltaTime);
3126
+ this.currentFlashlightStrain +=
3099
3127
  OsuFlashlightEvaluator.evaluateDifficultyOf(current, this.isHidden) * this.skillMultiplier;
3100
- return this.currentStrain;
3128
+ return this.currentFlashlightStrain;
3129
+ }
3130
+ calculateInitialStrain(time, current) {
3131
+ return (this.currentFlashlightStrain *
3132
+ this.strainDecay(time - (current.previous(0)?.startTime ?? 0)));
3101
3133
  }
3102
3134
  saveToHitObject(current) {
3103
- current.flashlightStrainWithSliders = this.currentStrain;
3135
+ current.flashlightStrainWithSliders = this.currentFlashlightStrain;
3104
3136
  }
3105
3137
  }
3106
3138
 
@@ -3151,20 +3183,9 @@ class OsuDifficultyCalculator extends DifficultyCalculator {
3151
3183
  * Calculates the speed star rating of the beatmap and stores it in this instance.
3152
3184
  */
3153
3185
  calculateSpeed() {
3154
- if (this.mods.some((m) => m instanceof osuBase.ModRelax)) {
3155
- this.speed = this.attributes.speedDifficulty = 0;
3156
- return;
3157
- }
3158
3186
  const speedSkill = new OsuSpeed(this.mods, new osuBase.OsuHitWindow(this.stats.od).hitWindowFor300());
3159
3187
  this.calculateSkills(speedSkill);
3160
- if (this.mods.some((m) => m instanceof osuBase.ModRelax)) {
3161
- this.speed = 0;
3162
- this.attributes.speedDifficulty = 0;
3163
- }
3164
- else {
3165
- this.postCalculateSpeed(speedSkill);
3166
- }
3167
- this.calculateSpeedAttributes();
3188
+ this.postCalculateSpeed(speedSkill);
3168
3189
  }
3169
3190
  /**
3170
3191
  * Calculates the flashlight star rating of the beatmap and stores it in this instance.
@@ -3199,20 +3220,13 @@ class OsuDifficultyCalculator extends DifficultyCalculator {
3199
3220
  }
3200
3221
  calculateAll() {
3201
3222
  const skills = this.createSkills();
3202
- const isRelax = this.mods.some((m) => m instanceof osuBase.ModRelax);
3203
3223
  this.calculateSkills(...skills);
3204
3224
  const aimSkill = skills[0];
3205
3225
  const aimSkillWithoutSliders = skills[1];
3206
3226
  const speedSkill = skills[2];
3207
3227
  const flashlightSkill = skills[3];
3208
3228
  this.postCalculateAim(aimSkill, aimSkillWithoutSliders);
3209
- if (isRelax) {
3210
- this.speed = 0;
3211
- this.attributes.speedDifficulty = 0;
3212
- }
3213
- else {
3214
- this.postCalculateSpeed(speedSkill);
3215
- }
3229
+ this.postCalculateSpeed(speedSkill);
3216
3230
  this.calculateSpeedAttributes();
3217
3231
  this.postCalculateFlashlight(flashlightSkill);
3218
3232
  this.calculateTotal();
@@ -3276,7 +3290,10 @@ class OsuDifficultyCalculator extends DifficultyCalculator {
3276
3290
  */
3277
3291
  postCalculateSpeed(speedSkill) {
3278
3292
  this.strainPeaks.speed = speedSkill.strainPeaks;
3279
- this.speed = this.attributes.speedDifficulty = this.starValue(speedSkill.difficultyValue());
3293
+ this.speed = this.attributes.speedDifficulty = this.mods.some((m) => m instanceof osuBase.ModRelax)
3294
+ ? 0
3295
+ : this.starValue(speedSkill.difficultyValue());
3296
+ this.calculateSpeedAttributes();
3280
3297
  }
3281
3298
  /**
3282
3299
  * Calculates speed-related attributes.
@@ -3371,17 +3388,16 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
3371
3388
  finalMultiplier = 1.14;
3372
3389
  mode = osuBase.Modes.osu;
3373
3390
  calculateValues() {
3374
- this.calculateAimValue();
3375
- this.calculateSpeedValue();
3376
- this.calculateAccuracyValue();
3377
- this.calculateFlashlightValue();
3391
+ this.aim = this.calculateAimValue();
3392
+ this.speed = this.calculateSpeedValue();
3393
+ this.accuracy = this.calculateAccuracyValue();
3394
+ this.flashlight = this.calculateFlashlightValue();
3378
3395
  }
3379
3396
  calculateTotalValue() {
3380
- this.total =
3381
- Math.pow(Math.pow(this.aim, 1.1) +
3382
- Math.pow(this.speed, 1.1) +
3383
- Math.pow(this.accuracy, 1.1) +
3384
- Math.pow(this.flashlight, 1.1), 1 / 1.1) * this.finalMultiplier;
3397
+ return (Math.pow(Math.pow(this.aim, 1.1) +
3398
+ Math.pow(this.speed, 1.1) +
3399
+ Math.pow(this.accuracy, 1.1) +
3400
+ Math.pow(this.flashlight, 1.1), 1 / 1.1) * this.finalMultiplier);
3385
3401
  }
3386
3402
  /**
3387
3403
  * @param difficultyAttributes The difficulty attributes to calculate.
@@ -3394,23 +3410,23 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
3394
3410
  * Calculates the aim performance value of the beatmap.
3395
3411
  */
3396
3412
  calculateAimValue() {
3397
- this.aim = this.baseValue(this.difficultyAttributes.aimDifficulty);
3413
+ let aimValue = this.baseValue(this.difficultyAttributes.aimDifficulty);
3398
3414
  // Longer maps are worth more
3399
3415
  let lengthBonus = 0.95 + 0.4 * Math.min(1, this.totalHits / 2000);
3400
3416
  if (this.totalHits > 2000) {
3401
3417
  lengthBonus += Math.log10(this.totalHits / 2000) * 0.5;
3402
3418
  }
3403
- this.aim *= lengthBonus;
3419
+ aimValue *= lengthBonus;
3404
3420
  if (this.effectiveMissCount > 0) {
3405
3421
  // Penalize misses by assessing # of misses relative to the total # of objects.
3406
3422
  // Default a 3% reduction for any # of misses.
3407
- this.aim *=
3423
+ aimValue *=
3408
3424
  0.97 *
3409
3425
  Math.pow(1 -
3410
3426
  Math.pow(this.effectiveMissCount / this.totalHits, 0.775), this.effectiveMissCount);
3411
3427
  }
3412
3428
  // Combo scaling
3413
- this.aim *= this.comboPenalty;
3429
+ aimValue *= this.comboPenalty;
3414
3430
  const calculatedAR = this.difficultyAttributes.approachRate;
3415
3431
  if (!this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModRelax)) {
3416
3432
  // AR scaling
@@ -3422,66 +3438,70 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
3422
3438
  arFactor += 0.05 * (8 - calculatedAR);
3423
3439
  }
3424
3440
  // Buff for longer maps with high AR.
3425
- this.aim *= 1 + arFactor * lengthBonus;
3441
+ aimValue *= 1 + arFactor * lengthBonus;
3426
3442
  }
3427
3443
  // We want to give more reward for lower AR when it comes to aim and HD. This nerfs high AR and buffs lower AR.
3428
3444
  if (this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModHidden)) {
3429
- this.aim *= 1 + 0.04 * (12 - calculatedAR);
3445
+ aimValue *= 1 + 0.04 * (12 - calculatedAR);
3430
3446
  }
3431
3447
  // Scale the aim value with slider factor to nerf very likely dropped sliderends.
3432
- this.aim *= this.sliderNerfFactor;
3448
+ aimValue *= this.sliderNerfFactor;
3433
3449
  // Scale the aim value with accuracy.
3434
- this.aim *= this.computedAccuracy.value();
3450
+ aimValue *= this.computedAccuracy.value();
3435
3451
  // It is also important to consider accuracy difficulty when doing that.
3436
3452
  const odScaling = Math.pow(this.difficultyAttributes.overallDifficulty, 2) / 2500;
3437
- this.aim *= 0.98 + odScaling;
3453
+ aimValue *= 0.98 + odScaling;
3454
+ return aimValue;
3438
3455
  }
3439
3456
  /**
3440
3457
  * Calculates the speed performance value of the beatmap.
3441
3458
  */
3442
3459
  calculateSpeedValue() {
3443
3460
  if (this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModRelax)) {
3444
- this.speed = 0;
3445
- return;
3461
+ return 0;
3446
3462
  }
3447
- this.speed = this.baseValue(this.difficultyAttributes.speedDifficulty);
3463
+ let speedValue = this.baseValue(this.difficultyAttributes.speedDifficulty);
3448
3464
  // Longer maps are worth more
3449
3465
  let lengthBonus = 0.95 + 0.4 * Math.min(1, this.totalHits / 2000);
3450
3466
  if (this.totalHits > 2000) {
3451
3467
  lengthBonus += Math.log10(this.totalHits / 2000) * 0.5;
3452
3468
  }
3453
- this.speed *= lengthBonus;
3469
+ speedValue *= lengthBonus;
3454
3470
  if (this.effectiveMissCount > 0) {
3455
3471
  // Penalize misses by assessing # of misses relative to the total # of objects.
3456
3472
  // Default a 3% reduction for any # of misses.
3457
- this.speed *=
3473
+ speedValue *=
3458
3474
  0.97 *
3459
3475
  Math.pow(1 -
3460
3476
  Math.pow(this.effectiveMissCount / this.totalHits, 0.775), Math.pow(this.effectiveMissCount, 0.875));
3461
3477
  }
3462
3478
  // Combo scaling
3463
- this.speed *= this.comboPenalty;
3479
+ speedValue *= this.comboPenalty;
3464
3480
  // AR scaling
3465
3481
  const calculatedAR = this.difficultyAttributes.approachRate;
3466
3482
  if (calculatedAR > 10.33) {
3467
3483
  // Buff for longer maps with high AR.
3468
- this.speed *= 1 + 0.3 * (calculatedAR - 10.33) * lengthBonus;
3484
+ speedValue *= 1 + 0.3 * (calculatedAR - 10.33) * lengthBonus;
3469
3485
  }
3470
3486
  if (this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModHidden)) {
3471
- this.speed *= 1 + 0.04 * (12 - calculatedAR);
3487
+ speedValue *= 1 + 0.04 * (12 - calculatedAR);
3472
3488
  }
3473
3489
  // Calculate accuracy assuming the worst case scenario.
3474
3490
  const countGreat = this.computedAccuracy.n300;
3475
3491
  const countOk = this.computedAccuracy.n100;
3476
3492
  const countMeh = this.computedAccuracy.n50;
3477
3493
  const relevantTotalDiff = this.totalHits - this.difficultyAttributes.speedNoteCount;
3478
- const relevantAccuracy = new osuBase.Accuracy({
3479
- n300: Math.max(0, countGreat - relevantTotalDiff),
3480
- n100: Math.max(0, countOk - Math.max(0, relevantTotalDiff - countGreat)),
3481
- n50: Math.max(0, countMeh - Math.max(0, relevantTotalDiff - countGreat - countOk)),
3482
- });
3494
+ const relevantAccuracy = new osuBase.Accuracy(this.difficultyAttributes.speedNoteCount > 0
3495
+ ? {
3496
+ n300: Math.max(0, countGreat - relevantTotalDiff),
3497
+ n100: Math.max(0, countOk - Math.max(0, relevantTotalDiff - countGreat)),
3498
+ n50: Math.max(0, countMeh -
3499
+ Math.max(0, relevantTotalDiff - countGreat - countOk)),
3500
+ }
3501
+ : // Set accuracy to 0.
3502
+ { n300: 0, nobjects: 1 });
3483
3503
  // Scale the speed value with accuracy and OD.
3484
- this.speed *=
3504
+ speedValue *=
3485
3505
  (0.95 +
3486
3506
  Math.pow(this.difficultyAttributes.overallDifficulty, 2) /
3487
3507
  750) *
@@ -3491,22 +3511,21 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
3491
3511
  Math.max(this.difficultyAttributes.overallDifficulty, 8)) /
3492
3512
  2);
3493
3513
  // Scale the speed value with # of 50s to punish doubletapping.
3494
- this.speed *= Math.pow(0.99, Math.max(0, this.computedAccuracy.n50 - this.totalHits / 500));
3514
+ speedValue *= Math.pow(0.99, Math.max(0, this.computedAccuracy.n50 - this.totalHits / 500));
3515
+ return speedValue;
3495
3516
  }
3496
3517
  /**
3497
3518
  * Calculates the accuracy performance value of the beatmap.
3498
3519
  */
3499
3520
  calculateAccuracyValue() {
3500
3521
  if (this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModRelax)) {
3501
- this.accuracy = 0;
3502
- return;
3522
+ return 0;
3503
3523
  }
3504
3524
  const ncircles = this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModScoreV2)
3505
3525
  ? this.totalHits - this.difficultyAttributes.spinnerCount
3506
3526
  : this.difficultyAttributes.hitCircleCount;
3507
3527
  if (ncircles === 0) {
3508
- this.accuracy = 0;
3509
- return;
3528
+ return 0;
3510
3529
  }
3511
3530
  const realAccuracy = new osuBase.Accuracy({
3512
3531
  ...this.computedAccuracy,
@@ -3514,51 +3533,50 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
3514
3533
  });
3515
3534
  // Lots of arbitrary values from testing.
3516
3535
  // Considering to use derivation from perfect accuracy in a probabilistic manner - assume normal distribution
3517
- this.accuracy =
3518
- Math.pow(1.52163, this.difficultyAttributes.overallDifficulty) *
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) *
3521
- 2.83;
3536
+ let accuracyValue = Math.pow(1.52163, this.difficultyAttributes.overallDifficulty) *
3537
+ // It is possible to reach a negative accuracy with this formula. Cap it at zero - zero points.
3538
+ Math.pow(realAccuracy.n300 < 0 ? 0 : realAccuracy.value(), 24) *
3539
+ 2.83;
3522
3540
  // Bonus for many hitcircles - it's harder to keep good accuracy up for longer
3523
- this.accuracy *= Math.min(1.15, Math.pow(ncircles / 1000, 0.3));
3541
+ accuracyValue *= Math.min(1.15, Math.pow(ncircles / 1000, 0.3));
3524
3542
  if (this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModHidden)) {
3525
- this.accuracy *= 1.08;
3543
+ accuracyValue *= 1.08;
3526
3544
  }
3527
3545
  if (this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModFlashlight)) {
3528
- this.accuracy *= 1.02;
3546
+ accuracyValue *= 1.02;
3529
3547
  }
3548
+ return accuracyValue;
3530
3549
  }
3531
3550
  /**
3532
3551
  * Calculates the flashlight performance value of the beatmap.
3533
3552
  */
3534
3553
  calculateFlashlightValue() {
3535
3554
  if (!this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModFlashlight)) {
3536
- this.flashlight = 0;
3537
- return;
3555
+ return 0;
3538
3556
  }
3539
- this.flashlight =
3540
- Math.pow(this.difficultyAttributes.flashlightDifficulty, 2) * 25;
3557
+ let flashlightValue = Math.pow(this.difficultyAttributes.flashlightDifficulty, 2) * 25;
3541
3558
  // Combo scaling
3542
- this.flashlight *= this.comboPenalty;
3559
+ flashlightValue *= this.comboPenalty;
3543
3560
  if (this.effectiveMissCount > 0) {
3544
3561
  // Penalize misses by assessing # of misses relative to the total # of objects. Default a 3% reduction for any # of misses.
3545
- this.flashlight *=
3562
+ flashlightValue *=
3546
3563
  0.97 *
3547
3564
  Math.pow(1 -
3548
3565
  Math.pow(this.effectiveMissCount / this.totalHits, 0.775), Math.pow(this.effectiveMissCount, 0.875));
3549
3566
  }
3550
3567
  // Account for shorter maps having a higher ratio of 0 combo/100 combo flashlight radius.
3551
- this.flashlight *=
3568
+ flashlightValue *=
3552
3569
  0.7 +
3553
3570
  0.1 * Math.min(1, this.totalHits / 200) +
3554
3571
  (this.totalHits > 200
3555
3572
  ? 0.2 * Math.min(1, (this.totalHits - 200) / 200)
3556
3573
  : 0);
3557
3574
  // Scale the flashlight value with accuracy slightly.
3558
- this.flashlight *= 0.5 + this.computedAccuracy.value() / 2;
3575
+ flashlightValue *= 0.5 + this.computedAccuracy.value() / 2;
3559
3576
  // It is also important to consider accuracy difficulty when doing that.
3560
3577
  const odScaling = Math.pow(this.difficultyAttributes.overallDifficulty, 2) / 2500;
3561
- this.flashlight *= 0.98 + odScaling;
3578
+ flashlightValue *= 0.98 + odScaling;
3579
+ return flashlightValue;
3562
3580
  }
3563
3581
  toString() {
3564
3582
  return (this.total.toFixed(2) +