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

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
@@ -32,6 +32,12 @@ AimEvaluator.velocityChangeMultiplier = 0.75;
32
32
  * The base of a difficulty calculator.
33
33
  */
34
34
  class DifficultyCalculator {
35
+ /**
36
+ * The difficulty objects of the beatmap.
37
+ */
38
+ get objects() {
39
+ return this._objects;
40
+ }
35
41
  /**
36
42
  * The total star rating of the beatmap.
37
43
  */
@@ -41,13 +47,13 @@ class DifficultyCalculator {
41
47
  /**
42
48
  * Constructs a new instance of the calculator.
43
49
  *
44
- * @param beatmap The beatmap to calculate. This beatmap will be deep-cloned to prevent reference changes.
50
+ * @param beatmap The beatmap to calculate.
45
51
  */
46
52
  constructor(beatmap) {
47
53
  /**
48
54
  * The difficulty objects of the beatmap.
49
55
  */
50
- this.objects = [];
56
+ this._objects = [];
51
57
  /**
52
58
  * The modifications applied.
53
59
  */
@@ -62,13 +68,6 @@ class DifficultyCalculator {
62
68
  flashlight: [],
63
69
  };
64
70
  this.beatmap = beatmap;
65
- this.difficultyStatistics = {
66
- circleSize: beatmap.difficulty.cs,
67
- approachRate: beatmap.difficulty.ar,
68
- overallDifficulty: beatmap.difficulty.od,
69
- healthDrain: beatmap.difficulty.hp,
70
- overallSpeedMultiplier: 1,
71
- };
72
71
  }
73
72
  /**
74
73
  * Calculates the star rating of the specified beatmap.
@@ -86,16 +85,17 @@ class DifficultyCalculator {
86
85
  * @returns The current instance.
87
86
  */
88
87
  calculate(options) {
89
- var _a;
88
+ var _a, _b;
90
89
  this.mods = (_a = options === null || options === void 0 ? void 0 : options.mods) !== null && _a !== void 0 ? _a : [];
91
90
  const playableBeatmap = this.beatmap.createPlayableBeatmap({
92
91
  mode: this.mode,
93
92
  mods: this.mods,
94
93
  customSpeedMultiplier: options === null || options === void 0 ? void 0 : options.customSpeedMultiplier,
95
94
  });
96
- this.difficultyStatistics = Object.seal(this.computeDifficultyStatistics(options));
97
- this.populateDifficultyAttributes();
98
- this.objects.push(...this.generateDifficultyHitObjects(playableBeatmap));
95
+ const clockRate = osuBase.ModUtil.calculateRateWithMods(this.mods) *
96
+ ((_b = options === null || options === void 0 ? void 0 : options.customSpeedMultiplier) !== null && _b !== void 0 ? _b : 1);
97
+ this.populateDifficultyAttributes(playableBeatmap, clockRate);
98
+ this._objects = this.generateDifficultyHitObjects(playableBeatmap, clockRate);
99
99
  this.calculateAll();
100
100
  return this;
101
101
  }
@@ -114,18 +114,27 @@ class DifficultyCalculator {
114
114
  }
115
115
  /**
116
116
  * Populates the stored difficulty attributes with necessary data.
117
+ *
118
+ * @param beatmap The beatmap to populate the attributes with.
119
+ * @param clockRate The clock rate of the beatmap.
117
120
  */
118
- populateDifficultyAttributes() {
119
- this.attributes.approachRate = this.difficultyStatistics.approachRate;
121
+ populateDifficultyAttributes(beatmap, clockRate) {
120
122
  this.attributes.hitCircleCount = this.beatmap.hitObjects.circles;
121
123
  this.attributes.maxCombo = this.beatmap.maxCombo;
122
124
  this.attributes.mods = this.mods.slice();
123
- this.attributes.overallDifficulty =
124
- this.difficultyStatistics.overallDifficulty;
125
125
  this.attributes.sliderCount = this.beatmap.hitObjects.sliders;
126
126
  this.attributes.spinnerCount = this.beatmap.hitObjects.spinners;
127
- this.attributes.clockRate =
128
- this.difficultyStatistics.overallSpeedMultiplier;
127
+ this.attributes.clockRate = clockRate;
128
+ let greatWindow;
129
+ switch (this.mode) {
130
+ case osuBase.Modes.droid:
131
+ greatWindow = new osuBase.DroidHitWindow(beatmap.difficulty.od).hitWindowFor300(this.mods.some((m) => m instanceof osuBase.ModPrecise));
132
+ break;
133
+ case osuBase.Modes.osu:
134
+ greatWindow = new osuBase.OsuHitWindow(beatmap.difficulty.od).hitWindowFor300();
135
+ break;
136
+ }
137
+ this.attributes.overallDifficulty = osuBase.OsuHitWindow.hitWindow300ToOD(greatWindow / clockRate);
129
138
  }
130
139
  /**
131
140
  * Calculates the star rating value of a difficulty.
@@ -668,11 +677,19 @@ class StrainSkill extends Skill {
668
677
  * Strain peaks are stored here.
669
678
  */
670
679
  this.strainPeaks = [];
680
+ this._objectStrains = [];
681
+ this.difficulty = 0;
671
682
  this.sectionLength = 400;
672
683
  this.currentStrain = 0;
673
684
  this.currentSectionPeak = 0;
674
685
  this.currentSectionEnd = 0;
675
686
  }
687
+ /**
688
+ * The strains of hitobjects.
689
+ */
690
+ get objectStrains() {
691
+ return this._objectStrains;
692
+ }
676
693
  process(current) {
677
694
  // The first object doesn't generate a strain, so we begin with an incremented section end
678
695
  if (current.index === 0) {
@@ -698,6 +715,21 @@ class StrainSkill extends Skill {
698
715
  saveCurrentPeak() {
699
716
  this.strainPeaks.push(this.currentSectionPeak);
700
717
  }
718
+ /**
719
+ * Returns the number of strains weighed against the top strain.
720
+ *
721
+ * The result is scaled by clock rate as it affects the total number of strains.
722
+ */
723
+ countDifficultStrains() {
724
+ if (this.difficulty === 0) {
725
+ return 0;
726
+ }
727
+ // This is what the top strain is if all strain values were identical.
728
+ const consistentTopStrain = this.difficulty / 10;
729
+ // Use a weighted sum of all strains.
730
+ return this._objectStrains.reduce((total, next) => total +
731
+ 1.1 / (1 + Math.exp(-10 * (next / consistentTopStrain - 0.88))), 0);
732
+ }
701
733
  /**
702
734
  * Calculates strain decay for a specified time frame.
703
735
  *
@@ -740,29 +772,6 @@ class DroidSkill extends StrainSkill {
740
772
  * The minimum number of strains to judge when computing for retryability.
741
773
  */
742
774
  this.minimumRetryabilityStrains = 500;
743
- this._objectStrains = [];
744
- this.difficulty = 0;
745
- }
746
- /**
747
- * The strains of hitobjects.
748
- */
749
- get objectStrains() {
750
- return this._objectStrains;
751
- }
752
- /**
753
- * Returns the number of strains weighed against the top strain.
754
- *
755
- * The result is scaled by clock rate as it affects the total number of strains.
756
- */
757
- countDifficultStrains() {
758
- if (this.difficulty === 0) {
759
- return 0;
760
- }
761
- // This is what the top strain is if all strain values were identical.
762
- const consistentTopStrain = this.difficulty / 10;
763
- // Use a weighted sum of all strains.
764
- return this._objectStrains.reduce((total, next) => total +
765
- 1.1 / (1 + Math.exp(-10 * (next / consistentTopStrain - 0.88))), 0);
766
775
  }
767
776
  /**
768
777
  * Computes the retryability of the beatmap based on the strains of the hitobjects.
@@ -1111,7 +1120,7 @@ class DroidFlashlight extends DroidSkill {
1111
1120
  this.reducedSectionCount = 0;
1112
1121
  this.reducedSectionBaseline = 1;
1113
1122
  this.starsPerDouble = 1.06;
1114
- this.skillMultiplier = 0.052;
1123
+ this.skillMultiplier = 0.02;
1115
1124
  this.currentFlashlightStrain = 0;
1116
1125
  this.isHidden = mods.some((m) => m instanceof osuBase.ModHidden);
1117
1126
  this.withSliders = withSliders;
@@ -1140,64 +1149,42 @@ class DroidFlashlight extends DroidSkill {
1140
1149
  }
1141
1150
  }
1142
1151
  difficultyValue() {
1143
- return Math.pow(this.strainPeaks.reduce((a, v) => a + v, 0) * this.starsPerDouble, 0.8);
1152
+ return (this.strainPeaks.reduce((a, v) => a + v, 0) * this.starsPerDouble);
1144
1153
  }
1145
1154
  }
1146
1155
 
1147
- /**
1148
- * An evaluator for calculating rhythm skill.
1149
- *
1150
- * This class should be considered an "evaluating" class and not persisted.
1151
- */
1152
- class RhythmEvaluator {
1153
- }
1154
- RhythmEvaluator.rhythmMultiplier = 0.75;
1155
- RhythmEvaluator.historyTimeMax = 5000; // 5 seconds of calculateRhythmBonus max.
1156
-
1157
- class Island {
1158
- constructor(firstDelta, epsilon) {
1159
- this.deltas = [];
1160
- if (epsilon === undefined) {
1161
- this.deltaDifferenceEpsilon = firstDelta;
1162
- return;
1156
+ let Island$1 = class Island {
1157
+ constructor(delta, deltaDifferenceEpsilon) {
1158
+ this.delta = Number.MAX_SAFE_INTEGER;
1159
+ this.deltaCount = 0;
1160
+ if (deltaDifferenceEpsilon === undefined) {
1161
+ this.deltaDifferenceEpsilon = delta;
1162
+ }
1163
+ else {
1164
+ this.deltaDifferenceEpsilon = deltaDifferenceEpsilon;
1165
+ this.addDelta(delta);
1163
1166
  }
1164
- this.deltaDifferenceEpsilon = epsilon;
1165
- this.addDelta(firstDelta);
1166
1167
  }
1167
1168
  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;
1169
+ if (this.delta === Number.MAX_SAFE_INTEGER) {
1170
+ this.delta = Math.max(Math.trunc(delta), DifficultyHitObject.minDeltaTime);
1171
+ }
1172
+ ++this.deltaCount;
1177
1173
  }
1178
1174
  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);
1175
+ // TODO: consider islands to be of similar polarity only if they're having the same average delta (we don't want to consider 3 singletaps similar to a triple)
1176
+ // naively adding delta check here breaks _a lot_ of maps because of the flawed ratio calculation
1177
+ return this.deltaCount % 2 == other.deltaCount % 2;
1184
1178
  }
1185
1179
  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;
1180
+ return (Math.abs(this.delta - other.delta) < this.deltaDifferenceEpsilon &&
1181
+ this.deltaCount === other.deltaCount);
1195
1182
  }
1196
- }
1183
+ };
1197
1184
  /**
1198
1185
  * An evaluator for calculating osu!droid Rhythm skill.
1199
1186
  */
1200
- class DroidRhythmEvaluator extends RhythmEvaluator {
1187
+ class DroidRhythmEvaluator {
1201
1188
  /**
1202
1189
  * Calculates a rhythm multiplier for the difficulty of the tap associated
1203
1190
  * with historic data of the current object.
@@ -1205,15 +1192,13 @@ class DroidRhythmEvaluator extends RhythmEvaluator {
1205
1192
  * @param current The current object.
1206
1193
  */
1207
1194
  static evaluateDifficultyOf(current) {
1208
- if (current.object instanceof osuBase.Spinner ||
1209
- // Exclude overlapping objects that can be tapped at once.
1210
- current.isOverlapping(false)) {
1195
+ if (current.object instanceof osuBase.Spinner) {
1211
1196
  return 1;
1212
1197
  }
1213
1198
  const deltaDifferenceEpsilon = current.fullGreatWindow * 0.3;
1214
1199
  let rhythmComplexitySum = 0;
1215
- let island = new Island(deltaDifferenceEpsilon);
1216
- let previousIsland = new Island(deltaDifferenceEpsilon);
1200
+ let island = new Island$1(deltaDifferenceEpsilon);
1201
+ let previousIsland = new Island$1(deltaDifferenceEpsilon);
1217
1202
  const islandCounts = new Map();
1218
1203
  // Store the ratio of the current start of an island to buff for tighter rhythms.
1219
1204
  let startRatio = 0;
@@ -1237,47 +1222,50 @@ class DroidRhythmEvaluator extends RhythmEvaluator {
1237
1222
  ++rhythmStart;
1238
1223
  }
1239
1224
  for (let i = rhythmStart; i > 0; --i) {
1240
- // Scale note 0 to 1 from history to now.
1241
- let currentHistoricalDecay = (this.historyTimeMax -
1242
- (current.startTime - validPrevious[i - 1].startTime)) /
1243
- this.historyTimeMax;
1244
- // Either we're limited by time or limited by object count.
1245
- currentHistoricalDecay = Math.min(currentHistoricalDecay, (validPrevious.length - i) / validPrevious.length);
1246
1225
  const currentObject = validPrevious[i - 1];
1247
1226
  const prevObject = validPrevious[i];
1248
1227
  const lastObject = validPrevious[i + 1];
1228
+ // Scale note 0 to 1 from history to now.
1229
+ const timeDecay = (this.historyTimeMax -
1230
+ (current.startTime - currentObject.startTime)) /
1231
+ this.historyTimeMax;
1232
+ const noteDecay = (validPrevious.length - i) / validPrevious.length;
1233
+ // Either we're limited by time or limited by object count.
1234
+ const currentHistoricalDecay = Math.min(timeDecay, noteDecay);
1249
1235
  const currentDelta = currentObject.strainTime;
1250
1236
  const prevDelta = prevObject.strainTime;
1251
1237
  const lastDelta = lastObject.strainTime;
1238
+ // Calculate how much current delta difference deserves a rhythm bonus
1239
+ // This function is meant to reduce rhythm bonus for deltas that are multiples of each other (i.e. 100 and 200)
1240
+ const deltaDifferenceRatio = Math.min(prevDelta, currentDelta) /
1241
+ Math.max(prevDelta, currentDelta);
1252
1242
  const currentRatio = 1 +
1253
- 10 *
1254
- Math.min(0.5, Math.pow(Math.sin(Math.PI /
1255
- (Math.min(prevDelta, currentDelta) /
1256
- Math.max(prevDelta, currentDelta))), 2));
1257
- const windowPenalty = osuBase.MathUtils.clamp((Math.abs(prevDelta - currentDelta) - deltaDifferenceEpsilon) /
1258
- deltaDifferenceEpsilon, 0, 1);
1259
- let effectiveRatio = windowPenalty * currentRatio;
1243
+ this.rhythmRatioMultiplier *
1244
+ Math.min(0.5, Math.pow(Math.sin(Math.PI / deltaDifferenceRatio), 2));
1245
+ // Reduce ratio bonus if delta difference is too big
1246
+ const fraction = Math.max(prevDelta / currentDelta, currentDelta / prevDelta);
1247
+ const fractionMultiplier = osuBase.MathUtils.clamp(2 - fraction / 8, 0, 1);
1248
+ const windowPenalty = Math.min(1, Math.max(0, Math.abs(prevDelta - currentDelta) - deltaDifferenceEpsilon) / deltaDifferenceEpsilon);
1249
+ let effectiveRatio = windowPenalty * currentRatio * fractionMultiplier;
1260
1250
  if (firstDeltaSwitch) {
1261
- if (Math.abs(prevDelta - currentDelta) <= deltaDifferenceEpsilon) {
1262
- if (island.deltas.length < this.maxIslandSize) {
1263
- // Island is still progressing.
1264
- island.addDelta(currentDelta);
1265
- }
1251
+ if (Math.abs(prevDelta - currentDelta) < deltaDifferenceEpsilon) {
1252
+ // Island is still progressing, count size.
1253
+ island.addDelta(currentDelta);
1266
1254
  }
1267
1255
  else {
1268
1256
  // BPM change is into slider, this is easy acc window.
1269
1257
  if (currentObject.object instanceof osuBase.Slider) {
1270
1258
  effectiveRatio /= 8;
1271
1259
  }
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.
1260
+ // BPM change was from a slider, this is easier typically than circle -> circle.
1261
+ // Unintentional side effect is that bursts with kicksliders at the ends might have lower difficulty
1262
+ // than bursts without sliders.
1275
1263
  if (prevObject.object instanceof osuBase.Slider) {
1276
- effectiveRatio /= 4;
1264
+ effectiveRatio *= 0.3;
1277
1265
  }
1278
1266
  // Repeated island polarity (2 -> 4, 3 -> 5).
1279
1267
  if (island.isSimilarPolarity(previousIsland)) {
1280
- effectiveRatio *= 0.3;
1268
+ effectiveRatio /= 2;
1281
1269
  }
1282
1270
  // Previous increase happened a note ago.
1283
1271
  // Albeit this is a 1/1 -> 1/2-1/4 type of transition, we don't want to buff this.
@@ -1285,8 +1273,9 @@ class DroidRhythmEvaluator extends RhythmEvaluator {
1285
1273
  prevDelta > currentDelta + deltaDifferenceEpsilon) {
1286
1274
  effectiveRatio /= 8;
1287
1275
  }
1288
- // Singletaps are easier to control.
1289
- if (island.deltas.length === 1) {
1276
+ // Repeated island size (ex: triplet -> triplet).
1277
+ // TODO: remove this nerf since its staying here only for balancing purposes because of the flawed ratio calculation
1278
+ if (previousIsland.deltaCount == island.deltaCount) {
1290
1279
  effectiveRatio /= 2;
1291
1280
  }
1292
1281
  let islandFound = false;
@@ -1303,9 +1292,7 @@ class DroidRhythmEvaluator extends RhythmEvaluator {
1303
1292
  }
1304
1293
  // Repeated island (ex: triplet -> triplet).
1305
1294
  // 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))));
1295
+ effectiveRatio *= Math.min(3 / islandCount, Math.pow(1 / islandCount, 2.75 / (1 + Math.exp(14 - 0.24 * island.delta))));
1309
1296
  break;
1310
1297
  }
1311
1298
  if (!islandFound) {
@@ -1323,28 +1310,35 @@ class DroidRhythmEvaluator extends RhythmEvaluator {
1323
1310
  // If we're speeding up, this stays as is and we keep counting island size.
1324
1311
  firstDeltaSwitch = false;
1325
1312
  }
1326
- island = new Island(Math.trunc(currentDelta), deltaDifferenceEpsilon);
1313
+ island = new Island$1(currentDelta, deltaDifferenceEpsilon);
1327
1314
  }
1328
1315
  }
1329
- else if (prevDelta > deltaDifferenceEpsilon + currentDelta) {
1330
- // We're speeding up.
1316
+ else if (prevDelta > currentDelta + deltaDifferenceEpsilon) {
1317
+ // We are speeding up.
1331
1318
  // Begin counting island until we change speed again.
1332
1319
  firstDeltaSwitch = true;
1333
- // Reduce ratio if we're starting after a slider.
1320
+ // BPM change is into slider, this is easy acc window.
1321
+ if (currentObject.object instanceof osuBase.Slider) {
1322
+ effectiveRatio *= 0.6;
1323
+ }
1324
+ // BPM change was from a slider, this is easier typically than circle -> circle
1325
+ // Unintentional side effect is that bursts with kicksliders at the ends might have lower difficulty
1326
+ // than bursts without sliders
1334
1327
  if (prevObject.object instanceof osuBase.Slider) {
1335
- effectiveRatio *= 0.3;
1328
+ effectiveRatio *= 0.6;
1336
1329
  }
1337
1330
  startRatio = effectiveRatio;
1338
- island = new Island(Math.trunc(currentDelta), deltaDifferenceEpsilon);
1331
+ island = new Island$1(currentDelta, deltaDifferenceEpsilon);
1339
1332
  }
1340
1333
  }
1341
- return Math.sqrt(4 + rhythmComplexitySum * this.rhythmMultiplier) / 2;
1334
+ return (Math.sqrt(4 + rhythmComplexitySum * this.rhythmOverallMultiplier) /
1335
+ 2);
1342
1336
  }
1343
1337
  }
1344
- DroidRhythmEvaluator.rhythmMultiplier = 1.2;
1345
- DroidRhythmEvaluator.historyTimeMax = 4000;
1346
- DroidRhythmEvaluator.maxIslandSize = 7;
1347
- DroidRhythmEvaluator.historyObjectsMax = 24;
1338
+ DroidRhythmEvaluator.historyTimeMax = 5000; // 5 seconds of calculateRhythmBonus max.
1339
+ DroidRhythmEvaluator.historyObjectsMax = 32;
1340
+ DroidRhythmEvaluator.rhythmOverallMultiplier = 0.95;
1341
+ DroidRhythmEvaluator.rhythmRatioMultiplier = 12;
1348
1342
 
1349
1343
  /**
1350
1344
  * Represents the skill required to properly follow a beatmap's rhythm.
@@ -1546,9 +1540,8 @@ class DroidDifficultyHitObject extends DifficultyHitObject {
1546
1540
  * @param difficultyHitObjects All difficulty hitobjects in the processed beatmap.
1547
1541
  * @param clockRate The clock rate of the beatmap.
1548
1542
  * @param greatWindow The great window of the hitobject.
1549
- * @param isForceAR Whether force AR is enabled.
1550
1543
  */
1551
- constructor(object, lastObject, lastLastObject, difficultyHitObjects, clockRate, greatWindow, isForceAR) {
1544
+ constructor(object, lastObject, lastLastObject, difficultyHitObjects, clockRate, greatWindow) {
1552
1545
  super(object, lastObject, lastLastObject, difficultyHitObjects, clockRate, greatWindow);
1553
1546
  /**
1554
1547
  * The tap strain generated by the hitobject.
@@ -1592,10 +1585,7 @@ class DroidDifficultyHitObject extends DifficultyHitObject {
1592
1585
  this.radiusBuffThreshold = 70;
1593
1586
  this.mode = osuBase.Modes.droid;
1594
1587
  this.maximumSliderRadius = this.normalizedRadius * 2;
1595
- this.timePreempt = object.timePreempt;
1596
- if (!isForceAR) {
1597
- this.timePreempt /= clockRate;
1598
- }
1588
+ this.timePreempt = object.timePreempt / clockRate;
1599
1589
  }
1600
1590
  computeProperties(clockRate, hitObjects) {
1601
1591
  super.computeProperties(clockRate, hitObjects);
@@ -1607,6 +1597,9 @@ class DroidDifficultyHitObject extends DifficultyHitObject {
1607
1597
  * Keep in mind that "overlapping" in this case is overlapping to the point where both hitobjects
1608
1598
  * can be hit with just a single tap in osu!droid.
1609
1599
  *
1600
+ * In the case of sliders, it is considered overlapping if all nested hitobjects can be hit with
1601
+ * one aim motion.
1602
+ *
1610
1603
  * @param considerDistance Whether to consider the distance between both hitobjects.
1611
1604
  * @returns Whether the hitobject is considered overlapping.
1612
1605
  */
@@ -1614,23 +1607,48 @@ class DroidDifficultyHitObject extends DifficultyHitObject {
1614
1607
  if (this.object instanceof osuBase.Spinner) {
1615
1608
  return false;
1616
1609
  }
1617
- const previous = this.previous(0);
1618
- if (!previous || previous.object instanceof osuBase.Spinner) {
1610
+ const prev = this.previous(0);
1611
+ if (!prev || prev.object instanceof osuBase.Spinner) {
1612
+ return false;
1613
+ }
1614
+ if (this.object.startTime !== prev.object.startTime) {
1619
1615
  return false;
1620
1616
  }
1621
- if (this.deltaTime >= 5) {
1617
+ if (!considerDistance) {
1618
+ return true;
1619
+ }
1620
+ const distanceThreshold = 2 * this.object.radius;
1621
+ const startPosition = this.object.getStackedPosition(osuBase.Modes.droid);
1622
+ const prevStartPosition = prev.object.getStackedPosition(osuBase.Modes.droid);
1623
+ // We need to consider two cases:
1624
+ //
1625
+ // Case 1: Current object is a circle, or previous object is a circle.
1626
+ // In this case, we only need to check if their positions are close enough to be tapped together.
1627
+ //
1628
+ // Case 2: Both objects are sliders.
1629
+ // In this case, we need to check if all nested hitobjects can be hit together.
1630
+ // To start with, check if the starting positions can be tapped together.
1631
+ if (startPosition.getDistance(prevStartPosition) > distanceThreshold) {
1622
1632
  return false;
1623
1633
  }
1624
- if (considerDistance) {
1625
- const endPosition = this.object.getStackedPosition(osuBase.Modes.droid);
1626
- let distance = previous.object
1627
- .getStackedEndPosition(osuBase.Modes.droid)
1628
- .getDistance(endPosition);
1629
- if (previous.object instanceof osuBase.Slider &&
1630
- previous.object.lazyEndPosition) {
1631
- distance = Math.min(distance, previous.object.lazyEndPosition.getDistance(endPosition));
1634
+ if (this.object instanceof osuBase.Circle || prev.object instanceof osuBase.Circle) {
1635
+ return true;
1636
+ }
1637
+ // Check if all nested hitobjects can be hit together.
1638
+ for (let i = 1; i < this.object.nestedHitObjects.length; ++i) {
1639
+ const position = this.object.nestedHitObjects[i].getStackedPosition(osuBase.Modes.droid);
1640
+ const prevPosition = prevStartPosition.add(prev.object.curvePositionAt(i / (this.object.nestedHitObjects.length - 1)));
1641
+ if (position.getDistance(prevPosition) > distanceThreshold) {
1642
+ return false;
1643
+ }
1644
+ }
1645
+ // Do the same for the previous slider as well.
1646
+ for (let i = 1; i < prev.object.nestedHitObjects.length; ++i) {
1647
+ const prevPosition = prev.object.nestedHitObjects[i].getStackedPosition(osuBase.Modes.droid);
1648
+ const position = startPosition.add(this.object.curvePositionAt(i / (prev.object.nestedHitObjects.length - 1)));
1649
+ if (prevPosition.getDistance(position) > distanceThreshold) {
1650
+ return false;
1632
1651
  }
1633
- return distance <= 2 * this.object.radius;
1634
1652
  }
1635
1653
  return true;
1636
1654
  }
@@ -1714,7 +1732,6 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
1714
1732
  speedNoteCount: 0,
1715
1733
  sliderFactor: 0,
1716
1734
  clockRate: 1,
1717
- approachRate: 0,
1718
1735
  overallDifficulty: 0,
1719
1736
  hitCircleCount: 0,
1720
1737
  sliderCount: 0,
@@ -1764,30 +1781,7 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
1764
1781
  return this.attributes.visualDifficulty;
1765
1782
  }
1766
1783
  get cacheableAttributes() {
1767
- return {
1768
- tapDifficulty: this.tap,
1769
- rhythmDifficulty: this.rhythm,
1770
- visualDifficulty: this.visual,
1771
- mods: osuBase.ModUtil.modsToOsuString(this.attributes.mods),
1772
- starRating: this.total,
1773
- maxCombo: this.attributes.maxCombo,
1774
- aimDifficulty: this.aim,
1775
- flashlightDifficulty: this.flashlight,
1776
- speedNoteCount: this.attributes.speedNoteCount,
1777
- sliderFactor: this.attributes.sliderFactor,
1778
- clockRate: this.attributes.clockRate,
1779
- approachRate: this.attributes.approachRate,
1780
- overallDifficulty: this.attributes.overallDifficulty,
1781
- hitCircleCount: this.attributes.hitCircleCount,
1782
- sliderCount: this.attributes.sliderCount,
1783
- spinnerCount: this.attributes.spinnerCount,
1784
- aimDifficultStrainCount: this.attributes.aimDifficultStrainCount,
1785
- tapDifficultStrainCount: this.attributes.tapDifficultStrainCount,
1786
- flashlightDifficultStrainCount: this.attributes.flashlightDifficultStrainCount,
1787
- visualDifficultStrainCount: this.attributes.visualDifficultStrainCount,
1788
- averageSpeedDeltaTime: this.attributes.averageSpeedDeltaTime,
1789
- vibroFactor: this.attributes.vibroFactor,
1790
- };
1784
+ return Object.assign(Object.assign({}, this.attributes), { mods: osuBase.ModUtil.modsToOsuString(this.attributes.mods) });
1791
1785
  }
1792
1786
  /**
1793
1787
  * Calculates the aim star rating of the beatmap and stores it in this instance.
@@ -1896,31 +1890,19 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
1896
1890
  this.visual.toFixed(2) +
1897
1891
  " visual)");
1898
1892
  }
1899
- generateDifficultyHitObjects(convertedBeatmap) {
1893
+ generateDifficultyHitObjects(beatmap, clockRate) {
1900
1894
  var _a, _b;
1901
1895
  const difficultyObjects = [];
1902
- const { objects } = convertedBeatmap.hitObjects;
1903
- const difficultyAdjustMod = this.mods.find((m) => m instanceof osuBase.ModDifficultyAdjust);
1904
- const greatWindow = new osuBase.OsuHitWindow(this.difficultyStatistics.overallDifficulty).hitWindowFor300();
1896
+ const { objects } = beatmap.hitObjects;
1897
+ const isPrecise = this.mods.some((m) => m instanceof osuBase.ModPrecise);
1898
+ const greatWindow = new osuBase.DroidHitWindow(beatmap.difficulty.od).hitWindowFor300(isPrecise) / clockRate;
1905
1899
  for (let i = 0; i < objects.length; ++i) {
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);
1907
- difficultyObject.computeProperties(this.difficultyStatistics.overallSpeedMultiplier, objects);
1900
+ 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, clockRate, greatWindow);
1901
+ difficultyObject.computeProperties(clockRate, objects);
1908
1902
  difficultyObjects.push(difficultyObject);
1909
1903
  }
1910
1904
  return difficultyObjects;
1911
1905
  }
1912
- computeDifficultyStatistics(options) {
1913
- const { difficulty } = this.beatmap;
1914
- return osuBase.calculateDroidDifficultyStatistics({
1915
- circleSize: difficulty.cs,
1916
- approachRate: difficulty.ar,
1917
- overallDifficulty: difficulty.od,
1918
- healthDrain: difficulty.hp,
1919
- mods: this.mods,
1920
- customSpeedMultiplier: options === null || options === void 0 ? void 0 : options.customSpeedMultiplier,
1921
- oldStatistics: options === null || options === void 0 ? void 0 : options.oldStatistics,
1922
- });
1923
- }
1924
1906
  createSkills() {
1925
1907
  return [
1926
1908
  new DroidAim(this.mods, true),
@@ -2149,10 +2131,6 @@ class PerformanceCalculator {
2149
2131
  * The calculated accuracy.
2150
2132
  */
2151
2133
  this.computedAccuracy = new osuBase.Accuracy({});
2152
- /**
2153
- * Penalty for combo breaks.
2154
- */
2155
- this.comboPenalty = 0;
2156
2134
  /**
2157
2135
  * The amount of misses that are filtered out from sliderbreaks.
2158
2136
  */
@@ -2212,7 +2190,6 @@ class PerformanceCalculator {
2212
2190
  const maxCombo = this.difficultyAttributes.maxCombo;
2213
2191
  const miss = this.computedAccuracy.nmiss;
2214
2192
  const combo = (_a = options === null || options === void 0 ? void 0 : options.combo) !== null && _a !== void 0 ? _a : maxCombo - miss;
2215
- this.comboPenalty = Math.min(Math.pow(combo / maxCombo, 0.8), 1);
2216
2193
  if ((options === null || options === void 0 ? void 0 : options.accPercent) instanceof osuBase.Accuracy) {
2217
2194
  // Copy into new instance to not modify the original
2218
2195
  this.computedAccuracy = new osuBase.Accuracy(options.accPercent);
@@ -2275,6 +2252,22 @@ class PerformanceCalculator {
2275
2252
  this.difficultyAttributes.sliderFactor;
2276
2253
  }
2277
2254
  }
2255
+ /**
2256
+ * Calculates a strain-based miss penalty.
2257
+ *
2258
+ * Strain-based miss penalty assumes that a player will miss on the hardest parts of a map,
2259
+ * so we use the amount of relatively difficult sections to adjust miss penalty
2260
+ * to make it more punishing on maps with lower amount of hard sections.
2261
+ */
2262
+ calculateStrainBasedMissPenalty(difficultStrainCount) {
2263
+ if (this.effectiveMissCount === 0) {
2264
+ return 1;
2265
+ }
2266
+ return (0.96 /
2267
+ (this.effectiveMissCount /
2268
+ (4 * Math.pow(Math.log(difficultStrainCount), 0.94)) +
2269
+ 1));
2270
+ }
2278
2271
  /**
2279
2272
  * Calculates the amount of misses + sliderbreaks from combo.
2280
2273
  */
@@ -2618,22 +2611,6 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2618
2611
  visualValue *= 0.98 + Math.pow(5, 2) / 2500;
2619
2612
  return visualValue;
2620
2613
  }
2621
- /**
2622
- * Calculates a strain-based miss penalty.
2623
- *
2624
- * Strain-based miss penalty assumes that a player will miss on the hardest parts of a map,
2625
- * so we use the amount of relatively difficult sections to adjust miss penalty
2626
- * to make it more punishing on maps with lower amount of hard sections.
2627
- */
2628
- calculateStrainBasedMissPenalty(difficultStrainCount) {
2629
- if (this.effectiveMissCount === 0) {
2630
- return 1;
2631
- }
2632
- return (0.96 /
2633
- (this.effectiveMissCount /
2634
- (4 * Math.pow(Math.log(difficultStrainCount), 0.94)) +
2635
- 1));
2636
- }
2637
2614
  /**
2638
2615
  * The object-based proportional miss penalty.
2639
2616
  */
@@ -2844,13 +2821,6 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2844
2821
  * and to calculate a final difficulty value representing the difficulty of hitting all the processed objects.
2845
2822
  */
2846
2823
  class OsuSkill extends StrainSkill {
2847
- constructor() {
2848
- super(...arguments);
2849
- /**
2850
- * The final multiplier to be applied to the final difficulty value after all other calculations.
2851
- */
2852
- this.difficultyMultiplier = OsuSkill.defaultDifficultyMultiplier;
2853
- }
2854
2824
  difficultyValue() {
2855
2825
  const strains = this.strainPeaks
2856
2826
  .slice()
@@ -2865,25 +2835,19 @@ class OsuSkill extends StrainSkill {
2865
2835
  }
2866
2836
  // Difficulty is the weighted sum of the highest strains from every section.
2867
2837
  // We're sorting from highest to lowest strain.
2868
- let difficulty = 0;
2838
+ this.difficulty = 0;
2869
2839
  let weight = 1;
2870
2840
  for (const strain of strains) {
2871
2841
  const addition = strain * weight;
2872
- if (difficulty + addition === difficulty) {
2842
+ if (this.difficulty + addition === this.difficulty) {
2873
2843
  break;
2874
2844
  }
2875
- difficulty += addition;
2845
+ this.difficulty += addition;
2876
2846
  weight *= this.decayWeight;
2877
2847
  }
2878
- return difficulty * this.difficultyMultiplier;
2848
+ return this.difficulty;
2879
2849
  }
2880
2850
  }
2881
- /**
2882
- * The default multiplier applied to the final difficulty value after all other calculations.
2883
- *
2884
- * May be overridden via {@link difficultyMultiplier}.
2885
- */
2886
- OsuSkill.defaultDifficultyMultiplier = 1.06;
2887
2851
 
2888
2852
  /**
2889
2853
  * An evaluator for calculating osu!standard Aim skill.
@@ -3018,7 +2982,7 @@ class OsuAim extends OsuSkill {
3018
2982
  this.reducedSectionBaseline = 0.75;
3019
2983
  this.decayWeight = 0.9;
3020
2984
  this.currentAimStrain = 0;
3021
- this.skillMultiplier = 23.55;
2985
+ this.skillMultiplier = 25.18;
3022
2986
  this.withSliders = withSliders;
3023
2987
  }
3024
2988
  strainValueAt(current) {
@@ -3026,6 +2990,7 @@ class OsuAim extends OsuSkill {
3026
2990
  this.currentAimStrain +=
3027
2991
  OsuAimEvaluator.evaluateDifficultyOf(current, this.withSliders) *
3028
2992
  this.skillMultiplier;
2993
+ this._objectStrains.push(this.currentAimStrain);
3029
2994
  return this.currentAimStrain;
3030
2995
  }
3031
2996
  calculateInitialStrain(time, current) {
@@ -3071,29 +3036,65 @@ class OsuSpeedEvaluator extends SpeedEvaluator {
3071
3036
  // Cap deltatime to the OD 300 hitwindow.
3072
3037
  // 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.
3073
3038
  strainTime /= osuBase.MathUtils.clamp(strainTime / current.fullGreatWindow / 0.93, 0.92, 1);
3074
- let speedBonus = 1;
3039
+ // speedBonus will be 0.0 for BPM < 200
3040
+ let speedBonus = 0;
3041
+ // Add additional scaling bonus for streams/bursts higher than 200bpm
3075
3042
  if (strainTime < this.minSpeedBonus) {
3076
- speedBonus +=
3043
+ speedBonus =
3077
3044
  0.75 * Math.pow((this.minSpeedBonus - strainTime) / 40, 2);
3078
3045
  }
3079
3046
  const travelDistance = (_a = prev === null || prev === void 0 ? void 0 : prev.travelDistance) !== null && _a !== void 0 ? _a : 0;
3047
+ // Cap distance at spacing threshold
3080
3048
  const distance = Math.min(this.SINGLE_SPACING_THRESHOLD, travelDistance + current.minimumJumpDistance);
3081
- return (((speedBonus +
3082
- speedBonus *
3083
- Math.pow(distance / this.SINGLE_SPACING_THRESHOLD, 3.5)) *
3084
- doubletapness) /
3085
- strainTime);
3049
+ // Max distance bonus is 1 * `distance_multiplier` at single_spacing_threshold
3050
+ const distanceBonus = Math.pow(distance / this.SINGLE_SPACING_THRESHOLD, 3.95) *
3051
+ this.DISTANCE_MULTIPLIER;
3052
+ // Base difficulty with all bonuses
3053
+ const difficulty = ((1 + speedBonus + distanceBonus) * 1000) / strainTime;
3054
+ // Apply penalty if there's doubletappable doubles
3055
+ return difficulty * doubletapness;
3086
3056
  }
3087
3057
  }
3088
3058
  /**
3089
3059
  * Spacing threshold for a single hitobject spacing.
3060
+ *
3061
+ * About 1.25 circles distance between hitobject centers.
3090
3062
  */
3091
3063
  OsuSpeedEvaluator.SINGLE_SPACING_THRESHOLD = 125;
3064
+ OsuSpeedEvaluator.DISTANCE_MULTIPLIER = 0.94;
3092
3065
 
3066
+ class Island {
3067
+ constructor(delta, deltaDifferenceEpsilon) {
3068
+ this.delta = Number.MAX_SAFE_INTEGER;
3069
+ this.deltaCount = 0;
3070
+ if (deltaDifferenceEpsilon === undefined) {
3071
+ this.deltaDifferenceEpsilon = delta;
3072
+ }
3073
+ else {
3074
+ this.deltaDifferenceEpsilon = deltaDifferenceEpsilon;
3075
+ this.addDelta(delta);
3076
+ }
3077
+ }
3078
+ addDelta(delta) {
3079
+ if (this.delta === Number.MAX_SAFE_INTEGER) {
3080
+ this.delta = Math.max(Math.trunc(delta), DifficultyHitObject.minDeltaTime);
3081
+ }
3082
+ ++this.deltaCount;
3083
+ }
3084
+ isSimilarPolarity(other) {
3085
+ // TODO: consider islands to be of similar polarity only if they're having the same average delta (we don't want to consider 3 singletaps similar to a triple)
3086
+ // naively adding delta check here breaks _a lot_ of maps because of the flawed ratio calculation
3087
+ return this.deltaCount % 2 == other.deltaCount % 2;
3088
+ }
3089
+ equals(other) {
3090
+ return (Math.abs(this.delta - other.delta) < this.deltaDifferenceEpsilon &&
3091
+ this.deltaCount === other.deltaCount);
3092
+ }
3093
+ }
3093
3094
  /**
3094
3095
  * An evaluator for calculating osu!standard Rhythm skill.
3095
3096
  */
3096
- class OsuRhythmEvaluator extends RhythmEvaluator {
3097
+ class OsuRhythmEvaluator {
3097
3098
  /**
3098
3099
  * Calculates a rhythm multiplier for the difficulty of the tap associated
3099
3100
  * with historic data of the current object.
@@ -3104,14 +3105,16 @@ class OsuRhythmEvaluator extends RhythmEvaluator {
3104
3105
  if (current.object instanceof osuBase.Spinner) {
3105
3106
  return 0;
3106
3107
  }
3107
- let previousIslandSize = 0;
3108
+ const deltaDifferenceEpsilon = current.fullGreatWindow * 0.3;
3108
3109
  let rhythmComplexitySum = 0;
3109
- let islandSize = 1;
3110
+ let island = new Island(deltaDifferenceEpsilon);
3111
+ let previousIsland = new Island(deltaDifferenceEpsilon);
3112
+ const islandCounts = new Map();
3110
3113
  // Store the ratio of the current start of an island to buff for tighter rhythms.
3111
3114
  let startRatio = 0;
3112
3115
  let firstDeltaSwitch = false;
3113
- const historicalNoteCount = Math.min(current.index, 32);
3114
3116
  let rhythmStart = 0;
3117
+ const historicalNoteCount = Math.min(current.index, this.historyObjectsMax);
3115
3118
  while (rhythmStart < historicalNoteCount - 2 &&
3116
3119
  current.startTime - current.previous(rhythmStart).startTime <
3117
3120
  this.historyTimeMax) {
@@ -3122,82 +3125,119 @@ class OsuRhythmEvaluator extends RhythmEvaluator {
3122
3125
  const prevObject = current.previous(i);
3123
3126
  const lastObject = current.previous(i + 1);
3124
3127
  // Scale note 0 to 1 from history to now.
3125
- let currentHistoricalDecay = (this.historyTimeMax -
3128
+ const timeDecay = (this.historyTimeMax -
3126
3129
  (current.startTime - currentObject.startTime)) /
3127
3130
  this.historyTimeMax;
3131
+ const noteDecay = (historicalNoteCount - i) / historicalNoteCount;
3128
3132
  // Either we're limited by time or limited by object count.
3129
- currentHistoricalDecay = Math.min(currentHistoricalDecay, (historicalNoteCount - i) / historicalNoteCount);
3133
+ const currentHistoricalDecay = Math.min(timeDecay, noteDecay);
3130
3134
  const currentDelta = currentObject.strainTime;
3131
3135
  const prevDelta = prevObject.strainTime;
3132
3136
  const lastDelta = lastObject.strainTime;
3137
+ // Calculate how much current delta difference deserves a rhythm bonus
3138
+ // This function is meant to reduce rhythm bonus for deltas that are multiples of each other (i.e. 100 and 200)
3139
+ const deltaDifferenceRatio = Math.min(prevDelta, currentDelta) /
3140
+ Math.max(prevDelta, currentDelta);
3133
3141
  const currentRatio = 1 +
3134
- 6 *
3135
- Math.min(0.5, Math.pow(Math.sin(Math.PI /
3136
- (Math.min(prevDelta, currentDelta) /
3137
- Math.max(prevDelta, currentDelta))), 2));
3138
- const windowPenalty = Math.min(1, Math.max(0, Math.abs(prevDelta - currentDelta) -
3139
- current.fullGreatWindow * 0.3) /
3140
- (current.fullGreatWindow * 0.3));
3141
- let effectiveRatio = windowPenalty * currentRatio;
3142
+ this.rhythmRatioMultiplier *
3143
+ Math.min(0.5, Math.pow(Math.sin(Math.PI / deltaDifferenceRatio), 2));
3144
+ // Reduce ratio bonus if delta difference is too big
3145
+ const fraction = Math.max(prevDelta / currentDelta, currentDelta / prevDelta);
3146
+ const fractionMultiplier = osuBase.MathUtils.clamp(2 - fraction / 8, 0, 1);
3147
+ const windowPenalty = Math.min(1, Math.max(0, Math.abs(prevDelta - currentDelta) - deltaDifferenceEpsilon) / deltaDifferenceEpsilon);
3148
+ let effectiveRatio = windowPenalty * currentRatio * fractionMultiplier;
3142
3149
  if (firstDeltaSwitch) {
3143
- if (prevDelta <= 1.25 * currentDelta &&
3144
- prevDelta * 1.25 >= currentDelta) {
3150
+ if (Math.abs(prevDelta - currentDelta) < deltaDifferenceEpsilon) {
3145
3151
  // Island is still progressing, count size.
3146
- if (islandSize < 7) {
3147
- ++islandSize;
3148
- }
3152
+ island.addDelta(currentDelta);
3149
3153
  }
3150
3154
  else {
3155
+ // BPM change is into slider, this is easy acc window.
3151
3156
  if (currentObject.object instanceof osuBase.Slider) {
3152
- // BPM change is into slider, this is easy acc window.
3153
3157
  effectiveRatio /= 8;
3154
3158
  }
3159
+ // BPM change was from a slider, this is easier typically than circle -> circle.
3160
+ // Unintentional side effect is that bursts with kicksliders at the ends might have lower difficulty
3161
+ // than bursts without sliders.
3155
3162
  if (prevObject.object instanceof osuBase.Slider) {
3156
- // BPM change was from a slider, this is typically easier than circle -> circle.
3157
- effectiveRatio /= 4;
3158
- }
3159
- if (previousIslandSize === islandSize) {
3160
- // Repeated island size (ex: triplet -> triplet).
3161
- effectiveRatio /= 4;
3163
+ effectiveRatio *= 0.3;
3162
3164
  }
3163
- if (previousIslandSize % 2 === islandSize % 2) {
3164
- // Repeated island polarity (2 -> 4, 3 -> 5).
3165
+ // Repeated island polarity (2 -> 4, 3 -> 5).
3166
+ if (island.isSimilarPolarity(previousIsland)) {
3165
3167
  effectiveRatio /= 2;
3166
3168
  }
3167
- if (lastDelta > prevDelta + 10 &&
3168
- prevDelta > currentDelta + 10) {
3169
- // Previous increase happened a note ago.
3170
- // Albeit this is a 1/1 -> 1/2-1/4 type of transition, we don't want to buff this.
3169
+ // Previous increase happened a note ago.
3170
+ // Albeit this is a 1/1 -> 1/2-1/4 type of transition, we don't want to buff this.
3171
+ if (lastDelta > prevDelta + deltaDifferenceEpsilon &&
3172
+ prevDelta > currentDelta + deltaDifferenceEpsilon) {
3171
3173
  effectiveRatio /= 8;
3172
3174
  }
3175
+ // Repeated island size (ex: triplet -> triplet).
3176
+ // TODO: remove this nerf since its staying here only for balancing purposes because of the flawed ratio calculation
3177
+ if (previousIsland.deltaCount == island.deltaCount) {
3178
+ effectiveRatio /= 2;
3179
+ }
3180
+ let islandFound = false;
3181
+ for (const [currentIsland, count] of islandCounts) {
3182
+ if (!island.equals(currentIsland)) {
3183
+ continue;
3184
+ }
3185
+ islandFound = true;
3186
+ let islandCount = count;
3187
+ if (previousIsland.equals(island)) {
3188
+ // Only add island to island counts if they're going one after another.
3189
+ ++islandCount;
3190
+ islandCounts.set(currentIsland, islandCount);
3191
+ }
3192
+ // Repeated island (ex: triplet -> triplet).
3193
+ // Graph: https://www.desmos.com/calculator/pj7an56zwf
3194
+ effectiveRatio *= Math.min(3 / islandCount, Math.pow(1 / islandCount, 2.75 / (1 + Math.exp(14 - 0.24 * island.delta))));
3195
+ break;
3196
+ }
3197
+ if (!islandFound) {
3198
+ islandCounts.set(island, 1);
3199
+ }
3200
+ // Scale down the difficulty if the object is doubletappable.
3201
+ effectiveRatio *= 1 - prevObject.doubletapness * 0.75;
3173
3202
  rhythmComplexitySum +=
3174
- (((Math.sqrt(effectiveRatio * startRatio) *
3175
- currentHistoricalDecay *
3176
- Math.sqrt(4 + islandSize)) /
3177
- 2) *
3178
- Math.sqrt(4 + previousIslandSize)) /
3179
- 2;
3203
+ Math.sqrt(effectiveRatio * startRatio) *
3204
+ currentHistoricalDecay;
3180
3205
  startRatio = effectiveRatio;
3181
- previousIslandSize = islandSize;
3182
- if (prevDelta * 1.25 < currentDelta) {
3206
+ previousIsland = island;
3207
+ if (prevDelta + deltaDifferenceEpsilon < currentDelta) {
3183
3208
  // We're slowing down, stop counting.
3184
3209
  // If we're speeding up, this stays as is and we keep counting island size.
3185
3210
  firstDeltaSwitch = false;
3186
3211
  }
3187
- islandSize = 1;
3212
+ island = new Island(currentDelta, deltaDifferenceEpsilon);
3188
3213
  }
3189
3214
  }
3190
- else if (prevDelta > 1.25 * currentDelta) {
3191
- // We want to be speeding up.
3215
+ else if (prevDelta > currentDelta + deltaDifferenceEpsilon) {
3216
+ // We are speeding up.
3192
3217
  // Begin counting island until we change speed again.
3193
3218
  firstDeltaSwitch = true;
3219
+ // BPM change is into slider, this is easy acc window.
3220
+ if (currentObject.object instanceof osuBase.Slider) {
3221
+ effectiveRatio *= 0.6;
3222
+ }
3223
+ // BPM change was from a slider, this is easier typically than circle -> circle
3224
+ // Unintentional side effect is that bursts with kicksliders at the ends might have lower difficulty
3225
+ // than bursts without sliders
3226
+ if (prevObject.object instanceof osuBase.Slider) {
3227
+ effectiveRatio *= 0.6;
3228
+ }
3194
3229
  startRatio = effectiveRatio;
3195
- islandSize = 1;
3230
+ island = new Island(currentDelta, deltaDifferenceEpsilon);
3196
3231
  }
3197
3232
  }
3198
- return Math.sqrt(4 + rhythmComplexitySum * this.rhythmMultiplier) / 2;
3233
+ return (Math.sqrt(4 + rhythmComplexitySum * this.rhythmOverallMultiplier) /
3234
+ 2);
3199
3235
  }
3200
3236
  }
3237
+ OsuRhythmEvaluator.historyTimeMax = 5000; // 5 seconds of calculateRhythmBonus max.
3238
+ OsuRhythmEvaluator.historyObjectsMax = 32;
3239
+ OsuRhythmEvaluator.rhythmOverallMultiplier = 0.95;
3240
+ OsuRhythmEvaluator.rhythmRatioMultiplier = 12;
3201
3241
 
3202
3242
  /**
3203
3243
  * Represents the skill required to press keys or tap with regards to keeping up with the speed at which objects need to be hit.
@@ -3208,11 +3248,10 @@ class OsuSpeed extends OsuSkill {
3208
3248
  this.strainDecayBase = 0.3;
3209
3249
  this.reducedSectionCount = 5;
3210
3250
  this.reducedSectionBaseline = 0.75;
3211
- this.difficultyMultiplier = 1.04;
3212
3251
  this.decayWeight = 0.9;
3213
3252
  this.currentSpeedStrain = 0;
3214
3253
  this.currentRhythm = 0;
3215
- this.skillMultiplier = 1375;
3254
+ this.skillMultiplier = 1.43;
3216
3255
  }
3217
3256
  /**
3218
3257
  * @param current The hitobject to calculate.
@@ -3223,7 +3262,9 @@ class OsuSpeed extends OsuSkill {
3223
3262
  OsuSpeedEvaluator.evaluateDifficultyOf(current) *
3224
3263
  this.skillMultiplier;
3225
3264
  this.currentRhythm = OsuRhythmEvaluator.evaluateDifficultyOf(current);
3226
- return this.currentSpeedStrain * this.currentRhythm;
3265
+ const strain = this.currentSpeedStrain * this.currentRhythm;
3266
+ this._objectStrains.push(strain);
3267
+ return strain;
3227
3268
  }
3228
3269
  calculateInitialStrain(time, current) {
3229
3270
  var _a, _b;
@@ -3333,9 +3374,12 @@ class OsuFlashlight extends OsuSkill {
3333
3374
  this.reducedSectionBaseline = 1;
3334
3375
  this.decayWeight = 1;
3335
3376
  this.currentFlashlightStrain = 0;
3336
- this.skillMultiplier = 0.052;
3377
+ this.skillMultiplier = 0.05512;
3337
3378
  this.isHidden = mods.some((m) => m instanceof osuBase.ModHidden);
3338
3379
  }
3380
+ difficultyValue() {
3381
+ return this.strainPeaks.reduce((a, b) => a + b, 0);
3382
+ }
3339
3383
  strainValueAt(current) {
3340
3384
  this.currentFlashlightStrain *= this.strainDecay(current.deltaTime);
3341
3385
  this.currentFlashlightStrain +=
@@ -3403,6 +3447,8 @@ class OsuDifficultyCalculator extends DifficultyCalculator {
3403
3447
  hitCircleCount: 0,
3404
3448
  sliderCount: 0,
3405
3449
  spinnerCount: 0,
3450
+ aimDifficultStrainCount: 0,
3451
+ speedDifficultStrainCount: 0,
3406
3452
  };
3407
3453
  this.difficultyMultiplier = 0.0675;
3408
3454
  this.mode = osuBase.Modes.osu;
@@ -3441,6 +3487,10 @@ class OsuDifficultyCalculator extends DifficultyCalculator {
3441
3487
  * Calculates the speed star rating of the beatmap and stores it in this instance.
3442
3488
  */
3443
3489
  calculateSpeed() {
3490
+ if (this.mods.some((m) => m instanceof osuBase.ModRelax)) {
3491
+ this.attributes.speedDifficulty = 0;
3492
+ return;
3493
+ }
3444
3494
  const speedSkill = new OsuSpeed(this.mods);
3445
3495
  this.calculateSkills(speedSkill);
3446
3496
  this.postCalculateSpeed(speedSkill);
@@ -3467,7 +3517,7 @@ class OsuDifficultyCalculator extends DifficultyCalculator {
3467
3517
  // Document for formula derivation:
3468
3518
  // https://docs.google.com/document/d/10DZGYYSsT_yjz2Mtp6yIJld0Rqx4E-vVHupCqiM4TNI/edit
3469
3519
  this.attributes.starRating =
3470
- Math.cbrt(1.14) *
3520
+ Math.cbrt(1.15) *
3471
3521
  0.027 *
3472
3522
  (Math.cbrt((100000 / Math.pow(2, 1 / 1.1)) * basePerformanceValue) +
3473
3523
  4);
@@ -3478,13 +3528,19 @@ class OsuDifficultyCalculator extends DifficultyCalculator {
3478
3528
  }
3479
3529
  calculateAll() {
3480
3530
  const skills = this.createSkills();
3531
+ const isRelax = this.mods.some((m) => m instanceof osuBase.ModRelax);
3481
3532
  this.calculateSkills(...skills);
3482
3533
  const aimSkill = skills[0];
3483
3534
  const aimSkillWithoutSliders = skills[1];
3484
3535
  const speedSkill = skills[2];
3485
3536
  const flashlightSkill = skills[3];
3486
3537
  this.postCalculateAim(aimSkill, aimSkillWithoutSliders);
3487
- this.postCalculateSpeed(speedSkill);
3538
+ if (isRelax) {
3539
+ this.attributes.speedDifficulty = 0;
3540
+ }
3541
+ else {
3542
+ this.postCalculateSpeed(speedSkill);
3543
+ }
3488
3544
  this.calculateSpeedAttributes();
3489
3545
  this.postCalculateFlashlight(flashlightSkill);
3490
3546
  this.calculateTotal();
@@ -3499,29 +3555,19 @@ class OsuDifficultyCalculator extends DifficultyCalculator {
3499
3555
  this.flashlight.toFixed(2) +
3500
3556
  " flashlight)");
3501
3557
  }
3502
- generateDifficultyHitObjects(convertedBeatmap) {
3558
+ generateDifficultyHitObjects(beatmap, clockRate) {
3503
3559
  var _a, _b;
3504
3560
  const difficultyObjects = [];
3505
- const { objects } = convertedBeatmap.hitObjects;
3506
- const greatWindow = new osuBase.OsuHitWindow(this.difficultyStatistics.overallDifficulty).hitWindowFor300();
3561
+ const { objects } = beatmap.hitObjects;
3562
+ const greatWindow = new osuBase.OsuHitWindow(beatmap.difficulty.od).hitWindowFor300() /
3563
+ clockRate;
3507
3564
  for (let i = 0; i < objects.length; ++i) {
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);
3509
- difficultyObject.computeProperties(this.difficultyStatistics.overallSpeedMultiplier, objects);
3565
+ 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, clockRate, greatWindow);
3566
+ difficultyObject.computeProperties(clockRate, objects);
3510
3567
  difficultyObjects.push(difficultyObject);
3511
3568
  }
3512
3569
  return difficultyObjects;
3513
3570
  }
3514
- computeDifficultyStatistics(options) {
3515
- const { difficulty } = this.beatmap;
3516
- return osuBase.calculateOsuDifficultyStatistics({
3517
- circleSize: difficulty.cs,
3518
- approachRate: difficulty.ar,
3519
- overallDifficulty: difficulty.od,
3520
- healthDrain: difficulty.hp,
3521
- mods: options === null || options === void 0 ? void 0 : options.mods,
3522
- customSpeedMultiplier: options === null || options === void 0 ? void 0 : options.customSpeedMultiplier,
3523
- });
3524
- }
3525
3571
  createSkills() {
3526
3572
  return [
3527
3573
  new OsuAim(this.mods, true),
@@ -3530,6 +3576,11 @@ class OsuDifficultyCalculator extends DifficultyCalculator {
3530
3576
  new OsuFlashlight(this.mods),
3531
3577
  ];
3532
3578
  }
3579
+ populateDifficultyAttributes(beatmap, clockRate) {
3580
+ super.populateDifficultyAttributes(beatmap, clockRate);
3581
+ const preempt = osuBase.BeatmapDifficulty.difficultyRange(beatmap.difficulty.ar, osuBase.HitObject.preemptMax, osuBase.HitObject.preemptMid, osuBase.HitObject.preemptMin) / clockRate;
3582
+ this.attributes.approachRate = osuBase.BeatmapDifficulty.inverseDifficultyRange(preempt, osuBase.HitObject.preemptMax, osuBase.HitObject.preemptMid, osuBase.HitObject.preemptMin);
3583
+ }
3533
3584
  /**
3534
3585
  * Called after aim skill calculation.
3535
3586
  *
@@ -3551,6 +3602,8 @@ class OsuDifficultyCalculator extends DifficultyCalculator {
3551
3602
  if (this.mods.some((m) => m instanceof osuBase.ModRelax)) {
3552
3603
  this.attributes.aimDifficulty *= 0.9;
3553
3604
  }
3605
+ this.attributes.aimDifficultStrainCount =
3606
+ aimSkill.countDifficultStrains();
3554
3607
  }
3555
3608
  /**
3556
3609
  * Called after speed skill calculation.
@@ -3559,10 +3612,9 @@ class OsuDifficultyCalculator extends DifficultyCalculator {
3559
3612
  */
3560
3613
  postCalculateSpeed(speedSkill) {
3561
3614
  this.strainPeaks.speed = speedSkill.strainPeaks;
3562
- this.attributes.speedDifficulty = this.mods.some((m) => m instanceof osuBase.ModRelax)
3563
- ? 0
3564
- : this.starValue(speedSkill.difficultyValue());
3565
- this.calculateSpeedAttributes();
3615
+ this.attributes.speedDifficulty = this.starValue(speedSkill.difficultyValue());
3616
+ this.attributes.speedDifficultStrainCount =
3617
+ speedSkill.countDifficultStrains();
3566
3618
  }
3567
3619
  /**
3568
3620
  * Calculates speed-related attributes.
@@ -3613,8 +3665,9 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
3613
3665
  * The flashlight performance value.
3614
3666
  */
3615
3667
  this.flashlight = 0;
3616
- this.finalMultiplier = 1.14;
3668
+ this.finalMultiplier = 1.15;
3617
3669
  this.mode = osuBase.Modes.osu;
3670
+ this.comboPenalty = 1;
3618
3671
  }
3619
3672
  calculateValues() {
3620
3673
  this.aim = this.calculateAimValue();
@@ -3628,6 +3681,14 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
3628
3681
  Math.pow(this.accuracy, 1.1) +
3629
3682
  Math.pow(this.flashlight, 1.1), 1 / 1.1) * this.finalMultiplier);
3630
3683
  }
3684
+ handleOptions(options) {
3685
+ var _a;
3686
+ super.handleOptions(options);
3687
+ const maxCombo = this.difficultyAttributes.maxCombo;
3688
+ const miss = this.computedAccuracy.nmiss;
3689
+ const combo = (_a = options === null || options === void 0 ? void 0 : options.combo) !== null && _a !== void 0 ? _a : maxCombo - miss;
3690
+ this.comboPenalty = Math.min(Math.pow(combo / maxCombo, 0.8), 1);
3691
+ }
3631
3692
  /**
3632
3693
  * Calculates the aim performance value of the beatmap.
3633
3694
  */
@@ -3647,8 +3708,7 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
3647
3708
  Math.pow(1 -
3648
3709
  Math.pow(this.effectiveMissCount / this.totalHits, 0.775), this.effectiveMissCount);
3649
3710
  }
3650
- // Combo scaling
3651
- aimValue *= this.comboPenalty;
3711
+ aimValue *= this.calculateStrainBasedMissPenalty(this.difficultyAttributes.aimDifficultStrainCount);
3652
3712
  const calculatedAR = this.difficultyAttributes.approachRate;
3653
3713
  if (!this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModRelax)) {
3654
3714
  // AR scaling
@@ -3689,16 +3749,7 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
3689
3749
  lengthBonus += Math.log10(this.totalHits / 2000) * 0.5;
3690
3750
  }
3691
3751
  speedValue *= lengthBonus;
3692
- if (this.effectiveMissCount > 0) {
3693
- // Penalize misses by assessing # of misses relative to the total # of objects.
3694
- // Default a 3% reduction for any # of misses.
3695
- speedValue *=
3696
- 0.97 *
3697
- Math.pow(1 -
3698
- Math.pow(this.effectiveMissCount / this.totalHits, 0.775), Math.pow(this.effectiveMissCount, 0.875));
3699
- }
3700
- // Combo scaling
3701
- speedValue *= this.comboPenalty;
3752
+ speedValue *= this.calculateStrainBasedMissPenalty(this.difficultyAttributes.speedDifficultStrainCount);
3702
3753
  // AR scaling
3703
3754
  const calculatedAR = this.difficultyAttributes.approachRate;
3704
3755
  if (calculatedAR > 10.33) {
@@ -3729,9 +3780,7 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
3729
3780
  750) *
3730
3781
  Math.pow((this.computedAccuracy.value() +
3731
3782
  relevantAccuracy.value(this.difficultyAttributes.speedNoteCount)) /
3732
- 2, (14.5 -
3733
- Math.max(this.difficultyAttributes.overallDifficulty, 8)) /
3734
- 2);
3783
+ 2, (14.5 - this.difficultyAttributes.overallDifficulty) / 2);
3735
3784
  // Scale the speed value with # of 50s to punish doubletapping.
3736
3785
  speedValue *= Math.pow(0.99, Math.max(0, this.computedAccuracy.n50 - this.totalHits / 500));
3737
3786
  return speedValue;
@@ -3839,6 +3888,5 @@ exports.OsuRhythmEvaluator = OsuRhythmEvaluator;
3839
3888
  exports.OsuSpeed = OsuSpeed;
3840
3889
  exports.OsuSpeedEvaluator = OsuSpeedEvaluator;
3841
3890
  exports.PerformanceCalculator = PerformanceCalculator;
3842
- exports.RhythmEvaluator = RhythmEvaluator;
3843
3891
  exports.SpeedEvaluator = SpeedEvaluator;
3844
3892
  //# sourceMappingURL=index.js.map