@rian8337/osu-rebalance-difficulty-calculator 4.0.0-beta.23 → 4.0.0-beta.25

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
@@ -44,7 +44,6 @@ class DifficultyCalculator {
44
44
  * @param beatmap The beatmap to calculate. This beatmap will be deep-cloned to prevent reference changes.
45
45
  */
46
46
  constructor(beatmap) {
47
- var _a;
48
47
  /**
49
48
  * The difficulty objects of the beatmap.
50
49
  */
@@ -65,7 +64,7 @@ class DifficultyCalculator {
65
64
  this.beatmap = beatmap;
66
65
  this.difficultyStatistics = {
67
66
  circleSize: beatmap.difficulty.cs,
68
- approachRate: (_a = beatmap.difficulty.ar) !== null && _a !== void 0 ? _a : beatmap.difficulty.od,
67
+ approachRate: beatmap.difficulty.ar,
69
68
  overallDifficulty: beatmap.difficulty.od,
70
69
  healthDrain: beatmap.difficulty.hp,
71
70
  overallSpeedMultiplier: 1,
@@ -89,14 +88,14 @@ class DifficultyCalculator {
89
88
  calculate(options) {
90
89
  var _a;
91
90
  this.mods = (_a = options === null || options === void 0 ? void 0 : options.mods) !== null && _a !== void 0 ? _a : [];
92
- const converted = new osuBase.BeatmapConverter(this.beatmap).convert({
91
+ const playableBeatmap = this.beatmap.createPlayableBeatmap({
93
92
  mode: this.mode,
94
93
  mods: this.mods,
95
94
  customSpeedMultiplier: options === null || options === void 0 ? void 0 : options.customSpeedMultiplier,
96
95
  });
97
96
  this.difficultyStatistics = Object.seal(this.computeDifficultyStatistics(options));
98
97
  this.populateDifficultyAttributes();
99
- this.objects.push(...this.generateDifficultyHitObjects(converted));
98
+ this.objects.push(...this.generateDifficultyHitObjects(playableBeatmap));
100
99
  this.calculateAll();
101
100
  return this;
102
101
  }
@@ -159,8 +158,9 @@ class DifficultyHitObject {
159
158
  * @param lastLastObject The hitobject before the last hitobject.
160
159
  * @param difficultyHitObjects All difficulty hitobjects in the processed beatmap.
161
160
  * @param clockRate The clock rate of the beatmap.
161
+ * @param greatWindow The great window of the hitobject.
162
162
  */
163
- constructor(object, lastObject, lastLastObject, difficultyHitObjects, clockRate) {
163
+ constructor(object, lastObject, lastLastObject, difficultyHitObjects, clockRate, greatWindow) {
164
164
  /**
165
165
  * The aim strain generated by the hitobject if sliders are considered.
166
166
  */
@@ -213,18 +213,18 @@ class DifficultyHitObject {
213
213
  this.normalizedRadius = 50;
214
214
  this.maximumSliderRadius = this.normalizedRadius * 2.4;
215
215
  this.assumedSliderRadius = this.normalizedRadius * 1.8;
216
- this.minDeltaTime = 25;
217
216
  this.object = object;
218
217
  this.lastObject = lastObject;
219
218
  this.lastLastObject = lastLastObject;
220
219
  this.hitObjects = difficultyHitObjects;
220
+ this.fullGreatWindow = greatWindow * 2;
221
221
  this.index = difficultyHitObjects.length - 1;
222
222
  // Capped to 25ms to prevent difficulty calculation breaking from simultaneous objects.
223
223
  this.startTime = object.startTime / clockRate;
224
224
  this.endTime = object.endTime / clockRate;
225
225
  if (lastObject) {
226
226
  this.deltaTime = this.startTime - lastObject.startTime / clockRate;
227
- this.strainTime = Math.max(this.deltaTime, this.minDeltaTime);
227
+ this.strainTime = Math.max(this.deltaTime, DifficultyHitObject.minDeltaTime);
228
228
  }
229
229
  else {
230
230
  this.deltaTime = 0;
@@ -295,6 +295,24 @@ class DifficultyHitObject {
295
295
  }
296
296
  return osuBase.MathUtils.clamp((time - fadeInStartTime) / fadeInDuration, 0, 1);
297
297
  }
298
+ /**
299
+ * How possible is it to doubletap this object together with the next one and get perfect
300
+ * judgement in range from 0 to 1.
301
+ *
302
+ * A value closer to 1 indicates a higher possibility.
303
+ */
304
+ get doubletapness() {
305
+ const next = this.next(0);
306
+ if (!next) {
307
+ return 0;
308
+ }
309
+ const currentDeltaTime = Math.max(1, this.deltaTime);
310
+ const nextDeltaTime = Math.max(1, next.deltaTime);
311
+ const deltaDifference = Math.abs(nextDeltaTime - currentDeltaTime);
312
+ const speedRatio = currentDeltaTime / Math.max(currentDeltaTime, deltaDifference);
313
+ const windowRatio = Math.pow(Math.min(1, currentDeltaTime / this.fullGreatWindow), 2);
314
+ return 1 - Math.pow(speedRatio, 1 - windowRatio);
315
+ }
298
316
  setDistances(clockRate) {
299
317
  if (this.object instanceof osuBase.Slider) {
300
318
  this.calculateSliderCursorPosition(this.object);
@@ -306,7 +324,7 @@ class DifficultyHitObject {
306
324
  else {
307
325
  this.travelDistance *= Math.pow(1 + this.object.repeatCount / 2.5, 1 / 2.5);
308
326
  }
309
- this.travelTime = Math.max(this.object.lazyTravelTime / clockRate, this.minDeltaTime);
327
+ this.travelTime = Math.max(this.object.lazyTravelTime / clockRate, DifficultyHitObject.minDeltaTime);
310
328
  }
311
329
  // We don't need to calculate either angle or distance when one of the last->curr objects is a spinner.
312
330
  if (!this.lastObject ||
@@ -324,8 +342,8 @@ class DifficultyHitObject {
324
342
  this.minimumJumpTime = this.strainTime;
325
343
  this.minimumJumpDistance = this.lazyJumpDistance;
326
344
  if (this.lastObject instanceof osuBase.Slider) {
327
- const lastTravelTime = Math.max(this.lastObject.lazyTravelTime / clockRate, this.minDeltaTime);
328
- this.minimumJumpTime = Math.max(this.strainTime - lastTravelTime, this.minDeltaTime);
345
+ const lastTravelTime = Math.max(this.lastObject.lazyTravelTime / clockRate, DifficultyHitObject.minDeltaTime);
346
+ this.minimumJumpTime = Math.max(this.strainTime - lastTravelTime, DifficultyHitObject.minDeltaTime);
329
347
  // There are two types of slider-to-object patterns to consider in order to better approximate the real movement a player will take to jump between the hitobjects.
330
348
  //
331
349
  // 1. The anti-flow pattern, where players cut the slider short in order to move to the next hitobject.
@@ -440,6 +458,10 @@ class DifficultyHitObject {
440
458
  return pos;
441
459
  }
442
460
  }
461
+ /**
462
+ * The lowest possible delta time value.
463
+ */
464
+ DifficultyHitObject.minDeltaTime = 25;
443
465
 
444
466
  /**
445
467
  * An evaluator for calculating osu!droid Aim skill.
@@ -568,6 +590,14 @@ class DroidAimEvaluator extends AimEvaluator {
568
590
  // Reward sliders based on velocity.
569
591
  sliderBonus = last.travelDistance / last.travelTime;
570
592
  }
593
+ // Reduce snap aim difficulty for low spacing as the player is more likely to perform
594
+ // a flowing movement instead of snapping to the object. This also prevents the weird
595
+ // scenario of awarding flow aim difficulty in snap aim.
596
+ const flowBonus = Math.pow(last.minimumJumpDistance / this.singleSpacingThreshold, 3.5);
597
+ if (flowBonus < 1) {
598
+ strain *= 0.5 * (1 + Math.sqrt(flowBonus));
599
+ wideAngleBonus *= 0.5 * (1 + Math.sqrt(flowBonus));
600
+ }
571
601
  // Add in acute angle bonus or wide angle bonus + velocity change bonus, whichever is larger.
572
602
  strain += Math.max(acuteAngleBonus * this.acuteAngleMultiplier, wideAngleBonus * this.wideAngleMultiplier +
573
603
  velocityChangeBonus * this.velocityChangeMultiplier);
@@ -582,16 +612,33 @@ class DroidAimEvaluator extends AimEvaluator {
582
612
  * Calculates the flow aim strain of a hitobject.
583
613
  */
584
614
  static flowAimStrainOf(current) {
585
- var _a, _b;
615
+ var _a;
586
616
  let speedBonus = 1;
587
617
  if (current.strainTime < this.minSpeedBonus) {
588
618
  speedBonus +=
589
619
  0.75 *
590
620
  Math.pow((this.minSpeedBonus - current.strainTime) / 40, 2);
591
621
  }
592
- const travelDistance = (_b = (_a = current.previous(0)) === null || _a === void 0 ? void 0 : _a.travelDistance) !== null && _b !== void 0 ? _b : 0;
593
- const shortDistancePenalty = Math.pow(Math.min(this.singleSpacingThreshold, travelDistance + current.minimumJumpDistance) / this.singleSpacingThreshold, 3.5);
594
- return (200 * speedBonus * shortDistancePenalty) / current.strainTime;
622
+ const prev = current.previous(0);
623
+ // Punish low spacing as it is easier to aim.
624
+ const travelDistance = (_a = prev === null || prev === void 0 ? void 0 : prev.travelDistance) !== null && _a !== void 0 ? _a : 0;
625
+ const distance = travelDistance + current.minimumJumpDistance;
626
+ const shortDistancePenalty = Math.min(1, Math.pow(distance / this.singleSpacingThreshold, 3.5));
627
+ let adjustedDistanceScale = 1;
628
+ // Reward for inconsistent angles while punishing consistent ones.
629
+ // Only apply the adjustment to patterns with the same delta time.
630
+ // Graph: https://www.desmos.com/calculator/soomupyfwp
631
+ if (current.angle !== null &&
632
+ typeof (prev === null || prev === void 0 ? void 0 : prev.angle) === "number" &&
633
+ Math.abs(current.deltaTime - prev.deltaTime) < 10) {
634
+ const angleDiff = Math.abs(current.angle - prev.angle);
635
+ const adjustedAngleDiff = Math.sin(angleDiff / 2) * 180;
636
+ const angularVelocity = adjustedAngleDiff / (0.1 + current.strainTime);
637
+ const angularVelocityBonus = Math.max(0, Math.pow(angularVelocity, 0.4) - 1);
638
+ adjustedDistanceScale = 0.65 + angularVelocityBonus * 0.45;
639
+ }
640
+ return ((200 * speedBonus * shortDistancePenalty * adjustedDistanceScale) /
641
+ current.strainTime);
595
642
  }
596
643
  }
597
644
  DroidAimEvaluator.wideAngleMultiplier = 1.65;
@@ -689,6 +736,10 @@ class StrainSkill extends Skill {
689
736
  class DroidSkill extends StrainSkill {
690
737
  constructor() {
691
738
  super(...arguments);
739
+ /**
740
+ * The minimum number of strains to judge when computing for retryability.
741
+ */
742
+ this.minimumRetryabilityStrains = 500;
692
743
  this._objectStrains = [];
693
744
  this.difficulty = 0;
694
745
  }
@@ -713,6 +764,34 @@ class DroidSkill extends StrainSkill {
713
764
  return this._objectStrains.reduce((total, next) => total +
714
765
  1.1 / (1 + Math.exp(-10 * (next / consistentTopStrain - 0.88))), 0);
715
766
  }
767
+ /**
768
+ * Computes the retryability of the beatmap based on the strains of the hitobjects.
769
+ *
770
+ * Earlier difficult strains indicate higher retryability.
771
+ *
772
+ * The result is scaled by clock rate as it affects the total number of strains.
773
+ *
774
+ * @returns A number between 0 and 1. A higher value indicates higher retryability.
775
+ */
776
+ countRetryability() {
777
+ if (this._objectStrains.length === 0) {
778
+ return 0;
779
+ }
780
+ const maxStrain = Math.max(...this._objectStrains);
781
+ if (maxStrain === 0) {
782
+ return 0;
783
+ }
784
+ let weightedStrainSum = 0;
785
+ for (let i = 0; i < this._objectStrains.length; ++i) {
786
+ const strainRatio = this._objectStrains[i] / maxStrain;
787
+ // Give more weight to earlier strains.
788
+ const strainPositionWeight = 1 - Math.pow(i / this._objectStrains.length, 0.75) / 10;
789
+ weightedStrainSum += strainRatio * strainPositionWeight;
790
+ }
791
+ return (1 -
792
+ weightedStrainSum /
793
+ Math.max(this._objectStrains.length, this.minimumRetryabilityStrains));
794
+ }
716
795
  process(current) {
717
796
  super.process(current);
718
797
  this._objectStrains.push(this.getObjectStrain(current));
@@ -806,31 +885,18 @@ class DroidTapEvaluator extends SpeedEvaluator {
806
885
  * - and the strain time cap.
807
886
  *
808
887
  * @param current The current object.
809
- * @param greatWindow The great hit window of the current object.
810
888
  * @param considerCheesability Whether to consider cheesability.
811
889
  * @param strainTimeCap The strain time to cap the object's strain time to.
812
890
  */
813
- static evaluateDifficultyOf(current, greatWindow, considerCheesability, strainTimeCap) {
891
+ static evaluateDifficultyOf(current, considerCheesability, strainTimeCap) {
814
892
  if (current.object instanceof osuBase.Spinner ||
815
893
  // Exclude overlapping objects that can be tapped at once.
816
894
  current.isOverlapping(false)) {
817
895
  return 0;
818
896
  }
819
- let doubletapness = 1;
820
- if (considerCheesability) {
821
- // Nerf doubletappable doubles.
822
- const next = current.next(0);
823
- if (next) {
824
- const greatWindowFull = greatWindow * 2;
825
- const currentDeltaTime = Math.max(1, current.deltaTime);
826
- const nextDeltaTime = Math.max(1, next.deltaTime);
827
- const deltaDifference = Math.abs(nextDeltaTime - currentDeltaTime);
828
- const speedRatio = currentDeltaTime /
829
- Math.max(currentDeltaTime, deltaDifference);
830
- const windowRatio = Math.pow(Math.min(1, currentDeltaTime / greatWindowFull), 2);
831
- doubletapness = Math.pow(speedRatio, 1 - windowRatio);
832
- }
833
- }
897
+ const doubletapness = considerCheesability
898
+ ? 1 - current.doubletapness
899
+ : 1;
834
900
  const strainTime = strainTimeCap !== undefined
835
901
  ? // We cap the strain time to 50 here as the chance of vibro is higher in any BPM higher than 300.
836
902
  Math.max(50, strainTimeCap, current.strainTime)
@@ -855,17 +921,17 @@ class DroidTap extends DroidSkill {
855
921
  get objectDeltaTimes() {
856
922
  return this._objectDeltaTimes;
857
923
  }
858
- constructor(mods, overallDifficulty, considerCheesability, strainTimeCap) {
924
+ constructor(mods, considerCheesability, strainTimeCap) {
859
925
  super(mods);
860
926
  this.reducedSectionCount = 10;
861
927
  this.reducedSectionBaseline = 0.75;
862
928
  this.strainDecayBase = 0.3;
863
929
  this.starsPerDouble = 1.1;
930
+ this.minimumRetryabilityStrains = 750;
864
931
  this.currentTapStrain = 0;
865
932
  this.currentRhythmMultiplier = 0;
866
933
  this.skillMultiplier = 1375;
867
934
  this._objectDeltaTimes = [];
868
- this.greatWindow = new osuBase.OsuHitWindow(overallDifficulty).hitWindowFor300();
869
935
  this.considerCheesability = considerCheesability;
870
936
  this.strainTimeCap = strainTimeCap;
871
937
  }
@@ -904,7 +970,7 @@ class DroidTap extends DroidSkill {
904
970
  strainValueAt(current) {
905
971
  this.currentTapStrain *= this.strainDecay(current.strainTime);
906
972
  this.currentTapStrain +=
907
- DroidTapEvaluator.evaluateDifficultyOf(current, this.greatWindow, this.considerCheesability, this.strainTimeCap) * this.skillMultiplier;
973
+ DroidTapEvaluator.evaluateDifficultyOf(current, this.considerCheesability, this.strainTimeCap) * this.skillMultiplier;
908
974
  this.currentRhythmMultiplier = current.rhythmMultiplier;
909
975
  this._objectDeltaTimes.push(current.deltaTime);
910
976
  return this.currentTapStrain * current.rhythmMultiplier;
@@ -1088,6 +1154,46 @@ class RhythmEvaluator {
1088
1154
  RhythmEvaluator.rhythmMultiplier = 0.75;
1089
1155
  RhythmEvaluator.historyTimeMax = 5000; // 5 seconds of calculateRhythmBonus max.
1090
1156
 
1157
+ class Island {
1158
+ constructor(firstDelta, epsilon) {
1159
+ this.deltas = [];
1160
+ if (epsilon === undefined) {
1161
+ this.deltaDifferenceEpsilon = firstDelta;
1162
+ return;
1163
+ }
1164
+ this.deltaDifferenceEpsilon = epsilon;
1165
+ this.addDelta(firstDelta);
1166
+ }
1167
+ addDelta(delta) {
1168
+ // Convert to integer
1169
+ delta = Math.trunc(delta);
1170
+ const existingDelta = this.deltas.find((v) => Math.abs(v - delta) >= this.deltaDifferenceEpsilon);
1171
+ this.deltas.push(existingDelta !== null && existingDelta !== void 0 ? existingDelta : delta);
1172
+ }
1173
+ get averageDelta() {
1174
+ return this.deltas.length > 0
1175
+ ? Math.max(this.deltas.reduce((a, b) => a + b) / this.deltas.length, DifficultyHitObject.minDeltaTime)
1176
+ : 0;
1177
+ }
1178
+ isSimilarPolarity(other) {
1179
+ // Consider islands to be of similar polarity only if they're having the same
1180
+ // average delta (we don't want to consider 3 singletaps similar to a triple)
1181
+ return (Math.abs(this.averageDelta - other.averageDelta) <
1182
+ this.deltaDifferenceEpsilon &&
1183
+ this.deltas.length % 2 === other.deltas.length % 2);
1184
+ }
1185
+ equals(other) {
1186
+ if (this.deltas.length !== other.deltas.length) {
1187
+ return false;
1188
+ }
1189
+ for (let i = 0; i < this.deltas.length; ++i) {
1190
+ if (this.deltas[i] !== other.deltas[i]) {
1191
+ return false;
1192
+ }
1193
+ }
1194
+ return true;
1195
+ }
1196
+ }
1091
1197
  /**
1092
1198
  * An evaluator for calculating osu!droid Rhythm skill.
1093
1199
  */
@@ -1097,22 +1203,23 @@ class DroidRhythmEvaluator extends RhythmEvaluator {
1097
1203
  * with historic data of the current object.
1098
1204
  *
1099
1205
  * @param current The current object.
1100
- * @param greatWindow The great hit window of the current object.
1101
1206
  */
1102
- static evaluateDifficultyOf(current, greatWindow) {
1207
+ static evaluateDifficultyOf(current) {
1103
1208
  if (current.object instanceof osuBase.Spinner ||
1104
1209
  // Exclude overlapping objects that can be tapped at once.
1105
1210
  current.isOverlapping(false)) {
1106
1211
  return 1;
1107
1212
  }
1108
- let previousIslandSize = 0;
1213
+ const deltaDifferenceEpsilon = current.fullGreatWindow * 0.3;
1109
1214
  let rhythmComplexitySum = 0;
1110
- let islandSize = 1;
1215
+ let island = new Island(deltaDifferenceEpsilon);
1216
+ let previousIsland = new Island(deltaDifferenceEpsilon);
1217
+ const islandCounts = new Map();
1111
1218
  // Store the ratio of the current start of an island to buff for tighter rhythms.
1112
1219
  let startRatio = 0;
1113
1220
  let firstDeltaSwitch = false;
1114
1221
  let rhythmStart = 0;
1115
- const historicalNoteCount = Math.min(current.index, 32);
1222
+ const historicalNoteCount = Math.min(current.index, this.historyObjectsMax);
1116
1223
  // Exclude overlapping objects that can be tapped at once.
1117
1224
  const validPrevious = [];
1118
1225
  for (let i = 0; i < historicalNoteCount; ++i) {
@@ -1136,105 +1243,125 @@ class DroidRhythmEvaluator extends RhythmEvaluator {
1136
1243
  this.historyTimeMax;
1137
1244
  // Either we're limited by time or limited by object count.
1138
1245
  currentHistoricalDecay = Math.min(currentHistoricalDecay, (validPrevious.length - i) / validPrevious.length);
1139
- const currentDelta = validPrevious[i - 1].strainTime;
1140
- const prevDelta = validPrevious[i].strainTime;
1141
- const lastDelta = validPrevious[i + 1].strainTime;
1246
+ const currentObject = validPrevious[i - 1];
1247
+ const prevObject = validPrevious[i];
1248
+ const lastObject = validPrevious[i + 1];
1249
+ const currentDelta = currentObject.strainTime;
1250
+ const prevDelta = prevObject.strainTime;
1251
+ const lastDelta = lastObject.strainTime;
1142
1252
  const currentRatio = 1 +
1143
- 6 *
1253
+ 10 *
1144
1254
  Math.min(0.5, Math.pow(Math.sin(Math.PI /
1145
1255
  (Math.min(prevDelta, currentDelta) /
1146
1256
  Math.max(prevDelta, currentDelta))), 2));
1147
- const windowPenalty = Math.min(1, Math.max(0, Math.abs(prevDelta - currentDelta) - greatWindow * 0.6) /
1148
- (greatWindow * 0.6));
1257
+ const windowPenalty = osuBase.MathUtils.clamp((Math.abs(prevDelta - currentDelta) - deltaDifferenceEpsilon) /
1258
+ deltaDifferenceEpsilon, 0, 1);
1149
1259
  let effectiveRatio = windowPenalty * currentRatio;
1150
1260
  if (firstDeltaSwitch) {
1151
- if (prevDelta <= 1.25 * currentDelta &&
1152
- prevDelta * 1.25 >= currentDelta) {
1153
- // Island is still progressing, count size.
1154
- if (islandSize < 7) {
1155
- ++islandSize;
1261
+ if (Math.abs(prevDelta - currentDelta) <= deltaDifferenceEpsilon) {
1262
+ if (island.deltas.length < this.maxIslandSize) {
1263
+ // Island is still progressing.
1264
+ island.addDelta(currentDelta);
1156
1265
  }
1157
1266
  }
1158
1267
  else {
1159
- if (validPrevious[i - 1].object instanceof osuBase.Slider) {
1160
- // BPM change is into slider, this is easy acc window.
1268
+ // BPM change is into slider, this is easy acc window.
1269
+ if (currentObject.object instanceof osuBase.Slider) {
1161
1270
  effectiveRatio /= 8;
1162
1271
  }
1163
- if (validPrevious[i].object instanceof osuBase.Slider) {
1164
- // BPM change was from a slider, this is typically easier than circle -> circle.
1272
+ // BPM change was from a slider, this is typically easier than circle -> circle.
1273
+ // Unintentional side effect is that bursts with kicksliders at the ends might
1274
+ // have lower difficulty than bursts without sliders.
1275
+ if (prevObject.object instanceof osuBase.Slider) {
1165
1276
  effectiveRatio /= 4;
1166
1277
  }
1167
- if (previousIslandSize === islandSize) {
1168
- // Repeated island size (ex: triplet -> triplet).
1169
- effectiveRatio /= 4;
1278
+ // Repeated island polarity (2 -> 4, 3 -> 5).
1279
+ if (island.isSimilarPolarity(previousIsland)) {
1280
+ effectiveRatio *= 0.3;
1170
1281
  }
1171
- if (previousIslandSize % 2 === islandSize % 2) {
1172
- // Repeated island polarity (2 -> 4, 3 -> 5).
1282
+ // Previous increase happened a note ago.
1283
+ // Albeit this is a 1/1 -> 1/2-1/4 type of transition, we don't want to buff this.
1284
+ if (lastDelta > prevDelta + deltaDifferenceEpsilon &&
1285
+ prevDelta > currentDelta + deltaDifferenceEpsilon) {
1286
+ effectiveRatio /= 8;
1287
+ }
1288
+ // Singletaps are easier to control.
1289
+ if (island.deltas.length === 1) {
1173
1290
  effectiveRatio /= 2;
1174
1291
  }
1175
- if (lastDelta > prevDelta + 10 &&
1176
- prevDelta > currentDelta + 10) {
1177
- // Previous increase happened a note ago.
1178
- // Albeit this is a 1/1 -> 1/2-1/4 type of transition, we don't want to buff this.
1179
- effectiveRatio /= 8;
1292
+ let islandFound = false;
1293
+ for (const [currentIsland, count] of islandCounts) {
1294
+ if (!island.equals(currentIsland)) {
1295
+ continue;
1296
+ }
1297
+ islandFound = true;
1298
+ let islandCount = count;
1299
+ if (previousIsland.equals(island)) {
1300
+ // Only add island to island counts if they're going one after another.
1301
+ ++islandCount;
1302
+ islandCounts.set(currentIsland, islandCount);
1303
+ }
1304
+ // Repeated island (ex: triplet -> triplet).
1305
+ // Graph: https://www.desmos.com/calculator/pj7an56zwf
1306
+ effectiveRatio *= Math.min(1 / islandCount, Math.pow(1 / islandCount, 4 /
1307
+ (1 +
1308
+ Math.exp(10 - 0.165 * island.averageDelta))));
1309
+ break;
1180
1310
  }
1311
+ if (!islandFound) {
1312
+ islandCounts.set(island, 1);
1313
+ }
1314
+ // Scale down the difficulty if the object is doubletappable.
1315
+ effectiveRatio *= 1 - prevObject.doubletapness * 0.75;
1181
1316
  rhythmComplexitySum +=
1182
- (((Math.sqrt(effectiveRatio * startRatio) *
1183
- currentHistoricalDecay *
1184
- Math.sqrt(4 + islandSize)) /
1185
- 2) *
1186
- Math.sqrt(4 + previousIslandSize)) /
1187
- 2;
1317
+ Math.sqrt(effectiveRatio * startRatio) *
1318
+ currentHistoricalDecay;
1188
1319
  startRatio = effectiveRatio;
1189
- previousIslandSize = islandSize;
1190
- if (prevDelta * 1.25 < currentDelta) {
1320
+ previousIsland = island;
1321
+ if (prevDelta + deltaDifferenceEpsilon < currentDelta) {
1191
1322
  // We're slowing down, stop counting.
1192
1323
  // If we're speeding up, this stays as is and we keep counting island size.
1193
1324
  firstDeltaSwitch = false;
1194
1325
  }
1195
- islandSize = 1;
1326
+ island = new Island(Math.trunc(currentDelta), deltaDifferenceEpsilon);
1196
1327
  }
1197
1328
  }
1198
- else if (prevDelta > 1.25 * currentDelta) {
1199
- // We want to be speeding up.
1329
+ else if (prevDelta > deltaDifferenceEpsilon + currentDelta) {
1330
+ // We're speeding up.
1200
1331
  // Begin counting island until we change speed again.
1201
1332
  firstDeltaSwitch = true;
1333
+ // Reduce ratio if we're starting after a slider.
1334
+ if (prevObject.object instanceof osuBase.Slider) {
1335
+ effectiveRatio *= 0.3;
1336
+ }
1202
1337
  startRatio = effectiveRatio;
1203
- islandSize = 1;
1338
+ island = new Island(Math.trunc(currentDelta), deltaDifferenceEpsilon);
1204
1339
  }
1205
1340
  }
1206
- // Nerf doubles that can be tapped at the same time to get Great hit results.
1207
- const next = current.next(0);
1208
- let doubletapness = 1;
1209
- if (next) {
1210
- const currentDeltaTime = Math.max(1, current.deltaTime);
1211
- const nextDeltaTime = Math.max(1, next.deltaTime);
1212
- const deltaDifference = Math.abs(nextDeltaTime - currentDeltaTime);
1213
- const speedRatio = currentDeltaTime / Math.max(currentDeltaTime, deltaDifference);
1214
- const windowRatio = Math.pow(Math.min(1, currentDeltaTime / (greatWindow * 2)), 2);
1215
- doubletapness = Math.pow(speedRatio, 1 - windowRatio);
1216
- }
1217
- return (Math.sqrt(4 + rhythmComplexitySum * this.rhythmMultiplier * doubletapness) / 2);
1341
+ return Math.sqrt(4 + rhythmComplexitySum * this.rhythmMultiplier) / 2;
1218
1342
  }
1219
1343
  }
1344
+ DroidRhythmEvaluator.rhythmMultiplier = 1.2;
1345
+ DroidRhythmEvaluator.historyTimeMax = 4000;
1346
+ DroidRhythmEvaluator.maxIslandSize = 7;
1347
+ DroidRhythmEvaluator.historyObjectsMax = 24;
1220
1348
 
1221
1349
  /**
1222
1350
  * Represents the skill required to properly follow a beatmap's rhythm.
1223
1351
  */
1224
1352
  class DroidRhythm extends DroidSkill {
1225
- constructor(mods, overallDifficulty) {
1226
- super(mods);
1353
+ constructor() {
1354
+ super(...arguments);
1227
1355
  this.reducedSectionCount = 5;
1228
1356
  this.reducedSectionBaseline = 0.75;
1229
1357
  this.strainDecayBase = 0.3;
1230
1358
  this.starsPerDouble = 1.75;
1231
1359
  this.currentRhythmStrain = 0;
1232
1360
  this.currentRhythmMultiplier = 1;
1233
- this.hitWindow = new osuBase.OsuHitWindow(overallDifficulty);
1234
1361
  }
1235
1362
  strainValueAt(current) {
1236
1363
  this.currentRhythmMultiplier =
1237
- DroidRhythmEvaluator.evaluateDifficultyOf(current, this.hitWindow.hitWindowFor300());
1364
+ DroidRhythmEvaluator.evaluateDifficultyOf(current);
1238
1365
  this.currentRhythmStrain *= this.strainDecay(current.deltaTime);
1239
1366
  this.currentRhythmStrain += this.currentRhythmMultiplier - 1;
1240
1367
  return this.currentRhythmStrain;
@@ -1418,10 +1545,11 @@ class DroidDifficultyHitObject extends DifficultyHitObject {
1418
1545
  * @param lastLastObject The hitobject before the last hitobject.
1419
1546
  * @param difficultyHitObjects All difficulty hitobjects in the processed beatmap.
1420
1547
  * @param clockRate The clock rate of the beatmap.
1548
+ * @param greatWindow The great window of the hitobject.
1421
1549
  * @param isForceAR Whether force AR is enabled.
1422
1550
  */
1423
- constructor(object, lastObject, lastLastObject, difficultyHitObjects, clockRate, isForceAR) {
1424
- super(object, lastObject, lastLastObject, difficultyHitObjects, clockRate);
1551
+ constructor(object, lastObject, lastLastObject, difficultyHitObjects, clockRate, greatWindow, isForceAR) {
1552
+ super(object, lastObject, lastLastObject, difficultyHitObjects, clockRate, greatWindow);
1425
1553
  /**
1426
1554
  * The tap strain generated by the hitobject.
1427
1555
  */
@@ -1560,7 +1688,9 @@ class DroidDifficultyHitObject extends DifficultyHitObject {
1560
1688
  Math.max(0, 1 - distance / (2.5 * this.object.radius)) *
1561
1689
  (7.5 /
1562
1690
  (1 +
1563
- Math.exp(0.15 * (Math.max(deltaTime, this.minDeltaTime) - 75))));
1691
+ Math.exp(0.15 *
1692
+ (Math.max(deltaTime, DifficultyHitObject.minDeltaTime) -
1693
+ 75))));
1564
1694
  }
1565
1695
  }
1566
1696
 
@@ -1672,11 +1802,10 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
1672
1802
  * Calculates the tap star rating of the beatmap and stores it in this instance.
1673
1803
  */
1674
1804
  calculateTap() {
1675
- const od = this.difficultyStatistics.overallDifficulty;
1676
- const tapSkillCheese = new DroidTap(this.mods, od, true);
1677
- const tapSkillNoCheese = new DroidTap(this.mods, od, false);
1805
+ const tapSkillCheese = new DroidTap(this.mods, true);
1806
+ const tapSkillNoCheese = new DroidTap(this.mods, false);
1678
1807
  this.calculateSkills(tapSkillCheese, tapSkillNoCheese);
1679
- const tapSkillVibro = new DroidTap(this.mods, od, true, tapSkillCheese.relevantDeltaTime());
1808
+ const tapSkillVibro = new DroidTap(this.mods, true, tapSkillCheese.relevantDeltaTime());
1680
1809
  this.calculateSkills(tapSkillVibro);
1681
1810
  this.postCalculateTap(tapSkillCheese, tapSkillVibro);
1682
1811
  }
@@ -1684,7 +1813,7 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
1684
1813
  * Calculates the rhythm star rating of the beatmap and stores it in this instance.
1685
1814
  */
1686
1815
  calculateRhythm() {
1687
- const rhythmSkill = new DroidRhythm(this.mods, this.difficultyStatistics.overallDifficulty);
1816
+ const rhythmSkill = new DroidRhythm(this.mods);
1688
1817
  this.calculateSkills(rhythmSkill);
1689
1818
  this.postCalculateRhythm(rhythmSkill);
1690
1819
  }
@@ -1744,7 +1873,7 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
1744
1873
  const flashlightSkillWithoutSliders = skills[6];
1745
1874
  const visualSkill = skills[7];
1746
1875
  const visualSkillWithoutSliders = skills[8];
1747
- const tapSkillVibro = new DroidTap(this.mods, this.difficultyStatistics.overallDifficulty, true, tapSkillCheese.relevantDeltaTime());
1876
+ const tapSkillVibro = new DroidTap(this.mods, true, tapSkillCheese.relevantDeltaTime());
1748
1877
  this.calculateSkills(tapSkillVibro);
1749
1878
  this.postCalculateAim(aimSkill, aimSkillWithoutSliders);
1750
1879
  this.postCalculateTap(tapSkillCheese, tapSkillVibro);
@@ -1772,19 +1901,19 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
1772
1901
  const difficultyObjects = [];
1773
1902
  const { objects } = convertedBeatmap.hitObjects;
1774
1903
  const difficultyAdjustMod = this.mods.find((m) => m instanceof osuBase.ModDifficultyAdjust);
1904
+ const greatWindow = new osuBase.OsuHitWindow(this.difficultyStatistics.overallDifficulty).hitWindowFor300();
1775
1905
  for (let i = 0; i < objects.length; ++i) {
1776
- const difficultyObject = new DroidDifficultyHitObject(objects[i], (_a = objects[i - 1]) !== null && _a !== void 0 ? _a : null, (_b = objects[i - 2]) !== null && _b !== void 0 ? _b : null, difficultyObjects, this.difficultyStatistics.overallSpeedMultiplier, (difficultyAdjustMod === null || difficultyAdjustMod === void 0 ? void 0 : difficultyAdjustMod.ar) !== undefined);
1906
+ const difficultyObject = new DroidDifficultyHitObject(objects[i], (_a = objects[i - 1]) !== null && _a !== void 0 ? _a : null, (_b = objects[i - 2]) !== null && _b !== void 0 ? _b : null, difficultyObjects, this.difficultyStatistics.overallSpeedMultiplier, greatWindow, (difficultyAdjustMod === null || difficultyAdjustMod === void 0 ? void 0 : difficultyAdjustMod.ar) !== undefined);
1777
1907
  difficultyObject.computeProperties(this.difficultyStatistics.overallSpeedMultiplier, objects);
1778
1908
  difficultyObjects.push(difficultyObject);
1779
1909
  }
1780
1910
  return difficultyObjects;
1781
1911
  }
1782
1912
  computeDifficultyStatistics(options) {
1783
- var _a;
1784
1913
  const { difficulty } = this.beatmap;
1785
1914
  return osuBase.calculateDroidDifficultyStatistics({
1786
1915
  circleSize: difficulty.cs,
1787
- approachRate: (_a = difficulty.ar) !== null && _a !== void 0 ? _a : difficulty.od,
1916
+ approachRate: difficulty.ar,
1788
1917
  overallDifficulty: difficulty.od,
1789
1918
  healthDrain: difficulty.hp,
1790
1919
  mods: this.mods,
@@ -1793,16 +1922,15 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
1793
1922
  });
1794
1923
  }
1795
1924
  createSkills() {
1796
- const od = this.difficultyStatistics.overallDifficulty;
1797
1925
  return [
1798
1926
  new DroidAim(this.mods, true),
1799
1927
  new DroidAim(this.mods, false),
1800
1928
  // Tap skill depends on rhythm skill, so we put it first
1801
- new DroidRhythm(this.mods, od),
1929
+ new DroidRhythm(this.mods),
1802
1930
  // Cheesability tap
1803
- new DroidTap(this.mods, od, true),
1931
+ new DroidTap(this.mods, true),
1804
1932
  // Non-cheesability tap
1805
- new DroidTap(this.mods, od, false),
1933
+ new DroidTap(this.mods, false),
1806
1934
  new DroidFlashlight(this.mods, true),
1807
1935
  new DroidFlashlight(this.mods, false),
1808
1936
  new DroidVisual(this.mods, true),
@@ -1818,10 +1946,14 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
1818
1946
  postCalculateAim(aimSkill, aimSkillWithoutSliders) {
1819
1947
  this.strainPeaks.aimWithSliders = aimSkill.strainPeaks;
1820
1948
  this.strainPeaks.aimWithoutSliders = aimSkillWithoutSliders.strainPeaks;
1821
- this.attributes.aimDifficulty = this.starValue(aimSkill.difficultyValue());
1949
+ const retryabilityScaling = this.calculateRetryabilityScaling(aimSkill.countRetryability());
1950
+ this.attributes.aimDifficulty = this.mods.some((m) => m instanceof osuBase.ModAutopilot)
1951
+ ? 0
1952
+ : this.starValue(aimSkill.difficultyValue()) * retryabilityScaling;
1822
1953
  if (this.aim) {
1823
1954
  this.attributes.sliderFactor =
1824
- this.starValue(aimSkillWithoutSliders.difficultyValue()) /
1955
+ (this.starValue(aimSkillWithoutSliders.difficultyValue()) *
1956
+ retryabilityScaling) /
1825
1957
  this.aim;
1826
1958
  }
1827
1959
  if (this.mods.some((m) => m instanceof osuBase.ModRelax)) {
@@ -1835,6 +1967,7 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
1835
1967
  * Calculates aim-related attributes.
1836
1968
  */
1837
1969
  calculateAimAttributes() {
1970
+ this.attributes.difficultSliders = [];
1838
1971
  const topDifficultSliders = [];
1839
1972
  for (let i = 0; i < this.objects.length; ++i) {
1840
1973
  const object = this.objects[i];
@@ -1872,12 +2005,16 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
1872
2005
  */
1873
2006
  postCalculateTap(tapSkillCheese, tapSkillVibro) {
1874
2007
  this.strainPeaks.speed = tapSkillCheese.strainPeaks;
2008
+ const retryabilityScaling = this.calculateRetryabilityScaling(tapSkillCheese.countRetryability());
1875
2009
  this.attributes.tapDifficulty = this.mods.some((m) => m instanceof osuBase.ModRelax)
1876
2010
  ? 0
1877
- : this.starValue(tapSkillCheese.difficultyValue());
2011
+ : this.starValue(tapSkillCheese.difficultyValue()) *
2012
+ retryabilityScaling;
1878
2013
  if (this.tap) {
1879
2014
  this.attributes.vibroFactor =
1880
- this.starValue(tapSkillVibro.difficultyValue()) / this.tap;
2015
+ (this.starValue(tapSkillVibro.difficultyValue()) *
2016
+ retryabilityScaling) /
2017
+ this.tap;
1881
2018
  }
1882
2019
  this.attributes.speedNoteCount = tapSkillCheese.relevantNoteCount();
1883
2020
  this.attributes.averageSpeedDeltaTime =
@@ -1955,10 +2092,12 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
1955
2092
  this.attributes.flashlightSliderFactor =
1956
2093
  this.starValue(flashlightSkillWithoutSliders.difficultyValue()) / this.flashlight;
1957
2094
  }
2095
+ if (this.mods.some((m) => m instanceof osuBase.ModAutopilot)) {
2096
+ this.attributes.flashlightDifficulty *= 0.3;
2097
+ }
1958
2098
  if (this.mods.some((m) => m instanceof osuBase.ModRelax)) {
1959
2099
  this.attributes.flashlightDifficulty *= 0.7;
1960
2100
  }
1961
- this.attributes.flashlightDifficulty = this.flashlight;
1962
2101
  this.attributes.flashlightDifficultStrainCount =
1963
2102
  flashlightSkill.countDifficultStrains();
1964
2103
  }
@@ -1977,9 +2116,15 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
1977
2116
  this.starValue(visualSkillWithoutSliders.difficultyValue()) /
1978
2117
  this.visual;
1979
2118
  }
2119
+ if (this.mods.some((m) => m instanceof osuBase.ModAutopilot)) {
2120
+ this.attributes.visualDifficulty *= 0.8;
2121
+ }
1980
2122
  this.attributes.visualDifficultStrainCount =
1981
2123
  visualSkillWithSliders.countDifficultStrains();
1982
2124
  }
2125
+ calculateRetryabilityScaling(retryability) {
2126
+ return 1 - Math.pow(retryability, 4) / 10;
2127
+ }
1983
2128
  }
1984
2129
  /**
1985
2130
  * The strain threshold to start detecting for possible three-fingered section.
@@ -2371,8 +2516,9 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2371
2516
  let tapValue = this.baseValue(this.difficultyAttributes.tapDifficulty);
2372
2517
  tapValue *= this.calculateStrainBasedMissPenalty(this.difficultyAttributes.tapDifficultStrainCount);
2373
2518
  // Scale the tap value with estimated full combo deviation.
2374
- // Require more objects to be present as object count can rack up easily in tap-oriented beatmaps.
2375
- tapValue *= this.calculateDeviationBasedLengthScaling(this.totalHits / 1.45);
2519
+ // Consider notes that are difficult to tap with respect to other notes, but
2520
+ // also cap the note count to prevent buffing filler patterns.
2521
+ tapValue *= this.calculateDeviationBasedLengthScaling(Math.min(this.difficultyAttributes.speedNoteCount, this.totalHits / 1.45));
2376
2522
  // Normalize the deviation to 300 BPM.
2377
2523
  const normalizedDeviation = this.tapDeviation *
2378
2524
  Math.max(1, 50 / this.difficultyAttributes.averageSpeedDeltaTime);
@@ -2912,30 +3058,19 @@ class OsuSpeedEvaluator extends SpeedEvaluator {
2912
3058
  * - and how easily they can be cheesed.
2913
3059
  *
2914
3060
  * @param current The current object.
2915
- * @param greatWindow The great hit window of the current object.
2916
3061
  */
2917
- static evaluateDifficultyOf(current, greatWindow) {
3062
+ static evaluateDifficultyOf(current) {
2918
3063
  var _a;
2919
3064
  if (current.object instanceof osuBase.Spinner) {
2920
3065
  return 0;
2921
3066
  }
2922
3067
  const prev = current.previous(0);
2923
3068
  let strainTime = current.strainTime;
2924
- const greatWindowFull = greatWindow * 2;
2925
3069
  // Nerf doubletappable doubles.
2926
- const next = current.next(0);
2927
- let doubletapness = 1;
2928
- if (next) {
2929
- const currentDeltaTime = Math.max(1, current.deltaTime);
2930
- const nextDeltaTime = Math.max(1, next.deltaTime);
2931
- const deltaDifference = Math.abs(nextDeltaTime - currentDeltaTime);
2932
- const speedRatio = currentDeltaTime / Math.max(currentDeltaTime, deltaDifference);
2933
- const windowRatio = Math.pow(Math.min(1, currentDeltaTime / greatWindowFull), 2);
2934
- doubletapness = Math.pow(speedRatio, 1 - windowRatio);
2935
- }
3070
+ const doubletapness = 1 - current.doubletapness;
2936
3071
  // Cap deltatime to the OD 300 hitwindow.
2937
3072
  // 0.93 is derived from making sure 260 BPM 1/4 OD8 streams aren't nerfed harshly, whilst 0.92 limits the effect of the cap.
2938
- strainTime /= osuBase.MathUtils.clamp(strainTime / greatWindowFull / 0.93, 0.92, 1);
3073
+ strainTime /= osuBase.MathUtils.clamp(strainTime / current.fullGreatWindow / 0.93, 0.92, 1);
2939
3074
  let speedBonus = 1;
2940
3075
  if (strainTime < this.minSpeedBonus) {
2941
3076
  speedBonus +=
@@ -2964,9 +3099,8 @@ class OsuRhythmEvaluator extends RhythmEvaluator {
2964
3099
  * with historic data of the current object.
2965
3100
  *
2966
3101
  * @param current The current object.
2967
- * @param greatWindow The great hit window of the current object.
2968
3102
  */
2969
- static evaluateDifficultyOf(current, greatWindow) {
3103
+ static evaluateDifficultyOf(current) {
2970
3104
  if (current.object instanceof osuBase.Spinner) {
2971
3105
  return 0;
2972
3106
  }
@@ -3001,8 +3135,9 @@ class OsuRhythmEvaluator extends RhythmEvaluator {
3001
3135
  Math.min(0.5, Math.pow(Math.sin(Math.PI /
3002
3136
  (Math.min(prevDelta, currentDelta) /
3003
3137
  Math.max(prevDelta, currentDelta))), 2));
3004
- const windowPenalty = Math.min(1, Math.max(0, Math.abs(prevDelta - currentDelta) - greatWindow * 0.6) /
3005
- (greatWindow * 0.6));
3138
+ const windowPenalty = Math.min(1, Math.max(0, Math.abs(prevDelta - currentDelta) -
3139
+ current.fullGreatWindow * 0.3) /
3140
+ (current.fullGreatWindow * 0.3));
3006
3141
  let effectiveRatio = windowPenalty * currentRatio;
3007
3142
  if (firstDeltaSwitch) {
3008
3143
  if (prevDelta <= 1.25 * currentDelta &&
@@ -3068,8 +3203,8 @@ class OsuRhythmEvaluator extends RhythmEvaluator {
3068
3203
  * Represents the skill required to press keys or tap with regards to keeping up with the speed at which objects need to be hit.
3069
3204
  */
3070
3205
  class OsuSpeed extends OsuSkill {
3071
- constructor(mods, overallDifficulty) {
3072
- super(mods);
3206
+ constructor() {
3207
+ super(...arguments);
3073
3208
  this.strainDecayBase = 0.3;
3074
3209
  this.reducedSectionCount = 5;
3075
3210
  this.reducedSectionBaseline = 0.75;
@@ -3078,7 +3213,6 @@ class OsuSpeed extends OsuSkill {
3078
3213
  this.currentSpeedStrain = 0;
3079
3214
  this.currentRhythm = 0;
3080
3215
  this.skillMultiplier = 1375;
3081
- this.greatWindow = new osuBase.OsuHitWindow(overallDifficulty).hitWindowFor300();
3082
3216
  }
3083
3217
  /**
3084
3218
  * @param current The hitobject to calculate.
@@ -3086,9 +3220,9 @@ class OsuSpeed extends OsuSkill {
3086
3220
  strainValueAt(current) {
3087
3221
  this.currentSpeedStrain *= this.strainDecay(current.strainTime);
3088
3222
  this.currentSpeedStrain +=
3089
- OsuSpeedEvaluator.evaluateDifficultyOf(current, this.greatWindow) *
3223
+ OsuSpeedEvaluator.evaluateDifficultyOf(current) *
3090
3224
  this.skillMultiplier;
3091
- this.currentRhythm = OsuRhythmEvaluator.evaluateDifficultyOf(current, this.greatWindow);
3225
+ this.currentRhythm = OsuRhythmEvaluator.evaluateDifficultyOf(current);
3092
3226
  return this.currentSpeedStrain * this.currentRhythm;
3093
3227
  }
3094
3228
  calculateInitialStrain(time, current) {
@@ -3222,29 +3356,8 @@ class OsuFlashlight extends OsuSkill {
3222
3356
  * Represents an osu!standard hit object with difficulty calculation values.
3223
3357
  */
3224
3358
  class OsuDifficultyHitObject extends DifficultyHitObject {
3225
- get scalingFactor() {
3226
- const radius = this.object.radius;
3227
- // We will scale distances by this factor, so we can assume a uniform CircleSize among beatmaps.
3228
- let scalingFactor = this.normalizedRadius / radius;
3229
- // High circle size (small CS) bonus
3230
- if (radius < this.radiusBuffThreshold) {
3231
- scalingFactor *=
3232
- 1 + Math.min(this.radiusBuffThreshold - radius, 5) / 50;
3233
- }
3234
- return scalingFactor;
3235
- }
3236
- /**
3237
- * Note: You **must** call `computeProperties` at some point due to how TypeScript handles
3238
- * overridden properties (see [this](https://github.com/microsoft/TypeScript/issues/1617) GitHub issue).
3239
- *
3240
- * @param object The underlying hitobject.
3241
- * @param lastObject The hitobject before this hitobject.
3242
- * @param lastLastObject The hitobject before the last hitobject.
3243
- * @param difficultyHitObjects All difficulty hitobjects in the processed beatmap.
3244
- * @param clockRate The clock rate of the beatmap.
3245
- */
3246
- constructor(object, lastObject, lastLastObject, difficultyHitObjects, clockRate) {
3247
- super(object, lastObject, lastLastObject, difficultyHitObjects, clockRate);
3359
+ constructor() {
3360
+ super(...arguments);
3248
3361
  /**
3249
3362
  * The speed strain generated by the hitobject.
3250
3363
  */
@@ -3256,6 +3369,17 @@ class OsuDifficultyHitObject extends DifficultyHitObject {
3256
3369
  this.radiusBuffThreshold = 30;
3257
3370
  this.mode = osuBase.Modes.osu;
3258
3371
  }
3372
+ get scalingFactor() {
3373
+ const radius = this.object.radius;
3374
+ // We will scale distances by this factor, so we can assume a uniform CircleSize among beatmaps.
3375
+ let scalingFactor = this.normalizedRadius / radius;
3376
+ // High circle size (small CS) bonus
3377
+ if (radius < this.radiusBuffThreshold) {
3378
+ scalingFactor *=
3379
+ 1 + Math.min(this.radiusBuffThreshold - radius, 5) / 50;
3380
+ }
3381
+ return scalingFactor;
3382
+ }
3259
3383
  }
3260
3384
 
3261
3385
  /**
@@ -3317,7 +3441,7 @@ class OsuDifficultyCalculator extends DifficultyCalculator {
3317
3441
  * Calculates the speed star rating of the beatmap and stores it in this instance.
3318
3442
  */
3319
3443
  calculateSpeed() {
3320
- const speedSkill = new OsuSpeed(this.mods, this.difficultyStatistics.overallDifficulty);
3444
+ const speedSkill = new OsuSpeed(this.mods);
3321
3445
  this.calculateSkills(speedSkill);
3322
3446
  this.postCalculateSpeed(speedSkill);
3323
3447
  }
@@ -3379,19 +3503,19 @@ class OsuDifficultyCalculator extends DifficultyCalculator {
3379
3503
  var _a, _b;
3380
3504
  const difficultyObjects = [];
3381
3505
  const { objects } = convertedBeatmap.hitObjects;
3506
+ const greatWindow = new osuBase.OsuHitWindow(this.difficultyStatistics.overallDifficulty).hitWindowFor300();
3382
3507
  for (let i = 0; i < objects.length; ++i) {
3383
- const difficultyObject = new OsuDifficultyHitObject(objects[i], (_a = objects[i - 1]) !== null && _a !== void 0 ? _a : null, (_b = objects[i - 2]) !== null && _b !== void 0 ? _b : null, difficultyObjects, this.difficultyStatistics.overallSpeedMultiplier);
3508
+ const difficultyObject = new OsuDifficultyHitObject(objects[i], (_a = objects[i - 1]) !== null && _a !== void 0 ? _a : null, (_b = objects[i - 2]) !== null && _b !== void 0 ? _b : null, difficultyObjects, this.difficultyStatistics.overallSpeedMultiplier, greatWindow);
3384
3509
  difficultyObject.computeProperties(this.difficultyStatistics.overallSpeedMultiplier, objects);
3385
3510
  difficultyObjects.push(difficultyObject);
3386
3511
  }
3387
3512
  return difficultyObjects;
3388
3513
  }
3389
3514
  computeDifficultyStatistics(options) {
3390
- var _a;
3391
3515
  const { difficulty } = this.beatmap;
3392
3516
  return osuBase.calculateOsuDifficultyStatistics({
3393
3517
  circleSize: difficulty.cs,
3394
- approachRate: (_a = difficulty.ar) !== null && _a !== void 0 ? _a : difficulty.od,
3518
+ approachRate: difficulty.ar,
3395
3519
  overallDifficulty: difficulty.od,
3396
3520
  healthDrain: difficulty.hp,
3397
3521
  mods: options === null || options === void 0 ? void 0 : options.mods,
@@ -3402,7 +3526,7 @@ class OsuDifficultyCalculator extends DifficultyCalculator {
3402
3526
  return [
3403
3527
  new OsuAim(this.mods, true),
3404
3528
  new OsuAim(this.mods, false),
3405
- new OsuSpeed(this.mods, this.difficultyStatistics.overallDifficulty),
3529
+ new OsuSpeed(this.mods),
3406
3530
  new OsuFlashlight(this.mods),
3407
3531
  ];
3408
3532
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rian8337/osu-rebalance-difficulty-calculator",
3
- "version": "4.0.0-beta.23",
3
+ "version": "4.0.0-beta.25",
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",
@@ -33,10 +33,10 @@
33
33
  "url": "https://github.com/Rian8337/osu-droid-module/issues"
34
34
  },
35
35
  "dependencies": {
36
- "@rian8337/osu-base": "^4.0.0-beta.23"
36
+ "@rian8337/osu-base": "^4.0.0-beta.25"
37
37
  },
38
38
  "publishConfig": {
39
39
  "access": "public"
40
40
  },
41
- "gitHead": "62063ddac57c3a60426c7206268a0573cc6db6dd"
41
+ "gitHead": "2d6271ea24c787caad1d24c3d20dbeeaf450359e"
42
42
  }
@@ -191,6 +191,10 @@ declare abstract class DifficultyHitObject {
191
191
  * Adjusted end time of the hitobject, taking speed multiplier into account.
192
192
  */
193
193
  readonly endTime: number;
194
+ /**
195
+ * The full great window of the hitobject.
196
+ */
197
+ readonly fullGreatWindow: number;
194
198
  /**
195
199
  * Other hitobjects in the beatmap, including this hitobject.
196
200
  */
@@ -199,7 +203,10 @@ declare abstract class DifficultyHitObject {
199
203
  protected readonly normalizedRadius = 50;
200
204
  protected readonly maximumSliderRadius: number;
201
205
  protected readonly assumedSliderRadius: number;
202
- protected readonly minDeltaTime = 25;
206
+ /**
207
+ * The lowest possible delta time value.
208
+ */
209
+ static readonly minDeltaTime = 25;
203
210
  private readonly lastObject;
204
211
  private readonly lastLastObject;
205
212
  /**
@@ -211,8 +218,9 @@ declare abstract class DifficultyHitObject {
211
218
  * @param lastLastObject The hitobject before the last hitobject.
212
219
  * @param difficultyHitObjects All difficulty hitobjects in the processed beatmap.
213
220
  * @param clockRate The clock rate of the beatmap.
221
+ * @param greatWindow The great window of the hitobject.
214
222
  */
215
- protected constructor(object: PlaceableHitObject, lastObject: PlaceableHitObject | null, lastLastObject: PlaceableHitObject | null, difficultyHitObjects: readonly DifficultyHitObject[], clockRate: number);
223
+ constructor(object: PlaceableHitObject, lastObject: PlaceableHitObject | null, lastLastObject: PlaceableHitObject | null, difficultyHitObjects: readonly DifficultyHitObject[], clockRate: number, greatWindow: number);
216
224
  /**
217
225
  * Computes the properties of this hitobject.
218
226
  *
@@ -250,6 +258,13 @@ declare abstract class DifficultyHitObject {
250
258
  * @returns The opacity of the hitobject at the given time.
251
259
  */
252
260
  opacityAt(time: number, isHidden: boolean): number;
261
+ /**
262
+ * How possible is it to doubletap this object together with the next one and get perfect
263
+ * judgement in range from 0 to 1.
264
+ *
265
+ * A value closer to 1 indicates a higher possibility.
266
+ */
267
+ get doubletapness(): number;
253
268
  protected abstract get scalingFactor(): number;
254
269
  protected setDistances(clockRate: number): void;
255
270
  private calculateSliderCursorPosition;
@@ -515,6 +530,10 @@ declare abstract class DroidSkill extends StrainSkill {
515
530
  * The bonus multiplier that is given for a sequence of notes of equal difficulty.
516
531
  */
517
532
  protected abstract readonly starsPerDouble: number;
533
+ /**
534
+ * The minimum number of strains to judge when computing for retryability.
535
+ */
536
+ protected readonly minimumRetryabilityStrains: number;
518
537
  protected readonly _objectStrains: number[];
519
538
  /**
520
539
  * The strains of hitobjects.
@@ -527,6 +546,16 @@ declare abstract class DroidSkill extends StrainSkill {
527
546
  * The result is scaled by clock rate as it affects the total number of strains.
528
547
  */
529
548
  countDifficultStrains(): number;
549
+ /**
550
+ * Computes the retryability of the beatmap based on the strains of the hitobjects.
551
+ *
552
+ * Earlier difficult strains indicate higher retryability.
553
+ *
554
+ * The result is scaled by clock rate as it affects the total number of strains.
555
+ *
556
+ * @returns A number between 0 and 1. A higher value indicates higher retryability.
557
+ */
558
+ countRetryability(): number;
530
559
  process(current: DifficultyHitObject): void;
531
560
  difficultyValue(): number;
532
561
  /**
@@ -599,9 +628,10 @@ declare class DroidDifficultyHitObject extends DifficultyHitObject {
599
628
  * @param lastLastObject The hitobject before the last hitobject.
600
629
  * @param difficultyHitObjects All difficulty hitobjects in the processed beatmap.
601
630
  * @param clockRate The clock rate of the beatmap.
631
+ * @param greatWindow The great window of the hitobject.
602
632
  * @param isForceAR Whether force AR is enabled.
603
633
  */
604
- constructor(object: PlaceableHitObject, lastObject: PlaceableHitObject | null, lastLastObject: PlaceableHitObject | null, difficultyHitObjects: readonly DifficultyHitObject[], clockRate: number, isForceAR: boolean);
634
+ constructor(object: PlaceableHitObject, lastObject: PlaceableHitObject | null, lastLastObject: PlaceableHitObject | null, difficultyHitObjects: readonly DifficultyHitObject[], clockRate: number, greatWindow: number, isForceAR: boolean);
605
635
  computeProperties(clockRate: number, hitObjects: readonly PlaceableHitObject[]): void;
606
636
  /**
607
637
  * Determines whether this hitobject is considered overlapping with the hitobject before it.
@@ -886,6 +916,7 @@ declare class DroidDifficultyCalculator extends DifficultyCalculator<DroidDiffic
886
916
  * @param visualSkillWithoutSliders The visual skill that doesn't consider sliders.
887
917
  */
888
918
  private postCalculateVisual;
919
+ private calculateRetryabilityScaling;
889
920
  }
890
921
 
891
922
  /**
@@ -1243,8 +1274,6 @@ declare class DroidRhythm extends DroidSkill {
1243
1274
  protected readonly starsPerDouble = 1.75;
1244
1275
  private currentRhythmStrain;
1245
1276
  private currentRhythmMultiplier;
1246
- private readonly hitWindow;
1247
- constructor(mods: Mod[], overallDifficulty: number);
1248
1277
  protected strainValueAt(current: DroidDifficultyHitObject): number;
1249
1278
  protected calculateInitialStrain(time: number, current: DroidDifficultyHitObject): number;
1250
1279
  protected getObjectStrain(): number;
@@ -1265,14 +1294,17 @@ declare abstract class RhythmEvaluator {
1265
1294
  * An evaluator for calculating osu!droid Rhythm skill.
1266
1295
  */
1267
1296
  declare abstract class DroidRhythmEvaluator extends RhythmEvaluator {
1297
+ protected static readonly rhythmMultiplier = 1.2;
1298
+ protected static readonly historyTimeMax = 4000;
1299
+ private static readonly maxIslandSize;
1300
+ private static readonly historyObjectsMax;
1268
1301
  /**
1269
1302
  * Calculates a rhythm multiplier for the difficulty of the tap associated
1270
1303
  * with historic data of the current object.
1271
1304
  *
1272
1305
  * @param current The current object.
1273
- * @param greatWindow The great hit window of the current object.
1274
1306
  */
1275
- static evaluateDifficultyOf(current: DroidDifficultyHitObject, greatWindow: number): number;
1307
+ static evaluateDifficultyOf(current: DroidDifficultyHitObject): number;
1276
1308
  }
1277
1309
 
1278
1310
  /**
@@ -1283,10 +1315,10 @@ declare class DroidTap extends DroidSkill {
1283
1315
  protected readonly reducedSectionBaseline = 0.75;
1284
1316
  protected readonly strainDecayBase = 0.3;
1285
1317
  protected readonly starsPerDouble = 1.1;
1318
+ protected readonly minimumRetryabilityStrains = 750;
1286
1319
  private currentTapStrain;
1287
1320
  private currentRhythmMultiplier;
1288
1321
  private readonly skillMultiplier;
1289
- private readonly greatWindow;
1290
1322
  private readonly considerCheesability;
1291
1323
  private readonly strainTimeCap?;
1292
1324
  private readonly _objectDeltaTimes;
@@ -1294,7 +1326,7 @@ declare class DroidTap extends DroidSkill {
1294
1326
  * The delta time of hitobjects.
1295
1327
  */
1296
1328
  get objectDeltaTimes(): readonly number[];
1297
- constructor(mods: Mod[], overallDifficulty: number, considerCheesability: boolean, strainTimeCap?: number);
1329
+ constructor(mods: Mod[], considerCheesability: boolean, strainTimeCap?: number);
1298
1330
  /**
1299
1331
  * The amount of notes that are relevant to the difficulty.
1300
1332
  */
@@ -1334,11 +1366,10 @@ declare abstract class DroidTapEvaluator extends SpeedEvaluator {
1334
1366
  * - and the strain time cap.
1335
1367
  *
1336
1368
  * @param current The current object.
1337
- * @param greatWindow The great hit window of the current object.
1338
1369
  * @param considerCheesability Whether to consider cheesability.
1339
1370
  * @param strainTimeCap The strain time to cap the object's strain time to.
1340
1371
  */
1341
- static evaluateDifficultyOf(current: DroidDifficultyHitObject, greatWindow: number, considerCheesability: boolean, strainTimeCap?: number): number;
1372
+ static evaluateDifficultyOf(current: DroidDifficultyHitObject, considerCheesability: boolean, strainTimeCap?: number): number;
1342
1373
  }
1343
1374
 
1344
1375
  /**
@@ -1420,17 +1451,6 @@ declare class OsuDifficultyHitObject extends DifficultyHitObject {
1420
1451
  private readonly radiusBuffThreshold;
1421
1452
  protected readonly mode = Modes.osu;
1422
1453
  protected get scalingFactor(): number;
1423
- /**
1424
- * Note: You **must** call `computeProperties` at some point due to how TypeScript handles
1425
- * overridden properties (see [this](https://github.com/microsoft/TypeScript/issues/1617) GitHub issue).
1426
- *
1427
- * @param object The underlying hitobject.
1428
- * @param lastObject The hitobject before this hitobject.
1429
- * @param lastLastObject The hitobject before the last hitobject.
1430
- * @param difficultyHitObjects All difficulty hitobjects in the processed beatmap.
1431
- * @param clockRate The clock rate of the beatmap.
1432
- */
1433
- constructor(object: PlaceableHitObject, lastObject: PlaceableHitObject | null, lastLastObject: PlaceableHitObject | null, difficultyHitObjects: readonly DifficultyHitObject[], clockRate: number);
1434
1454
  }
1435
1455
 
1436
1456
  /**
@@ -1632,9 +1652,8 @@ declare abstract class OsuRhythmEvaluator extends RhythmEvaluator {
1632
1652
  * with historic data of the current object.
1633
1653
  *
1634
1654
  * @param current The current object.
1635
- * @param greatWindow The great hit window of the current object.
1636
1655
  */
1637
- static evaluateDifficultyOf(current: OsuDifficultyHitObject, greatWindow: number): number;
1656
+ static evaluateDifficultyOf(current: OsuDifficultyHitObject): number;
1638
1657
  }
1639
1658
 
1640
1659
  /**
@@ -1649,8 +1668,6 @@ declare class OsuSpeed extends OsuSkill {
1649
1668
  private currentSpeedStrain;
1650
1669
  private currentRhythm;
1651
1670
  private readonly skillMultiplier;
1652
- private readonly greatWindow;
1653
- constructor(mods: Mod[], overallDifficulty: number);
1654
1671
  /**
1655
1672
  * @param current The hitobject to calculate.
1656
1673
  */
@@ -1678,9 +1695,8 @@ declare abstract class OsuSpeedEvaluator extends SpeedEvaluator {
1678
1695
  * - and how easily they can be cheesed.
1679
1696
  *
1680
1697
  * @param current The current object.
1681
- * @param greatWindow The great hit window of the current object.
1682
1698
  */
1683
- static evaluateDifficultyOf(current: OsuDifficultyHitObject, greatWindow: number): number;
1699
+ static evaluateDifficultyOf(current: OsuDifficultyHitObject): number;
1684
1700
  }
1685
1701
 
1686
1702
  export { AimEvaluator, type CacheableDifficultyAttributes, type DifficultSlider, type DifficultyAttributes, type DifficultyCalculationOptions, DifficultyCalculator, DifficultyHitObject, DroidAim, DroidAimEvaluator, type DroidDifficultyAttributes, type DroidDifficultyCalculationOptions, DroidDifficultyCalculator, DroidDifficultyHitObject, DroidFlashlight, DroidFlashlightEvaluator, DroidPerformanceCalculator, DroidRhythm, DroidRhythmEvaluator, DroidTap, DroidTapEvaluator, DroidVisual, DroidVisualEvaluator, type ExtendedDroidDifficultyAttributes, FlashlightEvaluator, type HighStrainSection, OsuAim, OsuAimEvaluator, type OsuDifficultyAttributes, OsuDifficultyCalculator, OsuDifficultyHitObject, OsuFlashlight, OsuFlashlightEvaluator, OsuPerformanceCalculator, OsuRhythmEvaluator, OsuSpeed, OsuSpeedEvaluator, type PerformanceCalculationOptions, PerformanceCalculator, RhythmEvaluator, SpeedEvaluator, type StrainPeaks };