@rian8337/osu-rebalance-difficulty-calculator 4.0.0-beta.98 → 4.0.0-beta.99

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
@@ -90,7 +90,7 @@ class DifficultyCalculator {
90
90
  }
91
91
  attributes[i] = {
92
92
  time: obj.endTime,
93
- attributes: this.createDifficultyAttributes(beatmap, playableBeatmap, skills, difficultyObjects.slice(0, currentIndex)),
93
+ attributes: this.createDifficultyAttributes(beatmap, progressiveBeatmap, skills, difficultyObjects.slice(0, currentIndex)),
94
94
  sliderCount: progressiveBeatmap.hitObjects.sliders,
95
95
  sliderTickCount: progressiveBeatmap.hitObjects.sliderTicks,
96
96
  sliderRepeatCount: progressiveBeatmap.hitObjects.sliderRepeatPoints
@@ -640,19 +640,12 @@ class DroidSnapAimEvaluator {
640
640
  return 0;
641
641
  }
642
642
  const last = current.previous(0);
643
- const last2 = current.previous(2);
644
- const radius = current.normalizedRadius;
645
- const diameter = current.normalizedDiameter;
646
- // Calculate the velocity to the current hitobject, which starts with a base distance / time assuming the last object is a hitcircle.
643
+ // Calculate the velocity to the current hitobject, which starts with a base distance / time
644
+ // assuming the last object is a hitcircle.
647
645
  const currentDistance = withSliders && !current.is2BSlider
648
646
  ? current.lazyJumpDistance
649
647
  : current.jumpDistance;
650
- let currentVelocity = currentDistance / current.strainTime;
651
- // But if the last object is a slider, then we extend the travel velocity through the slider into the current object.
652
- if (last.object instanceof osuBase.Slider && !last.is2BSlider && withSliders) {
653
- const sliderDistance = last.lazyTravelDistance + current.lazyJumpDistance;
654
- currentVelocity = Math.max(currentVelocity, sliderDistance / current.strainTime);
655
- }
648
+ const currentVelocity = this.calculateCurrentVelocity(current, last, currentDistance, withSliders);
656
649
  const prevDistance = withSliders && !last.is2BSlider
657
650
  ? last.lazyJumpDistance
658
651
  : last.jumpDistance;
@@ -660,99 +653,136 @@ class DroidSnapAimEvaluator {
660
653
  // Start strain with regular velocity.
661
654
  let strain = currentVelocity;
662
655
  strain *= this.calculateVectorAngleRepetition(current, last);
663
- if (current.angle !== null && last.angle !== null) {
664
- const currentAngle = current.angle;
665
- const lastAngle = last.angle;
666
- // Rewarding angles, take the smaller velocity as base.
667
- const velocityInfluence = Math.min(currentVelocity, prevVelocity);
668
- let acuteAngleBonus = 0;
669
- // If rhythms are the same.
670
- if (Math.max(current.strainTime, last.strainTime) <
671
- 1.25 * Math.min(current.strainTime, last.strainTime)) {
672
- acuteAngleBonus = this.calculateAcuteAngleAcuteness(current.angle);
673
- // Penalize angle repetition. It is important to do it _before_ multiplying by anything because we compare raw acuteness here.
674
- acuteAngleBonus *=
675
- 0.08 +
676
- 0.92 *
677
- (1 -
678
- Math.min(acuteAngleBonus, Math.pow(this.calculateAcuteAngleAcuteness(lastAngle), 3)));
679
- // Apply acute angle bonus for BPM above 300 1/2.
680
- acuteAngleBonus *=
681
- velocityInfluence *
682
- osuBase.MathUtils.smootherstep(osuBase.MathUtils.millisecondsToBPM(current.strainTime, 2), 300, 450) *
683
- osuBase.MathUtils.smootherstep(current.lazyJumpDistance, 0, diameter * 2);
684
- }
685
- let wideAngleBonus = this.calculateWideAngleAcuteness(current.angle);
686
- // Penalize angle repetition. It is important to do it _before_ multiplying by velocity because we compare raw wideness here.
687
- wideAngleBonus *=
688
- 0.25 +
689
- 0.75 *
690
- (1 -
691
- Math.min(wideAngleBonus, Math.pow(this.calculateWideAngleAcuteness(lastAngle), 3)));
692
- // Rescale velocity for wide angle bonus.
693
- const wideAngleTimeScale = 1.45;
694
- let wideAngleCurrentVelocity = currentDistance /
695
- Math.pow(current.strainTime, wideAngleTimeScale);
696
- const wideAnglePrevVelocity = prevDistance / Math.pow(last.strainTime, wideAngleTimeScale);
697
- if (last.object instanceof osuBase.Slider && withSliders) {
698
- const sliderDistance = last.lazyTravelDistance + current.lazyJumpDistance;
699
- wideAngleCurrentVelocity = Math.max(wideAngleCurrentVelocity, sliderDistance /
700
- Math.pow(current.strainTime, wideAngleTimeScale));
701
- }
702
- wideAngleBonus *= Math.min(wideAngleCurrentVelocity, wideAnglePrevVelocity);
703
- if (last2 !== null) {
704
- // If objects just go back and forth through a middle point - don't give as much wide bonus.
705
- // Use previous(2) and previous(0) because angles calculation is done prevprev-prev-curr, so any
706
- // object's angle's center point is always the previous object.
707
- const distance = last2.object.stackedPosition.getDistance(last.object.stackedPosition);
708
- if (distance < 1) {
709
- wideAngleBonus *= 1 - 0.55 * (1 - distance);
710
- }
711
- }
712
- // Add in acute angle bonus or wide angle bonus, whichever is larger.
713
- strain += Math.max(acuteAngleBonus * this.acuteAngleMultiplier, wideAngleBonus * this.wideAngleMultiplier);
714
- // Apply wiggle bonus for jumps that are [radius, 3*diameter] in distance, with < 110 angle
715
- // https://www.desmos.com/calculator/dp0v0nvowc
716
- strain +=
717
- velocityInfluence *
718
- osuBase.MathUtils.smootherstep(currentDistance, radius, diameter) *
719
- Math.pow(osuBase.MathUtils.reverseLerp(currentDistance, diameter * 3, diameter), 1.8) *
720
- osuBase.MathUtils.smootherstep(currentAngle, osuBase.MathUtils.degreesToRadians(110), osuBase.MathUtils.degreesToRadians(60)) *
721
- osuBase.MathUtils.smootherstep(prevDistance, radius, diameter) *
722
- Math.pow(osuBase.MathUtils.reverseLerp(prevDistance, diameter * 3, diameter), 1.8) *
723
- osuBase.MathUtils.smootherstep(lastAngle, osuBase.MathUtils.degreesToRadians(110), osuBase.MathUtils.degreesToRadians(60)) *
724
- this.wiggleMultiplier;
725
- }
726
- if (Math.max(prevVelocity, currentVelocity)) {
727
- if (withSliders) {
728
- // We want to use the average velocity over the whole object when awarding differences, not the individual jump and slider path velocities.
729
- currentVelocity = currentDistance / current.strainTime;
730
- }
731
- // Scale with ratio of difference compared to half the max distance.
732
- const distanceRatio = osuBase.MathUtils.smoothstep(Math.abs(prevVelocity - currentVelocity) /
733
- Math.max(prevVelocity, currentVelocity), 0, 1);
734
- // Reward for % distance up to 125 / strainTime for overlaps where velocity is still changing.
735
- const overlapVelocityBuff = Math.min((diameter * 1.25) /
736
- Math.min(current.strainTime, last.strainTime), Math.abs(prevVelocity - currentVelocity));
737
- let velocityChangeBonus = overlapVelocityBuff * distanceRatio;
738
- // Penalize for rhythm changes.
739
- velocityChangeBonus *= Math.pow(Math.min(current.strainTime, last.strainTime) /
740
- Math.max(current.strainTime, last.strainTime), 2);
741
- strain += velocityChangeBonus * this.velocityChangeMultiplier;
742
- }
656
+ const acuteAngleBonus = this.calculateAcuteAngleBonus(current, last, currentVelocity, prevVelocity);
657
+ const wideAngleBonus = this.calculateWideAngleBonus(current, last, currentDistance, prevDistance, withSliders);
658
+ // Add in acute angle bonus or wide angle bonus, whichever is larger.
659
+ strain += Math.max(acuteAngleBonus, wideAngleBonus);
660
+ strain += this.calculateWiggleBonus(current, last, currentVelocity, prevVelocity, currentDistance, prevDistance);
661
+ strain += this.calculateVelocityChangeBonus(withSliders, prevVelocity, currentVelocity, currentDistance, current, last);
743
662
  if (current.object instanceof osuBase.Slider && withSliders) {
744
- // Reward sliders based on velocity.
745
- let sliderBonus = current.travelDistance / current.travelTime;
746
- sliderBonus =
747
- sliderBonus < 1 ? sliderBonus : Math.pow(sliderBonus, 0.75);
748
- strain +=
749
- Math.pow(1 + sliderBonus * this.sliderMultiplier, 1.25) - 1;
663
+ strain += this.calculateSliderBonus(current);
750
664
  }
751
665
  // Apply high circle size bonus
752
666
  strain *= current.smallCircleBonus;
753
667
  strain *= this.highBpmBonus(current.strainTime);
754
668
  return strain;
755
669
  }
670
+ static calculateAcuteAngleBonus(current, last, currentVelocity, prevVelocity) {
671
+ if (current.angle === null || last.angle === null) {
672
+ return 0;
673
+ }
674
+ // Only reward acute angles when rhythms are the same.
675
+ if (Math.max(current.strainTime, last.strainTime) >=
676
+ 1.25 * Math.min(current.strainTime, last.strainTime)) {
677
+ return 0;
678
+ }
679
+ let acuteAngleBonus = this.calculateAcuteAngleAcuteness(current.angle);
680
+ // Penalize angle repetition. It is important to do it _before_ multiplying by anything because we
681
+ // compare raw acuteness here.
682
+ acuteAngleBonus *=
683
+ 0.08 +
684
+ 0.92 *
685
+ (1 -
686
+ Math.min(acuteAngleBonus, Math.pow(this.calculateAcuteAngleAcuteness(last.angle), 3)));
687
+ const velocity = Math.min(currentVelocity, prevVelocity);
688
+ // Apply acute angle bonus for BPM above 300 1/2.
689
+ acuteAngleBonus *=
690
+ velocity *
691
+ osuBase.MathUtils.smootherstep(osuBase.MathUtils.millisecondsToBPM(current.strainTime, 2), 300, 450) *
692
+ osuBase.MathUtils.smootherstep(current.lazyJumpDistance, 0, current.normalizedDiameter * 2);
693
+ return acuteAngleBonus * this.acuteAngleMultiplier;
694
+ }
695
+ static calculateWideAngleBonus(current, last, currentDistance, prevDistance, withSliders) {
696
+ if (current.angle === null || last.angle === null) {
697
+ return 0;
698
+ }
699
+ let wideAngleBonus = this.calculateWideAngleAcuteness(current.angle);
700
+ // Penalize angle repetition. It is important to do it _before_ multiplying by velocity because we
701
+ // compare raw wideness here.
702
+ wideAngleBonus *=
703
+ 0.25 +
704
+ 0.75 *
705
+ (1 -
706
+ Math.min(wideAngleBonus, Math.pow(this.calculateWideAngleAcuteness(last.angle), 3)));
707
+ // Rescale velocity for wide angle bonus.
708
+ const wideAngleTimeScale = 1.45;
709
+ let wideAngleCurrentVelocity = currentDistance / Math.pow(current.strainTime, wideAngleTimeScale);
710
+ const wideAnglePrevVelocity = prevDistance / Math.pow(last.strainTime, wideAngleTimeScale);
711
+ if (last.object instanceof osuBase.Slider && withSliders) {
712
+ const sliderDistance = last.lazyTravelDistance + current.lazyJumpDistance;
713
+ wideAngleCurrentVelocity = Math.max(wideAngleCurrentVelocity, sliderDistance /
714
+ Math.pow(current.strainTime, wideAngleTimeScale));
715
+ }
716
+ wideAngleBonus *= Math.min(wideAngleCurrentVelocity, wideAnglePrevVelocity);
717
+ const last2 = current.previous(2);
718
+ if (last2 !== null) {
719
+ // If objects just go back and forth through a middle point - don't give as much wide bonus.
720
+ // Use previous(2) and previous(0) because angles calculation is done prevprev-prev-curr, so any
721
+ // object's angle's center point is always the previous object.
722
+ const distance = last2.object.stackedPosition.getDistance(last.object.stackedPosition);
723
+ if (distance < 1) {
724
+ wideAngleBonus *= 1 - 0.55 * (1 - distance);
725
+ }
726
+ }
727
+ return wideAngleBonus * this.wideAngleMultiplier;
728
+ }
729
+ static calculateVelocityChangeBonus(withSliders, prevVelocity, currentVelocity, currentDistance, current, last) {
730
+ if (Math.max(prevVelocity, currentVelocity) === 0) {
731
+ return 0;
732
+ }
733
+ if (withSliders) {
734
+ // We want to use the average velocity over the whole object when awarding differences, not the
735
+ // individual jump and slider path velocities.
736
+ currentVelocity = currentDistance / current.strainTime;
737
+ }
738
+ // Scale with ratio of difference compared to half the max distance.
739
+ const distanceRatio = osuBase.MathUtils.smoothstep(Math.abs(prevVelocity - currentVelocity) /
740
+ Math.max(prevVelocity, currentVelocity), 0, 1);
741
+ // Reward for % distance up to 125 / strainTime for overlaps where velocity is still changing.
742
+ const overlapVelocityBuff = Math.min((current.normalizedDiameter * 1.25) /
743
+ Math.min(current.strainTime, last.strainTime), Math.abs(prevVelocity - currentVelocity));
744
+ let velocityChangeBonus = overlapVelocityBuff * distanceRatio;
745
+ // Penalize for rhythm changes.
746
+ velocityChangeBonus *= Math.pow(Math.min(current.strainTime, last.strainTime) /
747
+ Math.max(current.strainTime, last.strainTime), 2);
748
+ return velocityChangeBonus * this.velocityChangeMultiplier;
749
+ }
750
+ /**
751
+ * Difficulty bonus for "wiggle" patterns - jumps that are [radius, 3*diameter] in distance, with < 110 angle.
752
+ * https://www.desmos.com/calculator/dp0v0nvowc
753
+ */
754
+ static calculateWiggleBonus(current, last, currentVelocity, prevVelocity, currentDistance, prevDistance) {
755
+ if (current.angle === null || last.angle === null) {
756
+ return 0;
757
+ }
758
+ const radius = current.normalizedRadius;
759
+ const diameter = current.normalizedDiameter;
760
+ const wiggleBonus = Math.min(currentVelocity, prevVelocity) *
761
+ osuBase.MathUtils.smootherstep(currentDistance, radius, diameter) *
762
+ Math.pow(osuBase.MathUtils.reverseLerp(currentDistance, diameter * 3, diameter), 1.8) *
763
+ osuBase.MathUtils.smootherstep(current.angle, osuBase.MathUtils.degreesToRadians(110), osuBase.MathUtils.degreesToRadians(60)) *
764
+ osuBase.MathUtils.smootherstep(prevDistance, radius, diameter) *
765
+ Math.pow(osuBase.MathUtils.reverseLerp(prevDistance, diameter * 3, diameter), 1.8) *
766
+ osuBase.MathUtils.smootherstep(last.angle, osuBase.MathUtils.degreesToRadians(110), osuBase.MathUtils.degreesToRadians(60));
767
+ return wiggleBonus * this.wiggleMultiplier;
768
+ }
769
+ static calculateSliderBonus(current) {
770
+ // Reward sliders based on velocity.
771
+ let sliderBonus = current.travelDistance / current.travelTime;
772
+ sliderBonus =
773
+ sliderBonus < 1 ? sliderBonus : Math.pow(sliderBonus, 0.75);
774
+ return Math.pow(1 + sliderBonus * this.sliderMultiplier, 1.25) - 1;
775
+ }
776
+ static calculateCurrentVelocity(current, last, currentDistance, withSliders) {
777
+ let currentVelocity = currentDistance / current.strainTime;
778
+ // But if the last object is a slider, then we extend the travel velocity through the slider into
779
+ // the current object.
780
+ if (last.object instanceof osuBase.Slider && !last.is2BSlider && withSliders) {
781
+ const sliderDistance = last.lazyTravelDistance + current.lazyJumpDistance;
782
+ currentVelocity = Math.max(currentVelocity, sliderDistance / current.strainTime);
783
+ }
784
+ return currentVelocity;
785
+ }
756
786
  static calculateWideAngleAcuteness(angle) {
757
787
  return osuBase.MathUtils.smoothstep(angle, osuBase.MathUtils.degreesToRadians(40), osuBase.MathUtils.degreesToRadians(140));
758
788
  }
@@ -847,7 +877,7 @@ class DroidFlowAimEvaluator {
847
877
  // Rhythm changes are harder to flow.
848
878
  flowDifficulty *=
849
879
  1 +
850
- Math.min(0.25, Math.pow((Math.max(current.strainTime, last.strainTime) -
880
+ Math.min(0.1, Math.pow((Math.max(current.strainTime, last.strainTime) -
851
881
  Math.min(current.strainTime, last.strainTime)) /
852
882
  50, 4));
853
883
  if (current.angle !== null && last.angle !== null) {
@@ -1551,7 +1581,7 @@ class DroidReadingEvaluator {
1551
1581
  const distanceInfluenceThreshold = current.normalizedDiameter * 1.25;
1552
1582
  const next = current.next(0);
1553
1583
  // Only allow velocity to buff
1554
- const velocity = Math.max(1, current.lazyJumpDistance / current.strainTime);
1584
+ const velocity = Math.max(1, current.jumpDistance / current.strainTime);
1555
1585
  const currentVisibleObjectDensity = this.retrieveCurrentVisibleObjectDensity(current);
1556
1586
  const pastObjectDifficultyInfluence = this.getPastObjectDifficultyInfluence(current, distanceInfluenceThreshold);
1557
1587
  const constantAngleNerfFactor = this.getConstantAngleNerfFactor(current);
@@ -1825,13 +1855,24 @@ DroidReadingEvaluator.maximumAngleRelevancyTime = 200;
1825
1855
  * Represents the skill required to read every object in the beatmap.
1826
1856
  */
1827
1857
  class DroidReading extends HarmonicSkill {
1828
- constructor(mods, clockRate, hitObjects) {
1829
- super(mods);
1830
- this.clockRate = clockRate;
1831
- this.hitObjects = hitObjects;
1858
+ constructor() {
1859
+ super(...arguments);
1832
1860
  this.currentDifficulty = 0;
1861
+ this.firstObjectStartTime = null;
1833
1862
  this.skillMultiplier = 2.5;
1834
1863
  this.difficultyDecayBase = 0.8;
1864
+ /**
1865
+ * The duration for which the difficulty of objects is reduced, assuming the player has
1866
+ * memorized the beatmap.
1867
+ */
1868
+ this.reducedDifficultyDuration = 40 * 1000;
1869
+ /**
1870
+ * The baseline multiplier applied to the difficulty of the first object.
1871
+ *
1872
+ * Assume that even with full memorization, skill is still required to read and play the
1873
+ * first objects.
1874
+ */
1875
+ this.reducedDifficultyBaseline = 0.2;
1835
1876
  }
1836
1877
  countTopWeightedObjectDifficulties(difficultyValue) {
1837
1878
  if (difficultyValue === 0) {
@@ -1849,21 +1890,26 @@ class DroidReading extends HarmonicSkill {
1849
1890
  osuBase.MathUtils.offsetLogistic(next / consistentTopNote, 1.15, 5, 1.1), 0);
1850
1891
  }
1851
1892
  objectDifficultyOf(current) {
1893
+ var _a;
1852
1894
  const decay = this.difficultyDecay(current.deltaTime);
1895
+ // This currently operates under the assumption that `objectDifficultyOf` is called once
1896
+ // per object, and in order. Under that assumption, we can trust that `current.startTime`
1897
+ // refers to the start time of the first object in the case that `firstObjectStartTime`
1898
+ // is yet to be set.
1899
+ (_a = this.firstObjectStartTime) !== null && _a !== void 0 ? _a : (this.firstObjectStartTime = current.startTime);
1900
+ let currentObjectStrain = this.calculateAdjustedDifficulty(current) *
1901
+ (1 - decay) *
1902
+ this.skillMultiplier;
1903
+ if (current.startTime <=
1904
+ this.firstObjectStartTime + this.reducedDifficultyDuration) {
1905
+ const scale = Math.log10(osuBase.Interpolation.lerp(1, 10, osuBase.MathUtils.clamp((current.startTime - this.firstObjectStartTime) /
1906
+ this.reducedDifficultyDuration, 0, 1)));
1907
+ currentObjectStrain *= osuBase.Interpolation.lerp(this.reducedDifficultyBaseline, 1, scale);
1908
+ }
1853
1909
  this.currentDifficulty *= decay;
1854
- this.currentDifficulty +=
1855
- this.calculateAdjustedDifficulty(current) *
1856
- (1 - decay) *
1857
- this.skillMultiplier;
1910
+ this.currentDifficulty += currentObjectStrain;
1858
1911
  return this.currentDifficulty;
1859
1912
  }
1860
- applyDifficultyTransformation(difficulties) {
1861
- // Assume the first few seconds are completely memorized.
1862
- const reducedNoteCount = this.calculateReducedNoteCount();
1863
- for (let i = 0; i < Math.min(difficulties.length, reducedNoteCount); ++i) {
1864
- difficulties[i] *= Math.log10(osuBase.Interpolation.lerp(1, 10, osuBase.MathUtils.clamp(i / reducedNoteCount, 0, 1)));
1865
- }
1866
- }
1867
1913
  saveToHitObject(current, difficulty) {
1868
1914
  current.readingDifficulty = difficulty;
1869
1915
  }
@@ -1877,25 +1923,6 @@ class DroidReading extends HarmonicSkill {
1877
1923
  }
1878
1924
  return difficulty;
1879
1925
  }
1880
- calculateReducedNoteCount() {
1881
- if (this.hitObjects.length < 2) {
1882
- return 0;
1883
- }
1884
- const reducedDifficultyDuration = 60 * 1000;
1885
- // We take the 2nd note to match `createDifficultyHitObjects`
1886
- const firstDifficultyObject = this.hitObjects[1];
1887
- const reducedDuration = firstDifficultyObject.startTime / this.clockRate +
1888
- reducedDifficultyDuration;
1889
- let reducedNoteCount = 0;
1890
- for (let i = 1; i < this.hitObjects.length; ++i) {
1891
- const object = this.hitObjects[i];
1892
- if (object.startTime / this.clockRate > reducedDuration) {
1893
- break;
1894
- }
1895
- ++reducedNoteCount;
1896
- }
1897
- return reducedNoteCount;
1898
- }
1899
1926
  difficultyDecay(ms) {
1900
1927
  return Math.pow(this.difficultyDecayBase, ms / 1000);
1901
1928
  }
@@ -2202,7 +2229,8 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2202
2229
  * Calculates the tap performance value of the beatmap.
2203
2230
  */
2204
2231
  calculateTapValue() {
2205
- const tapDifficulty = this.difficultyAttributes.tapDifficulty * this.calculateTapHighDeviationNerf();
2232
+ const tapDifficulty = this.difficultyAttributes.tapDifficulty *
2233
+ this.calculateTapHighDeviationNerf();
2206
2234
  let tapValue = DroidTap.difficultyToPerformance(tapDifficulty);
2207
2235
  if (this._effectiveMissCount > 0) {
2208
2236
  const tapEstimatedSliderBreaks = this.calculateEstimatedSliderBreaks(this.difficultyAttributes.tapTopWeightedSliderFactor);
@@ -2292,7 +2320,8 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2292
2320
  return 1;
2293
2321
  }
2294
2322
  // https://www.desmos.com/calculator/naggvbcz0a
2295
- return 0.93 / (missCount / (4 * Math.log(difficultStrainCount)) + 1);
2323
+ return (0.93 /
2324
+ (missCount / (4 * Math.log(Math.max(1, difficultStrainCount))) + 1));
2296
2325
  }
2297
2326
  /**
2298
2327
  * The object-based proportional miss penalty.
@@ -2464,7 +2493,8 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2464
2493
  excessTapDifficultyCutoff / scale);
2465
2494
  // 250 UR and less are considered tapped correctly to ensure that normal scores will be punished as little as possible.
2466
2495
  const t = 1 - osuBase.Interpolation.reverseLerp(this.tapDeviation, 25, 30);
2467
- return osuBase.Interpolation.lerp(adjustedTapDifficulty, tapDifficulty, t) / tapDifficulty;
2496
+ return (osuBase.Interpolation.lerp(adjustedTapDifficulty, tapDifficulty, t) /
2497
+ tapDifficulty);
2468
2498
  }
2469
2499
  getHitWindow() {
2470
2500
  const { overallDifficulty } = this.difficultyAttributes;
@@ -2735,7 +2765,10 @@ class DifficultyHitObject {
2735
2765
  this.deltaTime = this.startTime - lastObject.startTime / clockRate;
2736
2766
  // Capped to 25ms to prevent difficulty calculation breaking from simultaneous objects.
2737
2767
  this.strainTime = Math.max(this.deltaTime, DifficultyHitObject.minDeltaTime);
2738
- this.lastObjectEndDeltaTime = Math.max(this.startTime - lastObject.endTime / clockRate, DifficultyHitObject.minDeltaTime);
2768
+ const previousDifficultyObject = this.previous(0);
2769
+ this.lastObjectEndDeltaTime = previousDifficultyObject
2770
+ ? Math.max(this.startTime - previousDifficultyObject.endTime, DifficultyHitObject.minDeltaTime)
2771
+ : this.strainTime;
2739
2772
  }
2740
2773
  else {
2741
2774
  this.deltaTime = 0;
@@ -3523,6 +3556,8 @@ class DroidScoreUtils {
3523
3556
  *
3524
3557
  * @param beatmap The `Beatmap` to calculate the maximum spinner bonus for.
3525
3558
  * @param playableBeatmap The `PlayableBeatmap` to calculate the maximum spinner bonus for.
3559
+ * Only base `PlayableBeatmap` members are used, so a progressive (as-of-a-point-in-time)
3560
+ * beatmap can be passed here too - see `DifficultyCalculator.calculateTimed`.
3526
3561
  * @returns The maximum spinner bonus.
3527
3562
  */
3528
3563
  static calculateMaximumSpinnerBonus(beatmap, playableBeatmap) {
@@ -3627,7 +3662,7 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
3627
3662
  skills.push(new DroidTap(mods, true));
3628
3663
  skills.push(new DroidTap(mods, false));
3629
3664
  }
3630
- skills.push(new DroidReading(mods, beatmap.speedMultiplier, beatmap.hitObjects.objects));
3665
+ skills.push(new DroidReading(mods));
3631
3666
  if (mods.has(osuBase.ModFlashlight)) {
3632
3667
  skills.push(new DroidFlashlight(mods, beatmap.hitObjects.objects.length));
3633
3668
  }
@@ -3940,120 +3975,146 @@ class OsuSnapAimEvaluator {
3940
3975
  last.object instanceof osuBase.Spinner) {
3941
3976
  return 0;
3942
3977
  }
3943
- const last2 = current.previous(2);
3944
- const radius = current.normalizedRadius;
3945
- const diameter = current.normalizedDiameter;
3946
- // Calculate the velocity to the current hitobject, which starts with a base distance / time assuming the last object is a hitcircle.
3947
3978
  const currentDistance = withSliders
3948
3979
  ? current.lazyJumpDistance
3949
3980
  : current.jumpDistance;
3950
- let currentVelocity = currentDistance / current.strainTime;
3951
- // But if the last object is a slider, then we extend the travel velocity through the slider into the current object.
3952
- if (last.object instanceof osuBase.Slider && withSliders) {
3953
- const sliderDistance = last.lazyTravelDistance + current.lazyJumpDistance;
3954
- currentVelocity = Math.max(currentVelocity, sliderDistance / current.strainTime);
3955
- }
3981
+ const currentVelocity = this.calculateCurrentVelocity(current, last, currentDistance, withSliders);
3956
3982
  const prevDistance = withSliders
3957
3983
  ? last.lazyJumpDistance
3958
3984
  : last.jumpDistance;
3959
3985
  const prevVelocity = prevDistance / last.strainTime;
3960
3986
  // Start strain with regular velocity.
3961
3987
  let strain = currentVelocity;
3988
+ // Penalize angle repetition.
3962
3989
  strain *= this.calculateVectorAngleRepetition(current, last);
3963
- if (current.angle !== null && last.angle !== null) {
3964
- const currentAngle = current.angle;
3965
- const lastAngle = last.angle;
3966
- // Rewarding angles, take the smaller velocity as base.
3967
- const velocityInfluence = Math.min(currentVelocity, prevVelocity);
3968
- let acuteAngleBonus = 0;
3969
- if (
3970
- // If rhythms are the same.
3971
- Math.max(current.strainTime, last.strainTime) <
3972
- 1.25 * Math.min(current.strainTime, last.strainTime)) {
3973
- acuteAngleBonus =
3974
- this.calculateAcuteAngleAcuteness(currentAngle);
3975
- // Penalize angle repetition. It is important to do it _before_ multiplying by anything because we compare raw acuteness here.
3976
- acuteAngleBonus *=
3977
- 0.08 +
3978
- 0.92 *
3979
- (1 -
3980
- Math.min(acuteAngleBonus, Math.pow(this.calculateAcuteAngleAcuteness(lastAngle), 3)));
3981
- // Apply acute angle bonus for BPM above 300 1/2.
3982
- acuteAngleBonus *=
3983
- velocityInfluence *
3984
- osuBase.MathUtils.smootherstep(osuBase.MathUtils.millisecondsToBPM(current.strainTime, 2), 300, 400) *
3985
- osuBase.MathUtils.smootherstep(currentDistance, 0, diameter * 2);
3986
- }
3987
- let wideAngleBonus = this.calculateWideAngleAcuteness(currentAngle);
3988
- // Penalize angle repetition. It is important to do it _before_ multiplying by velocity because we compare raw wideness here.
3989
- wideAngleBonus *=
3990
- 0.25 +
3991
- 0.75 *
3992
- (1 -
3993
- Math.min(wideAngleBonus, Math.pow(this.calculateWideAngleAcuteness(lastAngle), 3)));
3994
- // Rescale velocity for wide angle bonus.
3995
- const wideAngleTimeScale = 1.45;
3996
- let wideAngleCurrentVelocity = currentDistance /
3997
- Math.pow(current.strainTime, wideAngleTimeScale);
3998
- const wideAnglePrevVelocity = prevDistance / Math.pow(last.strainTime, wideAngleTimeScale);
3999
- if (last.object instanceof osuBase.Slider && withSliders) {
4000
- const sliderDistance = last.lazyTravelDistance + current.lazyJumpDistance;
4001
- wideAngleCurrentVelocity = Math.max(wideAngleCurrentVelocity, sliderDistance /
4002
- Math.pow(current.strainTime, wideAngleTimeScale));
4003
- }
4004
- wideAngleBonus *= Math.min(wideAngleCurrentVelocity, wideAnglePrevVelocity);
4005
- if (last2 !== null) {
4006
- // If objects just go back and forth through a middle point - don't give as much wide bonus.
4007
- // Use previous(2) and previous(0) because angles calculation is done prevprev-prev-curr, so any
4008
- // object's angle's center point is always the previous object.
4009
- const distance = last2.object.stackedPosition.getDistance(last.object.stackedPosition);
4010
- if (distance < 1) {
4011
- wideAngleBonus *= 1 - 0.55 * (1 - distance);
4012
- }
4013
- }
4014
- // Add in acute angle bonus or wide angle bonus, whichever is larger.
4015
- strain += Math.max(acuteAngleBonus * this.acuteAngleMultiplier, wideAngleBonus * this.wideAngleMultiplier);
4016
- // Apply wiggle bonus for jumps that are [radius, 3*diameter] in distance, with < 110 angle
4017
- // https://www.desmos.com/calculator/dp0v0nvowc
4018
- strain +=
4019
- velocityInfluence *
4020
- osuBase.MathUtils.smootherstep(currentDistance, radius, diameter) *
4021
- Math.pow(osuBase.MathUtils.reverseLerp(currentDistance, diameter * 3, diameter), 1.8) *
4022
- osuBase.MathUtils.smootherstep(currentAngle, osuBase.MathUtils.degreesToRadians(110), osuBase.MathUtils.degreesToRadians(60)) *
4023
- osuBase.MathUtils.smootherstep(prevDistance, radius, diameter) *
4024
- Math.pow(osuBase.MathUtils.reverseLerp(prevDistance, diameter * 3, diameter), 1.8) *
4025
- osuBase.MathUtils.smootherstep(lastAngle, osuBase.MathUtils.degreesToRadians(110), osuBase.MathUtils.degreesToRadians(60)) *
4026
- this.wiggleMultiplier;
4027
- }
4028
- if (Math.max(prevVelocity, currentVelocity)) {
4029
- if (withSliders) {
4030
- // We want to use the average velocity over the whole object when awarding differences, not the individual jump and slider path velocities.
4031
- currentVelocity = currentDistance / current.strainTime;
4032
- }
4033
- // Scale with ratio of difference compared to half the max distance.
4034
- const distanceRatio = osuBase.MathUtils.smoothstep(Math.abs(prevVelocity - currentVelocity) /
4035
- Math.max(prevVelocity, currentVelocity), 0, 1);
4036
- // Reward for % distance up to 125 / strainTime for overlaps where velocity is still changing.
4037
- const overlapVelocityBuff = Math.min((diameter * 1.25) /
4038
- Math.min(current.strainTime, last.strainTime), Math.abs(prevVelocity - currentVelocity));
4039
- let velocityChangeBonus = overlapVelocityBuff * distanceRatio;
4040
- // Penalize for rhythm changes.
4041
- velocityChangeBonus *= Math.pow(Math.min(current.strainTime, last.strainTime) /
4042
- Math.max(current.strainTime, last.strainTime), 2);
4043
- strain += velocityChangeBonus * this.velocityChangeMultiplier;
4044
- }
3990
+ const acuteAngleBonus = this.calculateAcuteAngleBonus(current, last, currentDistance, currentVelocity, prevVelocity);
3991
+ const wideAngleBonus = this.calculateWideAngleBonus(current, last, currentDistance, prevDistance, withSliders);
3992
+ // Add in acute angle bonus or wide angle bonus, whichever is larger.
3993
+ strain += Math.max(acuteAngleBonus, wideAngleBonus);
3994
+ strain += this.calculateWiggleBonus(current, last, currentVelocity, prevVelocity, currentDistance, prevDistance);
3995
+ strain += this.calculateVelocityChangeBonus(withSliders, prevVelocity, currentVelocity, currentDistance, current, last);
4045
3996
  if (current.object instanceof osuBase.Slider && withSliders) {
4046
- // Reward sliders based on velocity.
4047
- const sliderBonus = current.travelDistance / current.travelTime;
4048
- strain +=
4049
- (sliderBonus < 1 ? sliderBonus : Math.pow(sliderBonus, 0.75)) *
4050
- this.sliderMultiplier;
3997
+ strain += this.calculateSliderBonus(current);
4051
3998
  }
4052
- // Apply high circle size bonus
3999
+ // Apply high circle size bonus.
4053
4000
  strain *= current.smallCircleBonus;
4054
4001
  strain *= this.highBpmBonus(current.strainTime);
4055
4002
  return strain;
4056
4003
  }
4004
+ static calculateAcuteAngleBonus(current, last, currentDistance, currentVelocity, prevVelocity) {
4005
+ if (current.angle === null || last.angle === null) {
4006
+ return 0;
4007
+ }
4008
+ // Only reward acute angles when rhythms are the same.
4009
+ if (Math.max(current.strainTime, last.strainTime) >=
4010
+ 1.25 * Math.min(current.strainTime, last.strainTime)) {
4011
+ return 0;
4012
+ }
4013
+ let acuteAngleBonus = this.calculateAcuteAngleAcuteness(current.angle);
4014
+ // Penalize angle repetition. It is important to do it _before_ multiplying by anything because we
4015
+ // compare raw acuteness here.
4016
+ acuteAngleBonus *=
4017
+ 0.08 +
4018
+ 0.92 *
4019
+ (1 -
4020
+ Math.min(acuteAngleBonus, Math.pow(this.calculateAcuteAngleAcuteness(last.angle), 3)));
4021
+ const velocity = Math.min(currentVelocity, prevVelocity);
4022
+ // Apply acute angle bonus for BPM above 300 1/2 and distance more than one diameter.
4023
+ acuteAngleBonus *=
4024
+ velocity *
4025
+ osuBase.MathUtils.smootherstep(osuBase.MathUtils.millisecondsToBPM(current.strainTime, 2), 300, 400) *
4026
+ osuBase.MathUtils.smootherstep(currentDistance, 0, current.normalizedDiameter * 2);
4027
+ return acuteAngleBonus * this.acuteAngleMultiplier;
4028
+ }
4029
+ static calculateWideAngleBonus(current, last, currentDistance, prevDistance, withSliders) {
4030
+ if (current.angle === null || last.angle === null) {
4031
+ return 0;
4032
+ }
4033
+ let wideAngleBonus = this.calculateWideAngleAcuteness(current.angle);
4034
+ // Penalize angle repetition. It is important to do it _before_ multiplying by velocity because we
4035
+ // compare raw wideness here.
4036
+ wideAngleBonus *=
4037
+ 0.25 +
4038
+ 0.75 *
4039
+ (1 -
4040
+ Math.min(wideAngleBonus, Math.pow(this.calculateWideAngleAcuteness(last.angle), 3)));
4041
+ // Rescale velocity for the wide angle bonus.
4042
+ const wideAngleTimeScale = 1.45;
4043
+ let currentRescaledVelocity = currentDistance / Math.pow(current.strainTime, wideAngleTimeScale);
4044
+ const prevRescaledVelocity = prevDistance / Math.pow(last.strainTime, wideAngleTimeScale);
4045
+ if (last.object instanceof osuBase.Slider && withSliders) {
4046
+ const sliderDistance = last.lazyTravelDistance + current.lazyJumpDistance;
4047
+ currentRescaledVelocity = Math.max(currentRescaledVelocity, sliderDistance /
4048
+ Math.pow(current.strainTime, wideAngleTimeScale));
4049
+ }
4050
+ wideAngleBonus *= Math.min(currentRescaledVelocity, prevRescaledVelocity);
4051
+ const last2 = current.previous(2);
4052
+ if (last2 !== null) {
4053
+ // If objects just go back and forth through a middle point - don't give as much wide bonus.
4054
+ // Use previous(2) and previous(0) because angles calculation is done prevprev-prev-curr, so any
4055
+ // object's angle's center point is always the previous object.
4056
+ const distance = last2.object.stackedPosition.getDistance(last.object.stackedPosition);
4057
+ if (distance < 1) {
4058
+ wideAngleBonus *= 1 - 0.55 * (1 - distance);
4059
+ }
4060
+ }
4061
+ return wideAngleBonus * this.wideAngleMultiplier;
4062
+ }
4063
+ static calculateVelocityChangeBonus(withSliders, prevVelocity, currentVelocity, currentDistance, current, last) {
4064
+ if (Math.max(prevVelocity, currentVelocity) === 0) {
4065
+ return 0;
4066
+ }
4067
+ if (withSliders) {
4068
+ // We want to use just the object jump without slider velocity when awarding differences.
4069
+ currentVelocity = currentDistance / current.strainTime;
4070
+ }
4071
+ // Scale with ratio of difference compared to half the max distance.
4072
+ const distanceRatio = osuBase.MathUtils.smoothstep(Math.abs(prevVelocity - currentVelocity) /
4073
+ Math.max(prevVelocity, currentVelocity), 0, 1);
4074
+ // Reward for % distance up to 125 / strainTime for overlaps where velocity is still changing.
4075
+ const overlapVelocityBuff = Math.min((current.normalizedDiameter * 1.25) /
4076
+ Math.min(current.strainTime, last.strainTime), Math.abs(prevVelocity - currentVelocity));
4077
+ let velocityChangeBonus = overlapVelocityBuff * distanceRatio;
4078
+ // Penalize for rhythm changes.
4079
+ velocityChangeBonus *= Math.pow(Math.min(current.strainTime, last.strainTime) /
4080
+ Math.max(current.strainTime, last.strainTime), 2);
4081
+ return velocityChangeBonus * this.velocityChangeMultiplier;
4082
+ }
4083
+ /**
4084
+ * Difficulty bonus for "wiggle" patterns - jumps that are [radius, 3*diameter] in distance, with < 110 angle.
4085
+ * https://www.desmos.com/calculator/dp0v0nvowc
4086
+ */
4087
+ static calculateWiggleBonus(current, last, currentVelocity, prevVelocity, currentDistance, prevDistance) {
4088
+ if (current.angle === null || last.angle === null) {
4089
+ return 0;
4090
+ }
4091
+ const radius = current.normalizedRadius;
4092
+ const diameter = current.normalizedDiameter;
4093
+ const wiggleBonus = Math.min(currentVelocity, prevVelocity) *
4094
+ osuBase.MathUtils.smootherstep(currentDistance, radius, diameter) *
4095
+ Math.pow(osuBase.MathUtils.reverseLerp(currentDistance, diameter * 3, diameter), 1.8) *
4096
+ osuBase.MathUtils.smootherstep(current.angle, osuBase.MathUtils.degreesToRadians(110), osuBase.MathUtils.degreesToRadians(60)) *
4097
+ osuBase.MathUtils.smootherstep(prevDistance, radius, diameter) *
4098
+ Math.pow(osuBase.MathUtils.reverseLerp(prevDistance, diameter * 3, diameter), 1.8) *
4099
+ osuBase.MathUtils.smootherstep(last.angle, osuBase.MathUtils.degreesToRadians(110), osuBase.MathUtils.degreesToRadians(60));
4100
+ return wiggleBonus * this.wiggleMultiplier;
4101
+ }
4102
+ static calculateSliderBonus(current) {
4103
+ // Reward sliders based on velocity.
4104
+ const sliderBonus = current.travelDistance / current.travelTime;
4105
+ const rescaledSliderBonus = sliderBonus < 1 ? sliderBonus : Math.pow(sliderBonus, 0.75);
4106
+ return rescaledSliderBonus * this.sliderMultiplier;
4107
+ }
4108
+ static calculateCurrentVelocity(current, last, currentDistance, withSliders) {
4109
+ let currentVelocity = currentDistance / current.strainTime;
4110
+ // If the last object is a slider, then we extend the travel velocity through the slider into the
4111
+ // current object.
4112
+ if (last.object instanceof osuBase.Slider && withSliders) {
4113
+ const sliderDistance = last.lazyTravelDistance + current.lazyJumpDistance;
4114
+ currentVelocity = Math.max(currentVelocity, sliderDistance / current.strainTime);
4115
+ }
4116
+ return currentVelocity;
4117
+ }
4057
4118
  static calculateWideAngleAcuteness(angle) {
4058
4119
  return osuBase.MathUtils.smoothstep(angle, osuBase.MathUtils.degreesToRadians(40), osuBase.MathUtils.degreesToRadians(140));
4059
4120
  }
@@ -4148,7 +4209,7 @@ class OsuFlowAimEvaluator {
4148
4209
  // Rhythm changes are harder to flow.
4149
4210
  flowDifficulty *=
4150
4211
  1 +
4151
- Math.min(0.25, Math.pow((Math.max(current.strainTime, last.strainTime) -
4212
+ Math.min(0.1, Math.pow((Math.max(current.strainTime, last.strainTime) -
4152
4213
  Math.min(current.strainTime, last.strainTime)) /
4153
4214
  50, 4));
4154
4215
  if (current.angle !== null && last.angle !== null) {
@@ -4223,7 +4284,7 @@ class OsuReadingEvaluator {
4223
4284
  const distanceInfluenceThreshold = current.normalizedDiameter * 1.5;
4224
4285
  const next = current.next(0);
4225
4286
  // Only allow velocity to buff
4226
- const velocity = Math.max(1, current.lazyJumpDistance / current.strainTime);
4287
+ const velocity = Math.max(1, current.jumpDistance / current.strainTime);
4227
4288
  const currentVisibleObjectDensity = this.retrieveCurrentVisibleObjectDensity(current);
4228
4289
  const pastObjectDifficultyInfluence = this.getPastObjectDifficultyInfluence(current, distanceInfluenceThreshold);
4229
4290
  const constantAngleNerfFactor = this.getConstantAngleNerfFactor(current);
@@ -4866,13 +4927,24 @@ class OsuAim extends VariableLengthStrainSkill {
4866
4927
  * Represents the skill required to read every object in the beatmap.
4867
4928
  */
4868
4929
  class OsuReading extends HarmonicSkill {
4869
- constructor(mods, clockRate, hitObjects) {
4870
- super(mods);
4871
- this.clockRate = clockRate;
4872
- this.hitObjects = hitObjects;
4930
+ constructor() {
4931
+ super(...arguments);
4873
4932
  this.currentDifficulty = 0;
4933
+ this.firstObjectStartTime = null;
4874
4934
  this.skillMultiplier = 2.5;
4875
4935
  this.difficultyDecayBase = 0.8;
4936
+ /**
4937
+ * The duration for which the difficulty of objects is reduced, assuming the player has
4938
+ * memorized the beatmap.
4939
+ */
4940
+ this.reducedDifficultyDuration = 40 * 1000;
4941
+ /**
4942
+ * The baseline multiplier applied to the difficulty of the first object.
4943
+ *
4944
+ * Assume that even with full memorization, skill is still required to read and play the
4945
+ * first objects.
4946
+ */
4947
+ this.reducedDifficultyBaseline = 0.2;
4876
4948
  }
4877
4949
  countTopWeightedObjectDifficulties(difficultyValue) {
4878
4950
  if (difficultyValue === 0) {
@@ -4890,21 +4962,26 @@ class OsuReading extends HarmonicSkill {
4890
4962
  osuBase.MathUtils.offsetLogistic(next / consistentTopNote, 1.15, 5, 1.1), 0);
4891
4963
  }
4892
4964
  objectDifficultyOf(current) {
4965
+ var _a;
4893
4966
  const decay = this.difficultyDecay(current.deltaTime);
4967
+ // This currently operates under the assumption that `objectDifficultyOf` is called once
4968
+ // per object, and in order. Under that assumption, we can trust that `current.startTime`
4969
+ // refers to the start time of the first object in the case that `firstObjectStartTime`
4970
+ // is yet to be set.
4971
+ (_a = this.firstObjectStartTime) !== null && _a !== void 0 ? _a : (this.firstObjectStartTime = current.startTime);
4972
+ let currentObjectStrain = this.calculateAdjustedDifficulty(current) *
4973
+ (1 - decay) *
4974
+ this.skillMultiplier;
4975
+ if (current.startTime <=
4976
+ this.firstObjectStartTime + this.reducedDifficultyDuration) {
4977
+ const scale = Math.log10(osuBase.Interpolation.lerp(1, 10, osuBase.MathUtils.clamp((current.startTime - this.firstObjectStartTime) /
4978
+ this.reducedDifficultyDuration, 0, 1)));
4979
+ currentObjectStrain *= osuBase.Interpolation.lerp(this.reducedDifficultyBaseline, 1, scale);
4980
+ }
4894
4981
  this.currentDifficulty *= decay;
4895
- this.currentDifficulty +=
4896
- this.calculateAdjustedDifficulty(current) *
4897
- (1 - decay) *
4898
- this.skillMultiplier;
4982
+ this.currentDifficulty += currentObjectStrain;
4899
4983
  return this.currentDifficulty;
4900
4984
  }
4901
- applyDifficultyTransformation(difficulties) {
4902
- // Assume the first few seconds are completely memorized.
4903
- const reducedNoteCount = this.calculateReducedNoteCount();
4904
- for (let i = 0; i < Math.min(difficulties.length, reducedNoteCount); ++i) {
4905
- difficulties[i] *= Math.log10(osuBase.Interpolation.lerp(1, 10, osuBase.MathUtils.clamp(i / reducedNoteCount, 0, 1)));
4906
- }
4907
- }
4908
4985
  saveToHitObject(current, difficulty) {
4909
4986
  current.readingDifficulty = difficulty;
4910
4987
  }
@@ -4928,25 +5005,6 @@ class OsuReading extends HarmonicSkill {
4928
5005
  Math.pow(Math.max(0, current.overallDifficulty), 2.2) / 1125;
4929
5006
  return difficulty;
4930
5007
  }
4931
- calculateReducedNoteCount() {
4932
- if (this.hitObjects.length < 2) {
4933
- return 0;
4934
- }
4935
- const reducedDifficultyDuration = 60 * 1000;
4936
- // We take the 2nd note to match `createDifficultyHitObjects`
4937
- const firstDifficultyObject = this.hitObjects[1];
4938
- const reducedDuration = firstDifficultyObject.startTime / this.clockRate +
4939
- reducedDifficultyDuration;
4940
- let reducedNoteCount = 0;
4941
- for (let i = 1; i < this.hitObjects.length; ++i) {
4942
- const object = this.hitObjects[i];
4943
- if (object.startTime / this.clockRate > reducedDuration) {
4944
- break;
4945
- }
4946
- ++reducedNoteCount;
4947
- }
4948
- return reducedNoteCount;
4949
- }
4950
5008
  difficultyDecay(ms) {
4951
5009
  return Math.pow(this.difficultyDecayBase, ms / 1000);
4952
5010
  }
@@ -5179,7 +5237,8 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
5179
5237
  this.speedDeviation === Number.POSITIVE_INFINITY) {
5180
5238
  return 0;
5181
5239
  }
5182
- const speedDifficulty = this.difficultyAttributes.speedDifficulty * this.calculateSpeedHighDeviationNerf();
5240
+ const speedDifficulty = this.difficultyAttributes.speedDifficulty *
5241
+ this.calculateSpeedHighDeviationNerf();
5183
5242
  let speedValue = OsuSpeed.difficultyToPerformance(speedDifficulty);
5184
5243
  if (this._effectiveMissCount > 0) {
5185
5244
  const speedEstimatedSliderBreaks = this.calculateEstimatedSliderBreaks(this.difficultyAttributes.speedTopWeightedSliderFactor);
@@ -5215,9 +5274,9 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
5215
5274
  const realAccuracy = new osuBase.Accuracy(Object.assign(Object.assign({}, this.computedAccuracy), { n300: this.computedAccuracy.n300 - (this.totalHits - ncircles) }));
5216
5275
  // Lots of arbitrary values from testing.
5217
5276
  // Considering to use derivation from perfect accuracy in a probabilistic manner - assume normal distribution
5277
+ // It is possible to reach a negative accuracy with this formula. `Accuracy.value` caps it at zero - zero points.
5218
5278
  let accuracyValue = Math.pow(1.52163, this.overallDifficulty) *
5219
- // It is possible to reach a negative accuracy with this formula. Cap it at zero - zero points.
5220
- Math.pow(realAccuracy.n300 < 0 ? 0 : realAccuracy.value, 24) *
5279
+ Math.pow(realAccuracy.value, 24) *
5221
5280
  2.83;
5222
5281
  // Bonus for many hitcircles - it's harder to keep good accuracy up for longer.
5223
5282
  accuracyValue *= Math.pow(ncircles / 1000, ncircles < 1000 ? 0.3 : 0.1);
@@ -5279,7 +5338,8 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
5279
5338
  return 1;
5280
5339
  }
5281
5340
  // https://www.desmos.com/calculator/naggvbcz0a
5282
- return 0.93 / (missCount / (4 * Math.log(difficultStrainCount)) + 1);
5341
+ return (0.93 /
5342
+ (missCount / (4 * Math.log(Math.max(1, difficultStrainCount))) + 1));
5283
5343
  }
5284
5344
  /**
5285
5345
  * Estimates a player's deviation on speed notes using {@link calculateDeviation}, assuming worst-case.
@@ -5379,7 +5439,8 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
5379
5439
  excessSpeedDifficultyCutoff / scale);
5380
5440
  // 220 UR and less are considered tapped correctly to ensure that normal scores will be punished as little as possible
5381
5441
  const t = 1 - osuBase.Interpolation.reverseLerp(this.speedDeviation, 22, 27);
5382
- return (osuBase.Interpolation.lerp(adjustedSpeedDifficulty, speedDifficulty, t) / speedDifficulty);
5442
+ return (osuBase.Interpolation.lerp(adjustedSpeedDifficulty, speedDifficulty, t) /
5443
+ speedDifficulty);
5383
5444
  }
5384
5445
  calculateEstimatedSliderBreaks(topWeightedSliderFactor) {
5385
5446
  const nonMissMistakes = this.computedAccuracy.n100 + this.computedAccuracy.n50;
@@ -5766,7 +5827,7 @@ class OsuDifficultyCalculator extends DifficultyCalculator {
5766
5827
  if (!mods.has(osuBase.ModRelax)) {
5767
5828
  skills.push(new OsuSpeed(mods));
5768
5829
  }
5769
- skills.push(new OsuReading(mods, beatmap.speedMultiplier, beatmap.hitObjects.objects));
5830
+ skills.push(new OsuReading(mods));
5770
5831
  if (mods.has(osuBase.ModFlashlight)) {
5771
5832
  skills.push(new OsuFlashlight(mods, beatmap.hitObjects.objects.length));
5772
5833
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rian8337/osu-rebalance-difficulty-calculator",
3
- "version": "4.0.0-beta.98",
3
+ "version": "4.0.0-beta.99",
4
4
  "description": "A module for calculating osu!standard beatmap difficulty and performance value with respect to the latest osu!lazer difficulty and performance algorithm.",
5
5
  "keywords": [
6
6
  "osu",
@@ -38,5 +38,5 @@
38
38
  "publishConfig": {
39
39
  "access": "public"
40
40
  },
41
- "gitHead": "0d1f9256f0caee5123379cf5a8b3c92d1dcfa7bf"
41
+ "gitHead": "8db713bd3e23b065f26d65f4d312e3d55c384a1c"
42
42
  }
@@ -555,7 +555,7 @@ declare abstract class DifficultyCalculator<TBeatmap extends PlayableBeatmap, TH
555
555
  * @param objects The `DifficultyHitObject`s which were processed.
556
556
  * @returns The `DifficultyAttributes` object.
557
557
  */
558
- protected abstract createDifficultyAttributes(beatmap: Beatmap, playableBeatmap: TBeatmap, skills: Skill[], objects: THitObject[]): TAttributes;
558
+ protected abstract createDifficultyAttributes(beatmap: Beatmap, playableBeatmap: PlayableBeatmap, skills: Skill[], objects: THitObject[]): TAttributes;
559
559
  /**
560
560
  * Constructs a `PlayableBeatmap` from a `Beatmap` with specific `Mod`s.
561
561
  *
@@ -851,7 +851,7 @@ declare class ExtendedDroidDifficultyAttributes extends DroidDifficultyAttribute
851
851
  declare class DroidDifficultyCalculator extends DifficultyCalculator<DroidPlayableBeatmap, DroidDifficultyHitObject, ExtendedDroidDifficultyAttributes> {
852
852
  constructor();
853
853
  retainDifficultyAdjustmentMods(mods: Mod[]): Mod[];
854
- protected createDifficultyAttributes(beatmap: Beatmap, playableBeatmap: DroidPlayableBeatmap, skills: Skill[], objects: DroidDifficultyHitObject[]): ExtendedDroidDifficultyAttributes;
854
+ protected createDifficultyAttributes(beatmap: Beatmap, playableBeatmap: PlayableBeatmap, skills: Skill[], objects: DroidDifficultyHitObject[]): ExtendedDroidDifficultyAttributes;
855
855
  protected createPlayableBeatmap(beatmap: Beatmap, mods?: ModMap): DroidPlayableBeatmap;
856
856
  protected createDifficultyHitObjects(beatmap: DroidPlayableBeatmap): DroidDifficultyHitObject[];
857
857
  protected createSkills(beatmap: DroidPlayableBeatmap): Skill[];
@@ -1176,6 +1176,16 @@ declare abstract class DroidSnapAimEvaluator {
1176
1176
  * @param withSliders Whether to take slider difficulty into account.
1177
1177
  */
1178
1178
  static evaluateDifficultyOf(current: DroidDifficultyHitObject, withSliders: boolean): number;
1179
+ private static calculateAcuteAngleBonus;
1180
+ private static calculateWideAngleBonus;
1181
+ private static calculateVelocityChangeBonus;
1182
+ /**
1183
+ * Difficulty bonus for "wiggle" patterns - jumps that are [radius, 3*diameter] in distance, with < 110 angle.
1184
+ * https://www.desmos.com/calculator/dp0v0nvowc
1185
+ */
1186
+ private static calculateWiggleBonus;
1187
+ private static calculateSliderBonus;
1188
+ private static calculateCurrentVelocity;
1179
1189
  private static calculateWideAngleAcuteness;
1180
1190
  static calculateAcuteAngleAcuteness(angle: number): number;
1181
1191
  private static highBpmBonus;
@@ -1370,6 +1380,16 @@ declare abstract class OsuSnapAimEvaluator {
1370
1380
  * @param withSliders Whether to take slider difficulty into account.
1371
1381
  */
1372
1382
  static evaluateDifficultyOf(current: OsuDifficultyHitObject, withSliders: boolean): number;
1383
+ private static calculateAcuteAngleBonus;
1384
+ private static calculateWideAngleBonus;
1385
+ private static calculateVelocityChangeBonus;
1386
+ /**
1387
+ * Difficulty bonus for "wiggle" patterns - jumps that are [radius, 3*diameter] in distance, with < 110 angle.
1388
+ * https://www.desmos.com/calculator/dp0v0nvowc
1389
+ */
1390
+ private static calculateWiggleBonus;
1391
+ private static calculateSliderBonus;
1392
+ private static calculateCurrentVelocity;
1373
1393
  private static calculateWideAngleAcuteness;
1374
1394
  static calculateAcuteAngleAcuteness(angle: number): number;
1375
1395
  private static highBpmBonus;
@@ -1444,7 +1464,7 @@ declare class OsuDifficultyAttributes extends DifficultyAttributes implements IO
1444
1464
  declare class OsuDifficultyCalculator extends DifficultyCalculator<OsuPlayableBeatmap, OsuDifficultyHitObject, OsuDifficultyAttributes> {
1445
1465
  constructor();
1446
1466
  retainDifficultyAdjustmentMods(mods: Mod[]): Mod[];
1447
- protected createDifficultyAttributes(beatmap: Beatmap, playableBeatmap: OsuPlayableBeatmap, skills: Skill[]): OsuDifficultyAttributes;
1467
+ protected createDifficultyAttributes(beatmap: Beatmap, playableBeatmap: PlayableBeatmap, skills: Skill[]): OsuDifficultyAttributes;
1448
1468
  protected createPlayableBeatmap(beatmap: Beatmap, mods?: ModMap): OsuPlayableBeatmap;
1449
1469
  protected createDifficultyHitObjects(beatmap: OsuPlayableBeatmap): OsuDifficultyHitObject[];
1450
1470
  protected createSkills(beatmap: OsuPlayableBeatmap): Skill[];
@@ -1888,18 +1908,26 @@ declare abstract class HarmonicSkill extends Skill implements IHasPeakDifficulty
1888
1908
  * Represents the skill required to read every object in the beatmap.
1889
1909
  */
1890
1910
  declare class DroidReading extends HarmonicSkill {
1891
- private readonly clockRate;
1892
- private readonly hitObjects;
1893
1911
  private currentDifficulty;
1912
+ private firstObjectStartTime;
1894
1913
  private readonly skillMultiplier;
1895
1914
  private readonly difficultyDecayBase;
1896
- constructor(mods: ModMap, clockRate: number, hitObjects: readonly PlaceableHitObject[]);
1915
+ /**
1916
+ * The duration for which the difficulty of objects is reduced, assuming the player has
1917
+ * memorized the beatmap.
1918
+ */
1919
+ private readonly reducedDifficultyDuration;
1920
+ /**
1921
+ * The baseline multiplier applied to the difficulty of the first object.
1922
+ *
1923
+ * Assume that even with full memorization, skill is still required to read and play the
1924
+ * first objects.
1925
+ */
1926
+ private readonly reducedDifficultyBaseline;
1897
1927
  countTopWeightedObjectDifficulties(difficultyValue: number): number;
1898
1928
  protected objectDifficultyOf(current: DroidDifficultyHitObject): number;
1899
- protected applyDifficultyTransformation(difficulties: number[]): void;
1900
1929
  protected saveToHitObject(current: DifficultyHitObject, difficulty: number): void;
1901
1930
  private calculateAdjustedDifficulty;
1902
- private calculateReducedNoteCount;
1903
1931
  private difficultyDecay;
1904
1932
  }
1905
1933
 
@@ -2043,18 +2071,26 @@ declare class OsuFlashlight extends OsuSkill {
2043
2071
  * Represents the skill required to read every object in the beatmap.
2044
2072
  */
2045
2073
  declare class OsuReading extends HarmonicSkill {
2046
- private readonly clockRate;
2047
- private readonly hitObjects;
2048
2074
  private currentDifficulty;
2075
+ private firstObjectStartTime;
2049
2076
  private readonly skillMultiplier;
2050
2077
  private readonly difficultyDecayBase;
2051
- constructor(mods: ModMap, clockRate: number, hitObjects: readonly PlaceableHitObject[]);
2078
+ /**
2079
+ * The duration for which the difficulty of objects is reduced, assuming the player has
2080
+ * memorized the beatmap.
2081
+ */
2082
+ private readonly reducedDifficultyDuration;
2083
+ /**
2084
+ * The baseline multiplier applied to the difficulty of the first object.
2085
+ *
2086
+ * Assume that even with full memorization, skill is still required to read and play the
2087
+ * first objects.
2088
+ */
2089
+ private readonly reducedDifficultyBaseline;
2052
2090
  countTopWeightedObjectDifficulties(difficultyValue: number): number;
2053
2091
  protected objectDifficultyOf(current: OsuDifficultyHitObject): number;
2054
- protected applyDifficultyTransformation(difficulties: number[]): void;
2055
2092
  protected saveToHitObject(current: DifficultyHitObject, difficulty: number): void;
2056
2093
  private calculateAdjustedDifficulty;
2057
- private calculateReducedNoteCount;
2058
2094
  private difficultyDecay;
2059
2095
  }
2060
2096