@rian8337/osu-rebalance-difficulty-calculator 4.0.0-beta.15 → 4.0.0-beta.16
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 +890 -857
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/typings/index.d.ts +292 -287
package/dist/index.js
CHANGED
|
@@ -29,31 +29,143 @@ class AimEvaluator {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
32
|
+
* The base of a difficulty calculator.
|
|
33
33
|
*/
|
|
34
|
-
class
|
|
34
|
+
class DifficultyCalculator {
|
|
35
35
|
/**
|
|
36
|
-
* The
|
|
36
|
+
* The calculated beatmap.
|
|
37
37
|
*/
|
|
38
|
-
|
|
38
|
+
beatmap;
|
|
39
39
|
/**
|
|
40
|
-
* The
|
|
40
|
+
* The difficulty objects of the beatmap.
|
|
41
|
+
*/
|
|
42
|
+
objects = [];
|
|
43
|
+
/**
|
|
44
|
+
* The modifications applied.
|
|
45
|
+
*/
|
|
46
|
+
mods = [];
|
|
47
|
+
/**
|
|
48
|
+
* The total star rating of the beatmap.
|
|
49
|
+
*/
|
|
50
|
+
get total() {
|
|
51
|
+
return this.attributes.starRating;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The difficulty statistics of the beatmap after modifications are applied.
|
|
55
|
+
*/
|
|
56
|
+
difficultyStatistics;
|
|
57
|
+
/**
|
|
58
|
+
* The strain peaks of various calculated difficulties.
|
|
59
|
+
*/
|
|
60
|
+
strainPeaks = {
|
|
61
|
+
aimWithSliders: [],
|
|
62
|
+
aimWithoutSliders: [],
|
|
63
|
+
speed: [],
|
|
64
|
+
flashlight: [],
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Constructs a new instance of the calculator.
|
|
41
68
|
*
|
|
42
|
-
*
|
|
69
|
+
* @param beatmap The beatmap to calculate. This beatmap will be deep-cloned to prevent reference changes.
|
|
43
70
|
*/
|
|
44
|
-
|
|
71
|
+
constructor(beatmap) {
|
|
72
|
+
this.beatmap = beatmap;
|
|
73
|
+
this.difficultyStatistics = {
|
|
74
|
+
circleSize: beatmap.difficulty.cs,
|
|
75
|
+
approachRate: beatmap.difficulty.ar ?? beatmap.difficulty.od,
|
|
76
|
+
overallDifficulty: beatmap.difficulty.od,
|
|
77
|
+
healthDrain: beatmap.difficulty.hp,
|
|
78
|
+
overallSpeedMultiplier: 1,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
45
81
|
/**
|
|
46
|
-
*
|
|
82
|
+
* Calculates the star rating of the specified beatmap.
|
|
83
|
+
*
|
|
84
|
+
* The beatmap is analyzed in chunks of `sectionLength` duration.
|
|
85
|
+
* For each chunk the highest hitobject strains are added to
|
|
86
|
+
* a list which is then collapsed into a weighted sum, much
|
|
87
|
+
* like scores are weighted on a user's profile.
|
|
88
|
+
*
|
|
89
|
+
* For subsequent chunks, the initial max strain is calculated
|
|
90
|
+
* by decaying the previous hitobject's strain until the
|
|
91
|
+
* beginning of the new chunk.
|
|
92
|
+
*
|
|
93
|
+
* @param options Options for the difficulty calculation.
|
|
94
|
+
* @returns The current instance.
|
|
47
95
|
*/
|
|
48
|
-
|
|
96
|
+
calculate(options) {
|
|
97
|
+
this.mods = options?.mods ?? [];
|
|
98
|
+
const converted = new osuBase.BeatmapConverter(this.beatmap).convert({
|
|
99
|
+
mode: this.mode,
|
|
100
|
+
mods: this.mods,
|
|
101
|
+
customSpeedMultiplier: options?.customSpeedMultiplier,
|
|
102
|
+
});
|
|
103
|
+
this.difficultyStatistics = Object.seal(this.computeDifficultyStatistics(options));
|
|
104
|
+
this.populateDifficultyAttributes();
|
|
105
|
+
this.objects.push(...this.generateDifficultyHitObjects(converted));
|
|
106
|
+
this.calculateAll();
|
|
107
|
+
return this;
|
|
108
|
+
}
|
|
49
109
|
/**
|
|
50
|
-
*
|
|
110
|
+
* Calculates the skills provided.
|
|
111
|
+
*
|
|
112
|
+
* @param skills The skills to calculate.
|
|
113
|
+
*/
|
|
114
|
+
calculateSkills(...skills) {
|
|
115
|
+
// The first object doesn't generate a strain, so we begin calculating from the second object.
|
|
116
|
+
for (const object of this.objects.slice(1)) {
|
|
117
|
+
for (const skill of skills) {
|
|
118
|
+
skill.process(object);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Populates the stored difficulty attributes with necessary data.
|
|
124
|
+
*/
|
|
125
|
+
populateDifficultyAttributes() {
|
|
126
|
+
this.attributes.approachRate = this.difficultyStatistics.approachRate;
|
|
127
|
+
this.attributes.hitCircleCount = this.beatmap.hitObjects.circles;
|
|
128
|
+
this.attributes.maxCombo = this.beatmap.maxCombo;
|
|
129
|
+
this.attributes.mods = this.mods.slice();
|
|
130
|
+
this.attributes.overallDifficulty =
|
|
131
|
+
this.difficultyStatistics.overallDifficulty;
|
|
132
|
+
this.attributes.sliderCount = this.beatmap.hitObjects.sliders;
|
|
133
|
+
this.attributes.spinnerCount = this.beatmap.hitObjects.spinners;
|
|
134
|
+
this.attributes.clockRate =
|
|
135
|
+
this.difficultyStatistics.overallSpeedMultiplier;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Calculates the star rating value of a difficulty.
|
|
139
|
+
*
|
|
140
|
+
* @param difficulty The difficulty to calculate.
|
|
141
|
+
*/
|
|
142
|
+
starValue(difficulty) {
|
|
143
|
+
return Math.sqrt(difficulty) * this.difficultyMultiplier;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Calculates the base performance value of a difficulty rating.
|
|
147
|
+
*
|
|
148
|
+
* @param rating The difficulty rating.
|
|
149
|
+
*/
|
|
150
|
+
basePerformanceValue(rating) {
|
|
151
|
+
return Math.pow(5 * Math.max(1, rating / 0.0675) - 4, 3) / 100000;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Represents a hit object with difficulty calculation values.
|
|
157
|
+
*/
|
|
158
|
+
class DifficultyHitObject {
|
|
159
|
+
/**
|
|
160
|
+
* The underlying hitobject.
|
|
51
161
|
*/
|
|
52
|
-
|
|
162
|
+
object;
|
|
53
163
|
/**
|
|
54
|
-
* The
|
|
164
|
+
* The index of this hitobject in the list of all hitobjects.
|
|
165
|
+
*
|
|
166
|
+
* This is one less than the actual index of the hitobject in the beatmap.
|
|
55
167
|
*/
|
|
56
|
-
|
|
168
|
+
index;
|
|
57
169
|
/**
|
|
58
170
|
* The aim strain generated by the hitobject if sliders are considered.
|
|
59
171
|
*/
|
|
@@ -106,30 +218,68 @@ class DifficultyHitObject {
|
|
|
106
218
|
/**
|
|
107
219
|
* The amount of milliseconds elapsed between this hitobject and the last hitobject.
|
|
108
220
|
*/
|
|
109
|
-
deltaTime
|
|
221
|
+
deltaTime;
|
|
110
222
|
/**
|
|
111
223
|
* The amount of milliseconds elapsed since the start time of the previous hitobject, with a minimum of 25ms.
|
|
112
224
|
*/
|
|
113
|
-
strainTime
|
|
225
|
+
strainTime;
|
|
114
226
|
/**
|
|
115
227
|
* Adjusted start time of the hitobject, taking speed multiplier into account.
|
|
116
228
|
*/
|
|
117
|
-
startTime
|
|
229
|
+
startTime;
|
|
118
230
|
/**
|
|
119
231
|
* Adjusted end time of the hitobject, taking speed multiplier into account.
|
|
120
232
|
*/
|
|
121
|
-
endTime
|
|
233
|
+
endTime;
|
|
122
234
|
/**
|
|
123
235
|
* Other hitobjects in the beatmap, including this hitobject.
|
|
124
236
|
*/
|
|
125
237
|
hitObjects;
|
|
238
|
+
normalizedRadius = 50;
|
|
239
|
+
maximumSliderRadius = this.normalizedRadius * 2.4;
|
|
240
|
+
assumedSliderRadius = this.normalizedRadius * 1.8;
|
|
241
|
+
minDeltaTime = 25;
|
|
242
|
+
lastObject;
|
|
243
|
+
lastLastObject;
|
|
126
244
|
/**
|
|
245
|
+
* Note: You **must** call `computeProperties` at some point due to how TypeScript handles
|
|
246
|
+
* overridden properties (see [this](https://github.com/microsoft/TypeScript/issues/1617) GitHub issue).
|
|
247
|
+
*
|
|
127
248
|
* @param object The underlying hitobject.
|
|
128
|
-
* @param
|
|
249
|
+
* @param lastObject The hitobject before this hitobject.
|
|
250
|
+
* @param lastLastObject The hitobject before the last hitobject.
|
|
251
|
+
* @param difficultyHitObjects All difficulty hitobjects in the processed beatmap.
|
|
252
|
+
* @param clockRate The clock rate of the beatmap.
|
|
129
253
|
*/
|
|
130
|
-
constructor(object,
|
|
254
|
+
constructor(object, lastObject, lastLastObject, difficultyHitObjects, clockRate) {
|
|
131
255
|
this.object = object;
|
|
132
|
-
this.
|
|
256
|
+
this.lastObject = lastObject;
|
|
257
|
+
this.lastLastObject = lastLastObject;
|
|
258
|
+
this.hitObjects = difficultyHitObjects;
|
|
259
|
+
this.index = difficultyHitObjects.length - 1;
|
|
260
|
+
// Capped to 25ms to prevent difficulty calculation breaking from simultaneous objects.
|
|
261
|
+
this.startTime = object.startTime / clockRate;
|
|
262
|
+
this.endTime = object.endTime / clockRate;
|
|
263
|
+
if (lastObject) {
|
|
264
|
+
this.deltaTime = this.startTime - lastObject.startTime / clockRate;
|
|
265
|
+
this.strainTime = Math.max(this.deltaTime, this.minDeltaTime);
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
this.deltaTime = 0;
|
|
269
|
+
this.strainTime = 0;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Computes the properties of this hitobject.
|
|
274
|
+
*
|
|
275
|
+
* @param clockRate The clock rate of the beatmap.
|
|
276
|
+
* @param hitObjects The hitobjects in the beatmap.
|
|
277
|
+
*/
|
|
278
|
+
computeProperties(clockRate,
|
|
279
|
+
// Required for `DroidDifficultyHitObject` override.
|
|
280
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
281
|
+
hitObjects) {
|
|
282
|
+
this.setDistances(clockRate);
|
|
133
283
|
}
|
|
134
284
|
/**
|
|
135
285
|
* Gets the difficulty hitobject at a specific index with respect to the current
|
|
@@ -171,322 +321,88 @@ class DifficultyHitObject {
|
|
|
171
321
|
// but this is an approximation and such a case is unlikely to be hit where this function is used.
|
|
172
322
|
return 0;
|
|
173
323
|
}
|
|
174
|
-
const fadeInStartTime = this.object.startTime - this.
|
|
175
|
-
const fadeInDuration = this.timeFadeIn;
|
|
324
|
+
const fadeInStartTime = this.object.startTime - this.object.timePreempt;
|
|
325
|
+
const fadeInDuration = this.object.timeFadeIn;
|
|
176
326
|
if (isHidden) {
|
|
177
327
|
const fadeOutStartTime = fadeInStartTime + fadeInDuration;
|
|
178
|
-
const fadeOutDuration = this.
|
|
328
|
+
const fadeOutDuration = this.object.timePreempt * osuBase.ModHidden.fadeOutDurationMultiplier;
|
|
179
329
|
return Math.min(osuBase.MathUtils.clamp((time - fadeInStartTime) / fadeInDuration, 0, 1), 1 -
|
|
180
330
|
osuBase.MathUtils.clamp((time - fadeOutStartTime) / fadeOutDuration, 0, 1));
|
|
181
331
|
}
|
|
182
332
|
return osuBase.MathUtils.clamp((time - fadeInStartTime) / fadeInDuration, 0, 1);
|
|
183
333
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
* @returns Whether the hitobject is considered overlapping.
|
|
192
|
-
*/
|
|
193
|
-
isOverlapping(considerDistance) {
|
|
194
|
-
if (this.object instanceof osuBase.Spinner) {
|
|
195
|
-
return false;
|
|
196
|
-
}
|
|
197
|
-
const previous = this.previous(0);
|
|
198
|
-
if (!previous || previous.object instanceof osuBase.Spinner) {
|
|
199
|
-
return false;
|
|
200
|
-
}
|
|
201
|
-
if (this.deltaTime >= 5) {
|
|
202
|
-
return false;
|
|
203
|
-
}
|
|
204
|
-
if (considerDistance) {
|
|
205
|
-
const endPosition = this.object.getStackedPosition(osuBase.Modes.droid);
|
|
206
|
-
let distance = previous.object
|
|
207
|
-
.getStackedEndPosition(osuBase.Modes.droid)
|
|
208
|
-
.getDistance(endPosition);
|
|
209
|
-
if (previous.object instanceof osuBase.Slider &&
|
|
210
|
-
previous.object.lazyEndPosition) {
|
|
211
|
-
distance = Math.min(distance, previous.object.lazyEndPosition.getDistance(endPosition));
|
|
334
|
+
setDistances(clockRate) {
|
|
335
|
+
if (this.object instanceof osuBase.Slider) {
|
|
336
|
+
this.calculateSliderCursorPosition(this.object);
|
|
337
|
+
this.travelDistance = this.object.lazyTravelDistance;
|
|
338
|
+
// Bonus for repeat sliders until a better per nested object strain system can be achieved.
|
|
339
|
+
if (this.mode === osuBase.Modes.droid) {
|
|
340
|
+
this.travelDistance *= Math.pow(1 + this.object.repeatCount / 4, 1 / 4);
|
|
212
341
|
}
|
|
213
|
-
|
|
342
|
+
else {
|
|
343
|
+
this.travelDistance *= Math.pow(1 + this.object.repeatCount / 2.5, 1 / 2.5);
|
|
344
|
+
}
|
|
345
|
+
this.travelTime = Math.max(this.object.lazyTravelTime / clockRate, this.minDeltaTime);
|
|
214
346
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
* Represents an osu!droid hit object with difficulty calculation values.
|
|
221
|
-
*/
|
|
222
|
-
class DroidDifficultyHitObject extends DifficultyHitObject {
|
|
223
|
-
/**
|
|
224
|
-
* The tap strain generated by the hitobject.
|
|
225
|
-
*/
|
|
226
|
-
tapStrain = 0;
|
|
227
|
-
/**
|
|
228
|
-
* The tap strain generated by the hitobject if `strainTime` isn't modified by
|
|
229
|
-
* OD. This is used in three-finger detection.
|
|
230
|
-
*/
|
|
231
|
-
originalTapStrain = 0;
|
|
232
|
-
/**
|
|
233
|
-
* The rhythm strain generated by the hitobject.
|
|
234
|
-
*/
|
|
235
|
-
rhythmStrain = 0;
|
|
236
|
-
/**
|
|
237
|
-
* The flashlight strain generated by the hitobject if sliders are considered.
|
|
238
|
-
*/
|
|
239
|
-
flashlightStrainWithSliders = 0;
|
|
240
|
-
/**
|
|
241
|
-
* The flashlight strain generated by the hitobject if sliders are not considered.
|
|
242
|
-
*/
|
|
243
|
-
flashlightStrainWithoutSliders = 0;
|
|
244
|
-
/**
|
|
245
|
-
* The visual strain generated by the hitobject if sliders are considered.
|
|
246
|
-
*/
|
|
247
|
-
visualStrainWithSliders = 0;
|
|
248
|
-
/**
|
|
249
|
-
* The visual strain generated by the hitobject if sliders are not considered.
|
|
250
|
-
*/
|
|
251
|
-
visualStrainWithoutSliders = 0;
|
|
252
|
-
/**
|
|
253
|
-
* The note density of the hitobject.
|
|
254
|
-
*/
|
|
255
|
-
noteDensity = 1;
|
|
256
|
-
/**
|
|
257
|
-
* The overlapping factor of the hitobject.
|
|
258
|
-
*
|
|
259
|
-
* This is used to scale visual skill.
|
|
260
|
-
*/
|
|
261
|
-
overlappingFactor = 0;
|
|
262
|
-
/**
|
|
263
|
-
* @param object The underlying hitobject.
|
|
264
|
-
* @param hitObjects All difficulty hitobjects in the processed beatmap.
|
|
265
|
-
*/
|
|
266
|
-
constructor(object, hitObjects) {
|
|
267
|
-
super(object, hitObjects);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* Represents an osu!standard hit object with difficulty calculation values.
|
|
273
|
-
*/
|
|
274
|
-
class OsuDifficultyHitObject extends DifficultyHitObject {
|
|
275
|
-
/**
|
|
276
|
-
* The speed strain generated by the hitobject.
|
|
277
|
-
*/
|
|
278
|
-
speedStrain = 0;
|
|
279
|
-
/**
|
|
280
|
-
* The flashlight strain generated by this hitobject.
|
|
281
|
-
*/
|
|
282
|
-
flashlightStrain = 0;
|
|
283
|
-
/**
|
|
284
|
-
* @param object The underlying hitobject.
|
|
285
|
-
* @param hitObjects All difficulty hitobjects in the processed beatmap.
|
|
286
|
-
*/
|
|
287
|
-
constructor(object, hitObjects) {
|
|
288
|
-
super(object, hitObjects);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* A converter used to convert normal hitobjects into difficulty hitobjects.
|
|
294
|
-
*/
|
|
295
|
-
class DifficultyHitObjectCreator {
|
|
296
|
-
/**
|
|
297
|
-
* The threshold for small circle buff for osu!droid.
|
|
298
|
-
*/
|
|
299
|
-
DROID_CIRCLESIZE_BUFF_THRESHOLD = 70;
|
|
300
|
-
/**
|
|
301
|
-
* The threshold for small circle buff for osu!standard.
|
|
302
|
-
*/
|
|
303
|
-
PC_CIRCLESIZE_BUFF_THRESHOLD = 30;
|
|
304
|
-
/**
|
|
305
|
-
* The gamemode this creator is creating for.
|
|
306
|
-
*/
|
|
307
|
-
mode = osuBase.Modes.osu;
|
|
308
|
-
/**
|
|
309
|
-
* The base normalized radius of hitobjects.
|
|
310
|
-
*/
|
|
311
|
-
normalizedRadius = 50;
|
|
312
|
-
maximumSliderRadius = this.normalizedRadius * 2.4;
|
|
313
|
-
assumedSliderRadius = this.normalizedRadius * 1.8;
|
|
314
|
-
minDeltaTime = 25;
|
|
315
|
-
generateDifficultyObjects(params) {
|
|
316
|
-
params.preempt ??= 600;
|
|
317
|
-
this.mode = params.mode;
|
|
318
|
-
if (this.mode === osuBase.Modes.droid) {
|
|
319
|
-
this.maximumSliderRadius = this.normalizedRadius * 2;
|
|
347
|
+
// We don't need to calculate either angle or distance when one of the last->curr objects is a spinner.
|
|
348
|
+
if (!this.lastObject ||
|
|
349
|
+
this.object instanceof osuBase.Spinner ||
|
|
350
|
+
this.lastObject instanceof osuBase.Spinner) {
|
|
351
|
+
return;
|
|
320
352
|
}
|
|
321
|
-
|
|
322
|
-
const
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
// Cap to 25ms to prevent difficulty calculation breaking from simultaneous objects.
|
|
354
|
-
object.strainTime = Math.max(this.minDeltaTime, object.deltaTime);
|
|
355
|
-
if (object.object instanceof osuBase.Spinner) {
|
|
356
|
-
difficultyObjects.push(object);
|
|
357
|
-
continue;
|
|
358
|
-
}
|
|
359
|
-
if (object instanceof DroidDifficultyHitObject) {
|
|
360
|
-
// We'll have two visible object arrays. The first array contains objects before the current object starts in a reversed order,
|
|
361
|
-
// while the second array contains objects after the current object ends.
|
|
362
|
-
// For overlapping factor, we also need to consider previous visible objects.
|
|
363
|
-
const prevVisibleObjects = [];
|
|
364
|
-
const nextVisibleObjects = [];
|
|
365
|
-
for (let j = i + 1; j < params.objects.length; ++j) {
|
|
366
|
-
const o = params.objects[j];
|
|
367
|
-
if (o instanceof osuBase.Spinner) {
|
|
368
|
-
continue;
|
|
369
|
-
}
|
|
370
|
-
if (o.startTime / params.speedMultiplier >
|
|
371
|
-
object.endTime + object.timePreempt) {
|
|
372
|
-
break;
|
|
373
|
-
}
|
|
374
|
-
nextVisibleObjects.push(o);
|
|
375
|
-
}
|
|
376
|
-
for (let j = 0; j < object.index; ++j) {
|
|
377
|
-
const prev = object.previous(j);
|
|
378
|
-
if (prev.object instanceof osuBase.Spinner) {
|
|
379
|
-
continue;
|
|
380
|
-
}
|
|
381
|
-
if (prev.startTime >= object.startTime) {
|
|
382
|
-
continue;
|
|
383
|
-
}
|
|
384
|
-
if (prev.startTime <
|
|
385
|
-
object.startTime - object.timePreempt) {
|
|
386
|
-
break;
|
|
387
|
-
}
|
|
388
|
-
prevVisibleObjects.push(prev.object);
|
|
389
|
-
}
|
|
390
|
-
for (const hitObject of prevVisibleObjects) {
|
|
391
|
-
const distance = object.object
|
|
392
|
-
.getStackedPosition(this.mode)
|
|
393
|
-
.getDistance(hitObject.getStackedEndPosition(this.mode));
|
|
394
|
-
const deltaTime = object.startTime -
|
|
395
|
-
hitObject.endTime / params.speedMultiplier;
|
|
396
|
-
this.applyToOverlappingFactor(object, distance, deltaTime);
|
|
397
|
-
}
|
|
398
|
-
for (const hitObject of nextVisibleObjects) {
|
|
399
|
-
const distance = hitObject
|
|
400
|
-
.getStackedPosition(this.mode)
|
|
401
|
-
.getDistance(object.object.getStackedEndPosition(this.mode));
|
|
402
|
-
const deltaTime = hitObject.startTime / params.speedMultiplier -
|
|
403
|
-
object.endTime;
|
|
404
|
-
if (deltaTime >= 0) {
|
|
405
|
-
object.noteDensity +=
|
|
406
|
-
1 - deltaTime / object.timePreempt;
|
|
407
|
-
}
|
|
408
|
-
this.applyToOverlappingFactor(object, distance, deltaTime);
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
if (lastObject.object instanceof osuBase.Spinner) {
|
|
412
|
-
difficultyObjects.push(object);
|
|
413
|
-
continue;
|
|
414
|
-
}
|
|
415
|
-
const lastCursorPosition = this.getEndCursorPosition(lastObject.object);
|
|
416
|
-
object.lazyJumpDistance = object.object
|
|
353
|
+
// We will scale distances by this factor, so we can assume a uniform CircleSize among beatmaps.
|
|
354
|
+
const { scalingFactor } = this;
|
|
355
|
+
const lastCursorPosition = this.getEndCursorPosition(this.lastObject);
|
|
356
|
+
this.lazyJumpDistance = this.object
|
|
357
|
+
.getStackedPosition(this.mode)
|
|
358
|
+
.scale(scalingFactor)
|
|
359
|
+
.subtract(lastCursorPosition.scale(scalingFactor)).length;
|
|
360
|
+
this.minimumJumpTime = this.strainTime;
|
|
361
|
+
this.minimumJumpDistance = this.lazyJumpDistance;
|
|
362
|
+
if (this.lastObject instanceof osuBase.Slider) {
|
|
363
|
+
const lastTravelTime = Math.max(this.lastObject.lazyTravelTime / clockRate, this.minDeltaTime);
|
|
364
|
+
this.minimumJumpTime = Math.max(this.strainTime - lastTravelTime, this.minDeltaTime);
|
|
365
|
+
// 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.
|
|
366
|
+
//
|
|
367
|
+
// 1. The anti-flow pattern, where players cut the slider short in order to move to the next hitobject.
|
|
368
|
+
//
|
|
369
|
+
// <======o==> ← slider
|
|
370
|
+
// | ← most natural jump path
|
|
371
|
+
// o ← a follow-up hitcircle
|
|
372
|
+
//
|
|
373
|
+
// In this case the most natural jump path is approximated by LazyJumpDistance.
|
|
374
|
+
//
|
|
375
|
+
// 2. The flow pattern, where players follow through the slider to its visual extent into the next hitobject.
|
|
376
|
+
//
|
|
377
|
+
// <======o==>---o
|
|
378
|
+
// ↑
|
|
379
|
+
// most natural jump path
|
|
380
|
+
//
|
|
381
|
+
// In this case the most natural jump path is better approximated by a new distance called "tailJumpDistance" - the distance between the slider's tail and the next hitobject.
|
|
382
|
+
//
|
|
383
|
+
// Thus, the player is assumed to jump the minimum of these two distances in all cases.
|
|
384
|
+
const tailJumpDistance = this.lastObject.tail
|
|
417
385
|
.getStackedPosition(this.mode)
|
|
418
|
-
.
|
|
419
|
-
.
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
// In this case the most natural jump path is approximated by LazyJumpDistance.
|
|
433
|
-
//
|
|
434
|
-
// 2. The flow pattern, where players follow through the slider to its visual extent into the next hitobject.
|
|
435
|
-
//
|
|
436
|
-
// <======o==>---o
|
|
437
|
-
// ↑
|
|
438
|
-
// most natural jump path
|
|
439
|
-
//
|
|
440
|
-
// In this case the most natural jump path is better approximated by a new distance called "tailJumpDistance" - the distance between the slider's tail and the next hitobject.
|
|
441
|
-
//
|
|
442
|
-
// Thus, the player is assumed to jump the minimum of these two distances in all cases.
|
|
443
|
-
const tailJumpDistance = lastObject.object.tail
|
|
444
|
-
.getStackedPosition(this.mode)
|
|
445
|
-
.subtract(object.object.getStackedPosition(this.mode))
|
|
446
|
-
.length * scalingFactor;
|
|
447
|
-
object.minimumJumpDistance = Math.max(0, Math.min(object.lazyJumpDistance -
|
|
448
|
-
(this.maximumSliderRadius -
|
|
449
|
-
this.assumedSliderRadius), tailJumpDistance - this.maximumSliderRadius));
|
|
450
|
-
}
|
|
451
|
-
if (lastLastObject && !(lastLastObject.object instanceof osuBase.Spinner)) {
|
|
452
|
-
const lastLastCursorPosition = this.getEndCursorPosition(lastLastObject.object);
|
|
453
|
-
const v1 = lastLastCursorPosition.subtract(lastObject.object.getStackedPosition(this.mode));
|
|
454
|
-
const v2 = object.object
|
|
455
|
-
.getStackedPosition(this.mode)
|
|
456
|
-
.subtract(lastCursorPosition);
|
|
457
|
-
const dot = v1.dot(v2);
|
|
458
|
-
const det = v1.x * v2.y - v1.y * v2.x;
|
|
459
|
-
object.angle = Math.abs(Math.atan2(det, dot));
|
|
460
|
-
}
|
|
461
|
-
difficultyObjects.push(object);
|
|
386
|
+
.subtract(this.object.getStackedPosition(this.mode))
|
|
387
|
+
.length * scalingFactor;
|
|
388
|
+
this.minimumJumpDistance = Math.max(0, Math.min(this.lazyJumpDistance -
|
|
389
|
+
(this.maximumSliderRadius - this.assumedSliderRadius), tailJumpDistance - this.maximumSliderRadius));
|
|
390
|
+
}
|
|
391
|
+
if (this.lastLastObject && !(this.lastLastObject instanceof osuBase.Spinner)) {
|
|
392
|
+
const lastLastCursorPosition = this.getEndCursorPosition(this.lastLastObject);
|
|
393
|
+
const v1 = lastLastCursorPosition.subtract(this.lastObject.getStackedPosition(this.mode));
|
|
394
|
+
const v2 = this.object
|
|
395
|
+
.getStackedPosition(this.mode)
|
|
396
|
+
.subtract(lastCursorPosition);
|
|
397
|
+
const dot = v1.dot(v2);
|
|
398
|
+
const det = v1.x * v2.y - v1.y * v2.x;
|
|
399
|
+
this.angle = Math.abs(Math.atan2(det, dot));
|
|
462
400
|
}
|
|
463
|
-
return difficultyObjects;
|
|
464
401
|
}
|
|
465
|
-
/**
|
|
466
|
-
* Calculates a slider's cursor position.
|
|
467
|
-
*/
|
|
468
402
|
calculateSliderCursorPosition(slider) {
|
|
469
403
|
if (slider.lazyEndPosition) {
|
|
470
404
|
return;
|
|
471
405
|
}
|
|
472
|
-
// Droid doesn't have a legacy slider tail. Since beatmap parser defaults slider tail
|
|
473
|
-
// to legacy slider tail, it needs to be changed to real slider tail first.
|
|
474
|
-
if (this.mode === osuBase.Modes.droid) {
|
|
475
|
-
slider.tail.startTime += osuBase.Slider.legacyLastTickOffset;
|
|
476
|
-
slider.tail.endTime += osuBase.Slider.legacyLastTickOffset;
|
|
477
|
-
slider.nestedHitObjects.sort((a, b) => a.startTime - b.startTime);
|
|
478
|
-
// Temporary lazy end position until a real result can be derived.
|
|
479
|
-
slider.lazyEndPosition = slider.getStackedPosition(this.mode);
|
|
480
|
-
// Stop here if the slider has too short duration due to float number limitation.
|
|
481
|
-
// Incredibly close start and end time fluctuates travel distance and lazy
|
|
482
|
-
// end position heavily, which we do not want to happen.
|
|
483
|
-
//
|
|
484
|
-
// In the real game, this shouldn't happen. Perhaps we need to reinvestigate this
|
|
485
|
-
// in the future.
|
|
486
|
-
if (osuBase.Precision.almostEqualsNumber(slider.startTime, slider.endTime)) {
|
|
487
|
-
return;
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
406
|
// Not using slider.endTime due to legacy last tick offset.
|
|
491
407
|
slider.lazyTravelTime =
|
|
492
408
|
slider.nestedHitObjects.at(-1).startTime - slider.startTime;
|
|
@@ -502,7 +418,7 @@ class DifficultyHitObjectCreator {
|
|
|
502
418
|
.getStackedPosition(this.mode)
|
|
503
419
|
.add(slider.path.positionAt(endTimeMin));
|
|
504
420
|
let currentCursorPosition = slider.getStackedPosition(this.mode);
|
|
505
|
-
const scalingFactor = this.normalizedRadius / slider.
|
|
421
|
+
const scalingFactor = this.normalizedRadius / slider.radius;
|
|
506
422
|
for (let i = 1; i < slider.nestedHitObjects.length; ++i) {
|
|
507
423
|
const currentMovementObject = slider.nestedHitObjects[i];
|
|
508
424
|
let currentMovement = currentMovementObject
|
|
@@ -530,208 +446,24 @@ class DifficultyHitObjectCreator {
|
|
|
530
446
|
// This finds the positional delta from the required radius and the current position,
|
|
531
447
|
// and updates the currentCursorPosition accordingly, as well as rewarding distance.
|
|
532
448
|
currentCursorPosition = currentCursorPosition.add(currentMovement.scale((currentMovementLength - requiredMovement) /
|
|
533
|
-
currentMovementLength));
|
|
534
|
-
currentMovementLength *=
|
|
535
|
-
(currentMovementLength - requiredMovement) /
|
|
536
|
-
currentMovementLength;
|
|
537
|
-
slider.lazyTravelDistance += currentMovementLength;
|
|
538
|
-
}
|
|
539
|
-
if (i === slider.nestedHitObjects.length - 1) {
|
|
540
|
-
slider.lazyEndPosition = currentCursorPosition;
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
/**
|
|
545
|
-
* Gets the scaling factor of a radius.
|
|
546
|
-
*
|
|
547
|
-
* @param radius The radius to get the scaling factor from.
|
|
548
|
-
*/
|
|
549
|
-
getScalingFactor(radius) {
|
|
550
|
-
// We will scale distances by this factor, so we can assume a uniform CircleSize among beatmaps.
|
|
551
|
-
let scalingFactor = this.normalizedRadius / radius;
|
|
552
|
-
// High circle size (small CS) bonus
|
|
553
|
-
switch (this.mode) {
|
|
554
|
-
case osuBase.Modes.droid:
|
|
555
|
-
if (radius < this.DROID_CIRCLESIZE_BUFF_THRESHOLD) {
|
|
556
|
-
scalingFactor *=
|
|
557
|
-
1 +
|
|
558
|
-
Math.pow((this.DROID_CIRCLESIZE_BUFF_THRESHOLD - radius) /
|
|
559
|
-
50, 2);
|
|
560
|
-
}
|
|
561
|
-
break;
|
|
562
|
-
case osuBase.Modes.osu:
|
|
563
|
-
if (radius < this.PC_CIRCLESIZE_BUFF_THRESHOLD) {
|
|
564
|
-
scalingFactor *=
|
|
565
|
-
1 +
|
|
566
|
-
Math.min(this.PC_CIRCLESIZE_BUFF_THRESHOLD - radius, 5) /
|
|
567
|
-
50;
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
return scalingFactor;
|
|
571
|
-
}
|
|
572
|
-
/**
|
|
573
|
-
* Returns the end cursor position of a hitobject.
|
|
574
|
-
*/
|
|
575
|
-
getEndCursorPosition(object) {
|
|
576
|
-
let pos = object.getStackedPosition(this.mode);
|
|
577
|
-
if (object instanceof osuBase.Slider) {
|
|
578
|
-
this.calculateSliderCursorPosition(object);
|
|
579
|
-
pos = object.lazyEndPosition ?? pos;
|
|
580
|
-
}
|
|
581
|
-
return pos;
|
|
582
|
-
}
|
|
583
|
-
applyToOverlappingFactor(object, distance, deltaTime) {
|
|
584
|
-
// Penalize objects that are too close to the object in both distance
|
|
585
|
-
// and delta time to prevent stream maps from being overweighted.
|
|
586
|
-
object.overlappingFactor +=
|
|
587
|
-
Math.max(0, 1 - distance / (3 * object.object.getRadius(this.mode))) *
|
|
588
|
-
(7.5 /
|
|
589
|
-
(1 +
|
|
590
|
-
Math.exp(0.15 * (Math.max(deltaTime, this.minDeltaTime) - 75))));
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
/**
|
|
595
|
-
* The base of a difficulty calculator.
|
|
596
|
-
*/
|
|
597
|
-
class DifficultyCalculator {
|
|
598
|
-
/**
|
|
599
|
-
* The calculated beatmap.
|
|
600
|
-
*/
|
|
601
|
-
beatmap;
|
|
602
|
-
/**
|
|
603
|
-
* The difficulty objects of the beatmap.
|
|
604
|
-
*/
|
|
605
|
-
objects = [];
|
|
606
|
-
/**
|
|
607
|
-
* The modifications applied.
|
|
608
|
-
*/
|
|
609
|
-
mods = [];
|
|
610
|
-
/**
|
|
611
|
-
* The total star rating of the beatmap.
|
|
612
|
-
*/
|
|
613
|
-
total = 0;
|
|
614
|
-
/**
|
|
615
|
-
* The map statistics of the beatmap after modifications are applied.
|
|
616
|
-
*/
|
|
617
|
-
stats = new osuBase.MapStats();
|
|
618
|
-
/**
|
|
619
|
-
* The strain peaks of various calculated difficulties.
|
|
620
|
-
*/
|
|
621
|
-
strainPeaks = {
|
|
622
|
-
aimWithSliders: [],
|
|
623
|
-
aimWithoutSliders: [],
|
|
624
|
-
speed: [],
|
|
625
|
-
flashlight: [],
|
|
626
|
-
};
|
|
627
|
-
/**
|
|
628
|
-
* Constructs a new instance of the calculator.
|
|
629
|
-
*
|
|
630
|
-
* @param beatmap The beatmap to calculate. This beatmap will be deep-cloned to prevent reference changes.
|
|
631
|
-
*/
|
|
632
|
-
constructor(beatmap) {
|
|
633
|
-
this.beatmap = osuBase.Utils.deepCopy(beatmap);
|
|
634
|
-
}
|
|
635
|
-
/**
|
|
636
|
-
* Calculates the star rating of the specified beatmap.
|
|
637
|
-
*
|
|
638
|
-
* The beatmap is analyzed in chunks of `sectionLength` duration.
|
|
639
|
-
* For each chunk the highest hitobject strains are added to
|
|
640
|
-
* a list which is then collapsed into a weighted sum, much
|
|
641
|
-
* like scores are weighted on a user's profile.
|
|
642
|
-
*
|
|
643
|
-
* For subsequent chunks, the initial max strain is calculated
|
|
644
|
-
* by decaying the previous hitobject's strain until the
|
|
645
|
-
* beginning of the new chunk.
|
|
646
|
-
*
|
|
647
|
-
* @param options Options for the difficulty calculation.
|
|
648
|
-
* @returns The current instance.
|
|
649
|
-
*/
|
|
650
|
-
calculate(options) {
|
|
651
|
-
this.mods = options?.mods ?? [];
|
|
652
|
-
const { difficulty } = this.beatmap;
|
|
653
|
-
this.stats = new osuBase.MapStats({
|
|
654
|
-
...options?.stats,
|
|
655
|
-
cs: options?.stats?.forceCS
|
|
656
|
-
? options.stats.cs ?? difficulty.cs
|
|
657
|
-
: difficulty.cs,
|
|
658
|
-
ar: options?.stats?.forceAR
|
|
659
|
-
? options.stats.ar ?? difficulty.ar
|
|
660
|
-
: difficulty.ar,
|
|
661
|
-
od: options?.stats?.forceOD
|
|
662
|
-
? options.stats.od ?? difficulty.od
|
|
663
|
-
: difficulty.od,
|
|
664
|
-
hp: options?.stats?.forceHP
|
|
665
|
-
? options.stats.hp ?? difficulty.hp
|
|
666
|
-
: difficulty.hp,
|
|
667
|
-
mods: options?.mods,
|
|
668
|
-
}).calculate({ mode: this.mode });
|
|
669
|
-
this.preProcess();
|
|
670
|
-
this.populateDifficultyAttributes();
|
|
671
|
-
this.generateDifficultyHitObjects();
|
|
672
|
-
this.calculateAll();
|
|
673
|
-
return this;
|
|
674
|
-
}
|
|
675
|
-
/**
|
|
676
|
-
* Generates difficulty hitobjects for this calculator.
|
|
677
|
-
*/
|
|
678
|
-
generateDifficultyHitObjects() {
|
|
679
|
-
this.objects.length = 0;
|
|
680
|
-
this.objects.push(...new DifficultyHitObjectCreator().generateDifficultyObjects({
|
|
681
|
-
objects: this.beatmap.hitObjects.objects,
|
|
682
|
-
circleSize: this.stats.cs,
|
|
683
|
-
mods: this.mods,
|
|
684
|
-
speedMultiplier: this.stats.speedMultiplier,
|
|
685
|
-
mode: this.mode,
|
|
686
|
-
preempt: osuBase.MapStats.arToMS(this.stats.ar),
|
|
687
|
-
}));
|
|
688
|
-
}
|
|
689
|
-
/**
|
|
690
|
-
* Performs some pre-processing before proceeding with difficulty calculation.
|
|
691
|
-
*/
|
|
692
|
-
preProcess() {
|
|
693
|
-
}
|
|
694
|
-
/**
|
|
695
|
-
* Calculates the skills provided.
|
|
696
|
-
*
|
|
697
|
-
* @param skills The skills to calculate.
|
|
698
|
-
*/
|
|
699
|
-
calculateSkills(...skills) {
|
|
700
|
-
// The first object doesn't generate a strain, so we begin calculating from the second object.
|
|
701
|
-
for (const object of this.objects.slice(1)) {
|
|
702
|
-
for (const skill of skills) {
|
|
703
|
-
skill.process(object);
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
/**
|
|
708
|
-
* Populates the stored difficulty attributes with necessary data.
|
|
709
|
-
*/
|
|
710
|
-
populateDifficultyAttributes() {
|
|
711
|
-
this.attributes.approachRate = this.stats.ar;
|
|
712
|
-
this.attributes.hitCircleCount = this.beatmap.hitObjects.circles;
|
|
713
|
-
this.attributes.maxCombo = this.beatmap.maxCombo;
|
|
714
|
-
this.attributes.mods = this.mods.slice();
|
|
715
|
-
this.attributes.overallDifficulty = this.stats.od;
|
|
716
|
-
this.attributes.sliderCount = this.beatmap.hitObjects.sliders;
|
|
717
|
-
this.attributes.spinnerCount = this.beatmap.hitObjects.spinners;
|
|
718
|
-
this.attributes.clockRate = this.stats.speedMultiplier;
|
|
719
|
-
}
|
|
720
|
-
/**
|
|
721
|
-
* Calculates the star rating value of a difficulty.
|
|
722
|
-
*
|
|
723
|
-
* @param difficulty The difficulty to calculate.
|
|
724
|
-
*/
|
|
725
|
-
starValue(difficulty) {
|
|
726
|
-
return Math.sqrt(difficulty) * this.difficultyMultiplier;
|
|
449
|
+
currentMovementLength));
|
|
450
|
+
currentMovementLength *=
|
|
451
|
+
(currentMovementLength - requiredMovement) /
|
|
452
|
+
currentMovementLength;
|
|
453
|
+
slider.lazyTravelDistance += currentMovementLength;
|
|
454
|
+
}
|
|
455
|
+
if (i === slider.nestedHitObjects.length - 1) {
|
|
456
|
+
slider.lazyEndPosition = currentCursorPosition;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
727
459
|
}
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
return
|
|
460
|
+
getEndCursorPosition(object) {
|
|
461
|
+
let pos = object.getStackedPosition(this.mode);
|
|
462
|
+
if (object instanceof osuBase.Slider) {
|
|
463
|
+
this.calculateSliderCursorPosition(object);
|
|
464
|
+
pos = object.lazyEndPosition ?? pos;
|
|
465
|
+
}
|
|
466
|
+
return pos;
|
|
735
467
|
}
|
|
736
468
|
}
|
|
737
469
|
|
|
@@ -922,9 +654,7 @@ class StrainSkill extends Skill {
|
|
|
922
654
|
process(current) {
|
|
923
655
|
// The first object doesn't generate a strain, so we begin with an incremented section end
|
|
924
656
|
if (current.index === 0) {
|
|
925
|
-
this.currentSectionEnd =
|
|
926
|
-
Math.ceil(current.startTime / this.sectionLength) *
|
|
927
|
-
this.sectionLength;
|
|
657
|
+
this.currentSectionEnd = this.calculateCurrentSectionStart(current);
|
|
928
658
|
}
|
|
929
659
|
while (current.startTime > this.currentSectionEnd) {
|
|
930
660
|
this.saveCurrentPeak();
|
|
@@ -954,6 +684,16 @@ class StrainSkill extends Skill {
|
|
|
954
684
|
strainDecay(ms) {
|
|
955
685
|
return Math.pow(this.strainDecayBase, ms / 1000);
|
|
956
686
|
}
|
|
687
|
+
/**
|
|
688
|
+
* Calculates the starting time of a strain section at an object.
|
|
689
|
+
*
|
|
690
|
+
* @param current The object at which the strain section starts.
|
|
691
|
+
* @returns The start time of the strain section.
|
|
692
|
+
*/
|
|
693
|
+
calculateCurrentSectionStart(current) {
|
|
694
|
+
return (Math.ceil(current.startTime / this.sectionLength) *
|
|
695
|
+
this.sectionLength);
|
|
696
|
+
}
|
|
957
697
|
/**
|
|
958
698
|
* Sets the initial strain level for a new section.
|
|
959
699
|
*
|
|
@@ -972,6 +712,32 @@ class StrainSkill extends Skill {
|
|
|
972
712
|
* and to calculate a final difficulty value representing the difficulty of hitting all the processed objects.
|
|
973
713
|
*/
|
|
974
714
|
class DroidSkill extends StrainSkill {
|
|
715
|
+
_objectStrains = [];
|
|
716
|
+
/**
|
|
717
|
+
* The strains of hitobjects.
|
|
718
|
+
*/
|
|
719
|
+
get objectStrains() {
|
|
720
|
+
return this._objectStrains;
|
|
721
|
+
}
|
|
722
|
+
/**
|
|
723
|
+
* Returns the number of strains weighed against the top strain.
|
|
724
|
+
*
|
|
725
|
+
* The result is scaled by clock rate as it affects the total number of strains.
|
|
726
|
+
*/
|
|
727
|
+
countDifficultStrains() {
|
|
728
|
+
if (this._objectStrains.length === 0) {
|
|
729
|
+
return 0;
|
|
730
|
+
}
|
|
731
|
+
const maxStrain = Math.max(...this._objectStrains);
|
|
732
|
+
if (maxStrain === 0) {
|
|
733
|
+
return 0;
|
|
734
|
+
}
|
|
735
|
+
return this._objectStrains.reduce((total, next) => total + Math.pow(next / maxStrain, 4), 0);
|
|
736
|
+
}
|
|
737
|
+
process(current) {
|
|
738
|
+
super.process(current);
|
|
739
|
+
this._objectStrains.push(this.getObjectStrain(current));
|
|
740
|
+
}
|
|
975
741
|
difficultyValue() {
|
|
976
742
|
const strains = this.strainPeaks.slice();
|
|
977
743
|
if (this.reducedSectionCount > 0) {
|
|
@@ -991,6 +757,9 @@ class DroidSkill extends StrainSkill {
|
|
|
991
757
|
return a + Math.pow(v, 1 / Math.log2(this.starsPerDouble));
|
|
992
758
|
}, 0), Math.log2(this.starsPerDouble));
|
|
993
759
|
}
|
|
760
|
+
calculateCurrentSectionStart(current) {
|
|
761
|
+
return current.startTime;
|
|
762
|
+
}
|
|
994
763
|
}
|
|
995
764
|
|
|
996
765
|
/**
|
|
@@ -1019,6 +788,9 @@ class DroidAim extends DroidSkill {
|
|
|
1019
788
|
return (this.currentAimStrain *
|
|
1020
789
|
this.strainDecay(time - (current.previous(0)?.startTime ?? 0)));
|
|
1021
790
|
}
|
|
791
|
+
getObjectStrain() {
|
|
792
|
+
return this.currentAimStrain;
|
|
793
|
+
}
|
|
1022
794
|
/**
|
|
1023
795
|
* @param current The hitobject to save to.
|
|
1024
796
|
*/
|
|
@@ -1051,13 +823,15 @@ class DroidTapEvaluator extends SpeedEvaluator {
|
|
|
1051
823
|
*
|
|
1052
824
|
* - time between pressing the previous and current object,
|
|
1053
825
|
* - distance between those objects,
|
|
1054
|
-
* -
|
|
826
|
+
* - how easily they can be cheesed,
|
|
827
|
+
* - and the strain time cap.
|
|
1055
828
|
*
|
|
1056
829
|
* @param current The current object.
|
|
1057
830
|
* @param greatWindow The great hit window of the current object.
|
|
1058
831
|
* @param considerCheesability Whether to consider cheesability.
|
|
832
|
+
* @param strainTimeCap The strain time to cap the object's strain time to.
|
|
1059
833
|
*/
|
|
1060
|
-
static evaluateDifficultyOf(current, greatWindow, considerCheesability) {
|
|
834
|
+
static evaluateDifficultyOf(current, greatWindow, considerCheesability, strainTimeCap) {
|
|
1061
835
|
if (current.object instanceof osuBase.Spinner ||
|
|
1062
836
|
// Exclude overlapping objects that can be tapped at once.
|
|
1063
837
|
current.isOverlapping(false)) {
|
|
@@ -1078,13 +852,17 @@ class DroidTapEvaluator extends SpeedEvaluator {
|
|
|
1078
852
|
doubletapness = Math.pow(speedRatio, 1 - windowRatio);
|
|
1079
853
|
}
|
|
1080
854
|
}
|
|
855
|
+
const strainTime = strainTimeCap !== undefined
|
|
856
|
+
? // We cap the strain time to 50 here as the chance of vibro is higher in any BPM higher than 300.
|
|
857
|
+
Math.max(50, strainTimeCap, current.strainTime)
|
|
858
|
+
: current.strainTime;
|
|
1081
859
|
let speedBonus = 1;
|
|
1082
|
-
if (
|
|
860
|
+
if (strainTime < this.minSpeedBonus) {
|
|
1083
861
|
speedBonus +=
|
|
1084
862
|
0.75 *
|
|
1085
|
-
Math.pow(osuBase.ErrorFunction.erf((this.minSpeedBonus -
|
|
863
|
+
Math.pow(osuBase.ErrorFunction.erf((this.minSpeedBonus - strainTime) / 40), 2);
|
|
1086
864
|
}
|
|
1087
|
-
return (speedBonus * Math.pow(doubletapness, 1.5)) /
|
|
865
|
+
return (speedBonus * Math.pow(doubletapness, 1.5)) / strainTime;
|
|
1088
866
|
}
|
|
1089
867
|
}
|
|
1090
868
|
|
|
@@ -1101,17 +879,59 @@ class DroidTap extends DroidSkill {
|
|
|
1101
879
|
skillMultiplier = 1375;
|
|
1102
880
|
greatWindow;
|
|
1103
881
|
considerCheesability;
|
|
1104
|
-
|
|
882
|
+
strainTimeCap;
|
|
883
|
+
_objectDeltaTimes = [];
|
|
884
|
+
/**
|
|
885
|
+
* The delta time of hitobjects.
|
|
886
|
+
*/
|
|
887
|
+
get objectDeltaTimes() {
|
|
888
|
+
return this._objectDeltaTimes;
|
|
889
|
+
}
|
|
890
|
+
constructor(mods, overallDifficulty, considerCheesability, strainTimeCap) {
|
|
1105
891
|
super(mods);
|
|
1106
892
|
this.greatWindow = new osuBase.OsuHitWindow(overallDifficulty).hitWindowFor300();
|
|
1107
893
|
this.considerCheesability = considerCheesability;
|
|
894
|
+
this.strainTimeCap = strainTimeCap;
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* The amount of notes that are relevant to the difficulty.
|
|
898
|
+
*/
|
|
899
|
+
relevantNoteCount() {
|
|
900
|
+
if (this._objectStrains.length === 0) {
|
|
901
|
+
return 0;
|
|
902
|
+
}
|
|
903
|
+
const maxStrain = Math.max(...this._objectStrains);
|
|
904
|
+
if (maxStrain === 0) {
|
|
905
|
+
return 0;
|
|
906
|
+
}
|
|
907
|
+
return this._objectStrains.reduce((total, next) => total + 1 / (1 + Math.exp(-((next / maxStrain) * 12 - 6))), 0);
|
|
908
|
+
}
|
|
909
|
+
/**
|
|
910
|
+
* The delta time relevant to the difficulty.
|
|
911
|
+
*/
|
|
912
|
+
relevantDeltaTime() {
|
|
913
|
+
if (this._objectStrains.length === 0) {
|
|
914
|
+
return 0;
|
|
915
|
+
}
|
|
916
|
+
const maxStrain = Math.max(...this._objectStrains);
|
|
917
|
+
if (maxStrain === 0) {
|
|
918
|
+
return 0;
|
|
919
|
+
}
|
|
920
|
+
return (this._objectDeltaTimes.reduce((total, next, index) => total +
|
|
921
|
+
(next * 1) /
|
|
922
|
+
(1 +
|
|
923
|
+
Math.exp(-((this._objectStrains[index] / maxStrain) *
|
|
924
|
+
25 -
|
|
925
|
+
20))), 0) /
|
|
926
|
+
this._objectStrains.reduce((total, next) => total + 1 / (1 + Math.exp(-((next / maxStrain) * 25 - 20))), 0));
|
|
1108
927
|
}
|
|
1109
928
|
strainValueAt(current) {
|
|
1110
929
|
const decay = this.strainDecay(current.strainTime);
|
|
1111
930
|
this.currentTapStrain *= decay;
|
|
1112
931
|
this.currentTapStrain +=
|
|
1113
|
-
DroidTapEvaluator.evaluateDifficultyOf(current, this.greatWindow, this.considerCheesability) * this.skillMultiplier;
|
|
932
|
+
DroidTapEvaluator.evaluateDifficultyOf(current, this.greatWindow, this.considerCheesability, this.strainTimeCap) * this.skillMultiplier;
|
|
1114
933
|
this.currentRhythmMultiplier = current.rhythmMultiplier;
|
|
934
|
+
this._objectDeltaTimes.push(current.deltaTime);
|
|
1115
935
|
return this.currentTapStrain * current.rhythmMultiplier;
|
|
1116
936
|
}
|
|
1117
937
|
calculateInitialStrain(time, current) {
|
|
@@ -1119,10 +939,16 @@ class DroidTap extends DroidSkill {
|
|
|
1119
939
|
this.currentRhythmMultiplier *
|
|
1120
940
|
this.strainDecay(time - (current.previous(0)?.startTime ?? 0)));
|
|
1121
941
|
}
|
|
942
|
+
getObjectStrain() {
|
|
943
|
+
return this.currentTapStrain * this.currentRhythmMultiplier;
|
|
944
|
+
}
|
|
1122
945
|
/**
|
|
1123
946
|
* @param current The hitobject to save to.
|
|
1124
947
|
*/
|
|
1125
948
|
saveToHitObject(current) {
|
|
949
|
+
if (this.strainTimeCap !== undefined) {
|
|
950
|
+
return;
|
|
951
|
+
}
|
|
1126
952
|
const strain = this.currentTapStrain * this.currentRhythmMultiplier;
|
|
1127
953
|
if (this.considerCheesability) {
|
|
1128
954
|
current.tapStrain = strain;
|
|
@@ -1169,7 +995,7 @@ class DroidFlashlightEvaluator extends FlashlightEvaluator {
|
|
|
1169
995
|
current.isOverlapping(true)) {
|
|
1170
996
|
return 0;
|
|
1171
997
|
}
|
|
1172
|
-
const scalingFactor = 52 / current.object.
|
|
998
|
+
const scalingFactor = 52 / current.object.radius;
|
|
1173
999
|
let smallDistNerf = 1;
|
|
1174
1000
|
let cumulativeStrainTime = 0;
|
|
1175
1001
|
let result = 0;
|
|
@@ -1225,8 +1051,8 @@ class DroidFlashlightEvaluator extends FlashlightEvaluator {
|
|
|
1225
1051
|
// Longer sliders require more memorization.
|
|
1226
1052
|
sliderBonus *= pixelTravelDistance;
|
|
1227
1053
|
// Nerf sliders with repeats, as less memorization is required.
|
|
1228
|
-
if (current.object.
|
|
1229
|
-
sliderBonus /= current.object.
|
|
1054
|
+
if (current.object.repeatCount > 0)
|
|
1055
|
+
sliderBonus /= current.object.repeatCount + 1;
|
|
1230
1056
|
}
|
|
1231
1057
|
result += sliderBonus * this.sliderMultiplier;
|
|
1232
1058
|
return result;
|
|
@@ -1260,6 +1086,9 @@ class DroidFlashlight extends DroidSkill {
|
|
|
1260
1086
|
return (this.currentFlashlightStrain *
|
|
1261
1087
|
this.strainDecay(time - (current.previous(0)?.startTime ?? 0)));
|
|
1262
1088
|
}
|
|
1089
|
+
getObjectStrain() {
|
|
1090
|
+
return this.currentFlashlightStrain;
|
|
1091
|
+
}
|
|
1263
1092
|
saveToHitObject(current) {
|
|
1264
1093
|
if (this.withSliders) {
|
|
1265
1094
|
current.flashlightStrainWithSliders = this.currentFlashlightStrain;
|
|
@@ -1440,6 +1269,9 @@ class DroidRhythm extends DroidSkill {
|
|
|
1440
1269
|
return (this.currentRhythmStrain *
|
|
1441
1270
|
this.strainDecay(time - (current.previous(0)?.startTime ?? 0)));
|
|
1442
1271
|
}
|
|
1272
|
+
getObjectStrain() {
|
|
1273
|
+
return this.currentRhythmStrain;
|
|
1274
|
+
}
|
|
1443
1275
|
saveToHitObject(current) {
|
|
1444
1276
|
current.rhythmStrain = this.currentRhythmStrain;
|
|
1445
1277
|
current.rhythmMultiplier = this.currentRhythmMultiplier;
|
|
@@ -1478,109 +1310,286 @@ class DroidVisualEvaluator {
|
|
|
1478
1310
|
if (isHiddenMod) {
|
|
1479
1311
|
strain = Math.min(30, Math.pow(current.noteDensity, 3));
|
|
1480
1312
|
}
|
|
1481
|
-
else {
|
|
1482
|
-
strain = Math.min(20, Math.pow(current.noteDensity, 2));
|
|
1313
|
+
else {
|
|
1314
|
+
strain = Math.min(20, Math.pow(current.noteDensity, 2));
|
|
1315
|
+
}
|
|
1316
|
+
// Bonus based on how visible the object is.
|
|
1317
|
+
for (let i = 0; i < Math.min(current.index, 10); ++i) {
|
|
1318
|
+
const previous = current.previous(i);
|
|
1319
|
+
if (previous.object instanceof osuBase.Spinner ||
|
|
1320
|
+
// Exclude overlapping objects that can be tapped at once.
|
|
1321
|
+
previous.isOverlapping(true)) {
|
|
1322
|
+
continue;
|
|
1323
|
+
}
|
|
1324
|
+
// Do not consider objects that don't fall under time preempt.
|
|
1325
|
+
if (current.object.startTime - previous.object.endTime >
|
|
1326
|
+
current.object.timePreempt) {
|
|
1327
|
+
break;
|
|
1328
|
+
}
|
|
1329
|
+
strain +=
|
|
1330
|
+
(1 -
|
|
1331
|
+
current.opacityAt(previous.object.startTime, isHiddenMod)) /
|
|
1332
|
+
4;
|
|
1333
|
+
}
|
|
1334
|
+
if (current.timePreempt < 400) {
|
|
1335
|
+
// Give bonus for AR higher than 10.33.
|
|
1336
|
+
strain += Math.pow(400 - current.timePreempt, 1.3) / 100;
|
|
1337
|
+
}
|
|
1338
|
+
// Scale the value with overlapping factor.
|
|
1339
|
+
strain /= 10 * (1 + current.overlappingFactor);
|
|
1340
|
+
if (current.object instanceof osuBase.Slider && withSliders) {
|
|
1341
|
+
const scalingFactor = 50 / current.object.radius;
|
|
1342
|
+
// Invert the scaling factor to determine the true travel distance independent of circle size.
|
|
1343
|
+
const pixelTravelDistance = current.object.lazyTravelDistance / scalingFactor;
|
|
1344
|
+
const currentVelocity = pixelTravelDistance / current.travelTime;
|
|
1345
|
+
strain +=
|
|
1346
|
+
// Reward sliders based on velocity, while also avoiding overbuffing extremely fast sliders.
|
|
1347
|
+
Math.min(6, currentVelocity * 1.5) *
|
|
1348
|
+
// Longer sliders require more reading.
|
|
1349
|
+
(pixelTravelDistance / 100);
|
|
1350
|
+
let cumulativeStrainTime = 0;
|
|
1351
|
+
// Reward for velocity changes based on last few sliders.
|
|
1352
|
+
for (let i = 0; i < Math.min(current.index, 4); ++i) {
|
|
1353
|
+
const last = current.previous(i);
|
|
1354
|
+
cumulativeStrainTime += last.strainTime;
|
|
1355
|
+
if (!(last.object instanceof osuBase.Slider) ||
|
|
1356
|
+
// Exclude overlapping objects that can be tapped at once.
|
|
1357
|
+
last.isOverlapping(true)) {
|
|
1358
|
+
continue;
|
|
1359
|
+
}
|
|
1360
|
+
// Invert the scaling factor to determine the true travel distance independent of circle size.
|
|
1361
|
+
const pixelTravelDistance = last.object.lazyTravelDistance / scalingFactor;
|
|
1362
|
+
const lastVelocity = pixelTravelDistance / last.travelTime;
|
|
1363
|
+
strain +=
|
|
1364
|
+
// Reward past sliders based on velocity changes, while also
|
|
1365
|
+
// avoiding overbuffing extremely fast velocity changes.
|
|
1366
|
+
Math.min(10, 2.5 * Math.abs(currentVelocity - lastVelocity)) *
|
|
1367
|
+
// Longer sliders require more reading.
|
|
1368
|
+
(pixelTravelDistance / 125) *
|
|
1369
|
+
// Avoid overbuffing past sliders.
|
|
1370
|
+
Math.min(1, 300 / cumulativeStrainTime);
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
return strain;
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
/**
|
|
1378
|
+
* Represents the skill required to read every object in the map.
|
|
1379
|
+
*/
|
|
1380
|
+
class DroidVisual extends DroidSkill {
|
|
1381
|
+
starsPerDouble = 1.025;
|
|
1382
|
+
reducedSectionCount = 10;
|
|
1383
|
+
reducedSectionBaseline = 0.75;
|
|
1384
|
+
strainDecayBase = 0.1;
|
|
1385
|
+
isHidden;
|
|
1386
|
+
withSliders;
|
|
1387
|
+
currentVisualStrain = 0;
|
|
1388
|
+
currentRhythmMultiplier = 1;
|
|
1389
|
+
skillMultiplier = 10;
|
|
1390
|
+
constructor(mods, withSliders) {
|
|
1391
|
+
super(mods);
|
|
1392
|
+
this.isHidden = mods.some((m) => m instanceof osuBase.ModHidden);
|
|
1393
|
+
this.withSliders = withSliders;
|
|
1394
|
+
}
|
|
1395
|
+
strainValueAt(current) {
|
|
1396
|
+
this.currentVisualStrain *= this.strainDecay(current.deltaTime);
|
|
1397
|
+
this.currentVisualStrain +=
|
|
1398
|
+
DroidVisualEvaluator.evaluateDifficultyOf(current, this.isHidden, this.withSliders) * this.skillMultiplier;
|
|
1399
|
+
this.currentRhythmMultiplier = current.rhythmMultiplier;
|
|
1400
|
+
return this.currentVisualStrain * this.currentRhythmMultiplier;
|
|
1401
|
+
}
|
|
1402
|
+
calculateInitialStrain(time, current) {
|
|
1403
|
+
return (this.currentVisualStrain *
|
|
1404
|
+
this.currentRhythmMultiplier *
|
|
1405
|
+
this.strainDecay(time - (current.previous(0)?.startTime ?? 0)));
|
|
1406
|
+
}
|
|
1407
|
+
getObjectStrain() {
|
|
1408
|
+
return this.currentVisualStrain * this.currentRhythmMultiplier;
|
|
1409
|
+
}
|
|
1410
|
+
saveToHitObject(current) {
|
|
1411
|
+
const strain = this.currentVisualStrain * this.currentRhythmMultiplier;
|
|
1412
|
+
if (this.withSliders) {
|
|
1413
|
+
current.visualStrainWithSliders = strain;
|
|
1414
|
+
}
|
|
1415
|
+
else {
|
|
1416
|
+
current.visualStrainWithoutSliders = strain;
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
/**
|
|
1422
|
+
* Represents an osu!droid hit object with difficulty calculation values.
|
|
1423
|
+
*/
|
|
1424
|
+
class DroidDifficultyHitObject extends DifficultyHitObject {
|
|
1425
|
+
/**
|
|
1426
|
+
* The tap strain generated by the hitobject.
|
|
1427
|
+
*/
|
|
1428
|
+
tapStrain = 0;
|
|
1429
|
+
/**
|
|
1430
|
+
* The tap strain generated by the hitobject if `strainTime` isn't modified by
|
|
1431
|
+
* OD. This is used in three-finger detection.
|
|
1432
|
+
*/
|
|
1433
|
+
originalTapStrain = 0;
|
|
1434
|
+
/**
|
|
1435
|
+
* The rhythm strain generated by the hitobject.
|
|
1436
|
+
*/
|
|
1437
|
+
rhythmStrain = 0;
|
|
1438
|
+
/**
|
|
1439
|
+
* The flashlight strain generated by the hitobject if sliders are considered.
|
|
1440
|
+
*/
|
|
1441
|
+
flashlightStrainWithSliders = 0;
|
|
1442
|
+
/**
|
|
1443
|
+
* The flashlight strain generated by the hitobject if sliders are not considered.
|
|
1444
|
+
*/
|
|
1445
|
+
flashlightStrainWithoutSliders = 0;
|
|
1446
|
+
/**
|
|
1447
|
+
* The visual strain generated by the hitobject if sliders are considered.
|
|
1448
|
+
*/
|
|
1449
|
+
visualStrainWithSliders = 0;
|
|
1450
|
+
/**
|
|
1451
|
+
* The visual strain generated by the hitobject if sliders are not considered.
|
|
1452
|
+
*/
|
|
1453
|
+
visualStrainWithoutSliders = 0;
|
|
1454
|
+
/**
|
|
1455
|
+
* The note density of the hitobject.
|
|
1456
|
+
*/
|
|
1457
|
+
noteDensity = 1;
|
|
1458
|
+
/**
|
|
1459
|
+
* The overlapping factor of the hitobject.
|
|
1460
|
+
*
|
|
1461
|
+
* This is used to scale visual skill.
|
|
1462
|
+
*/
|
|
1463
|
+
overlappingFactor = 0;
|
|
1464
|
+
/**
|
|
1465
|
+
* Adjusted preempt time of the hitobject, taking speed multiplier into account.
|
|
1466
|
+
*/
|
|
1467
|
+
timePreempt;
|
|
1468
|
+
radiusBuffThreshold = 70;
|
|
1469
|
+
mode = osuBase.Modes.droid;
|
|
1470
|
+
maximumSliderRadius = this.normalizedRadius * 2;
|
|
1471
|
+
get scalingFactor() {
|
|
1472
|
+
const radius = this.object.radius;
|
|
1473
|
+
// We will scale distances by this factor, so we can assume a uniform CircleSize among beatmaps.
|
|
1474
|
+
let scalingFactor = this.normalizedRadius / radius;
|
|
1475
|
+
// High circle size (small CS) bonus
|
|
1476
|
+
if (radius < this.radiusBuffThreshold) {
|
|
1477
|
+
scalingFactor *=
|
|
1478
|
+
1 + Math.pow((this.radiusBuffThreshold - radius) / 50, 2);
|
|
1479
|
+
}
|
|
1480
|
+
return scalingFactor;
|
|
1481
|
+
}
|
|
1482
|
+
/**
|
|
1483
|
+
* Note: You **must** call `computeProperties` at some point due to how TypeScript handles
|
|
1484
|
+
* overridden properties (see [this](https://github.com/microsoft/TypeScript/issues/1617) GitHub issue.).
|
|
1485
|
+
*
|
|
1486
|
+
* @param object The underlying hitobject.
|
|
1487
|
+
* @param lastObject The hitobject before this hitobject.
|
|
1488
|
+
* @param lastLastObject The hitobject before the last hitobject.
|
|
1489
|
+
* @param difficultyHitObjects All difficulty hitobjects in the processed beatmap.
|
|
1490
|
+
* @param clockRate The clock rate of the beatmap.
|
|
1491
|
+
* @param isForceAR Whether force AR is enabled.
|
|
1492
|
+
*/
|
|
1493
|
+
constructor(object, lastObject, lastLastObject, difficultyHitObjects, clockRate, isForceAR) {
|
|
1494
|
+
super(object, lastObject, lastLastObject, difficultyHitObjects, clockRate);
|
|
1495
|
+
this.timePreempt = this.object.timePreempt;
|
|
1496
|
+
if (!isForceAR) {
|
|
1497
|
+
this.timePreempt /= clockRate;
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
computeProperties(clockRate, hitObjects) {
|
|
1501
|
+
super.computeProperties(clockRate, hitObjects);
|
|
1502
|
+
this.setVisuals(clockRate, hitObjects);
|
|
1503
|
+
}
|
|
1504
|
+
/**
|
|
1505
|
+
* Determines whether this hitobject is considered overlapping with the hitobject before it.
|
|
1506
|
+
*
|
|
1507
|
+
* Keep in mind that "overlapping" in this case is overlapping to the point where both hitobjects
|
|
1508
|
+
* can be hit with just a single tap in osu!droid.
|
|
1509
|
+
*
|
|
1510
|
+
* @param considerDistance Whether to consider the distance between both hitobjects.
|
|
1511
|
+
* @returns Whether the hitobject is considered overlapping.
|
|
1512
|
+
*/
|
|
1513
|
+
isOverlapping(considerDistance) {
|
|
1514
|
+
if (this.object instanceof osuBase.Spinner) {
|
|
1515
|
+
return false;
|
|
1516
|
+
}
|
|
1517
|
+
const previous = this.previous(0);
|
|
1518
|
+
if (!previous || previous.object instanceof osuBase.Spinner) {
|
|
1519
|
+
return false;
|
|
1520
|
+
}
|
|
1521
|
+
if (this.deltaTime >= 5) {
|
|
1522
|
+
return false;
|
|
1523
|
+
}
|
|
1524
|
+
if (considerDistance) {
|
|
1525
|
+
const endPosition = this.object.getStackedPosition(osuBase.Modes.droid);
|
|
1526
|
+
let distance = previous.object
|
|
1527
|
+
.getStackedEndPosition(osuBase.Modes.droid)
|
|
1528
|
+
.getDistance(endPosition);
|
|
1529
|
+
if (previous.object instanceof osuBase.Slider &&
|
|
1530
|
+
previous.object.lazyEndPosition) {
|
|
1531
|
+
distance = Math.min(distance, previous.object.lazyEndPosition.getDistance(endPosition));
|
|
1532
|
+
}
|
|
1533
|
+
return distance <= 2 * this.object.radius;
|
|
1483
1534
|
}
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1535
|
+
return true;
|
|
1536
|
+
}
|
|
1537
|
+
setVisuals(clockRate, hitObjects) {
|
|
1538
|
+
// We'll have two visible object arrays. The first array contains objects before the current object starts in a reversed order,
|
|
1539
|
+
// while the second array contains objects after the current object ends.
|
|
1540
|
+
// For overlapping factor, we also need to consider previous visible objects.
|
|
1541
|
+
const prevVisibleObjects = [];
|
|
1542
|
+
const nextVisibleObjects = [];
|
|
1543
|
+
for (let j = this.index + 2; j < hitObjects.length; ++j) {
|
|
1544
|
+
const o = hitObjects[j];
|
|
1545
|
+
if (o instanceof osuBase.Spinner) {
|
|
1490
1546
|
continue;
|
|
1491
1547
|
}
|
|
1492
|
-
|
|
1493
|
-
if (current.object.startTime - previous.object.endTime >
|
|
1494
|
-
current.baseTimePreempt) {
|
|
1548
|
+
if (o.startTime / clockRate > this.endTime + this.timePreempt) {
|
|
1495
1549
|
break;
|
|
1496
1550
|
}
|
|
1497
|
-
|
|
1498
|
-
(1 -
|
|
1499
|
-
current.opacityAt(previous.object.startTime, isHiddenMod)) /
|
|
1500
|
-
4;
|
|
1501
|
-
}
|
|
1502
|
-
// Scale the value with overlapping factor.
|
|
1503
|
-
strain /= 10 * (1 + current.overlappingFactor);
|
|
1504
|
-
if (current.timePreempt < 400) {
|
|
1505
|
-
// Give bonus for AR higher than 10.33.
|
|
1506
|
-
strain += Math.pow(400 - current.timePreempt, 1.3) / 100;
|
|
1551
|
+
nextVisibleObjects.push(o);
|
|
1507
1552
|
}
|
|
1508
|
-
|
|
1509
|
-
const
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
let cumulativeStrainTime = 0;
|
|
1519
|
-
// Reward for velocity changes based on last few sliders.
|
|
1520
|
-
for (let i = 0; i < Math.min(current.index, 4); ++i) {
|
|
1521
|
-
const last = current.previous(i);
|
|
1522
|
-
cumulativeStrainTime += last.strainTime;
|
|
1523
|
-
if (!(last.object instanceof osuBase.Slider) ||
|
|
1524
|
-
// Exclude overlapping objects that can be tapped at once.
|
|
1525
|
-
last.isOverlapping(true)) {
|
|
1526
|
-
continue;
|
|
1527
|
-
}
|
|
1528
|
-
// Invert the scaling factor to determine the true travel distance independent of circle size.
|
|
1529
|
-
const pixelTravelDistance = last.object.lazyTravelDistance / scalingFactor;
|
|
1530
|
-
const lastVelocity = pixelTravelDistance / last.travelTime;
|
|
1531
|
-
strain +=
|
|
1532
|
-
// Reward past sliders based on velocity changes, while also
|
|
1533
|
-
// avoiding overbuffing extremely fast velocity changes.
|
|
1534
|
-
Math.min(10, 2.5 * Math.abs(currentVelocity - lastVelocity)) *
|
|
1535
|
-
// Longer sliders require more reading.
|
|
1536
|
-
(pixelTravelDistance / 125) *
|
|
1537
|
-
// Avoid overbuffing past sliders.
|
|
1538
|
-
Math.min(1, 300 / cumulativeStrainTime);
|
|
1553
|
+
for (let j = 0; j < this.index; ++j) {
|
|
1554
|
+
const prev = this.previous(j);
|
|
1555
|
+
if (prev.object instanceof osuBase.Spinner) {
|
|
1556
|
+
continue;
|
|
1557
|
+
}
|
|
1558
|
+
if (prev.startTime >= this.startTime) {
|
|
1559
|
+
continue;
|
|
1560
|
+
}
|
|
1561
|
+
if (prev.startTime < this.startTime - this.timePreempt) {
|
|
1562
|
+
break;
|
|
1539
1563
|
}
|
|
1564
|
+
prevVisibleObjects.push(prev.object);
|
|
1540
1565
|
}
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
*/
|
|
1548
|
-
class DroidVisual extends DroidSkill {
|
|
1549
|
-
starsPerDouble = 1.025;
|
|
1550
|
-
reducedSectionCount = 10;
|
|
1551
|
-
reducedSectionBaseline = 0.75;
|
|
1552
|
-
strainDecayBase = 0.1;
|
|
1553
|
-
isHidden;
|
|
1554
|
-
withSliders;
|
|
1555
|
-
currentVisualStrain = 0;
|
|
1556
|
-
currentRhythmMultiplier = 1;
|
|
1557
|
-
skillMultiplier = 10;
|
|
1558
|
-
constructor(mods, withSliders) {
|
|
1559
|
-
super(mods);
|
|
1560
|
-
this.isHidden = mods.some((m) => m instanceof osuBase.ModHidden);
|
|
1561
|
-
this.withSliders = withSliders;
|
|
1562
|
-
}
|
|
1563
|
-
strainValueAt(current) {
|
|
1564
|
-
this.currentVisualStrain *= this.strainDecay(current.deltaTime);
|
|
1565
|
-
this.currentVisualStrain +=
|
|
1566
|
-
DroidVisualEvaluator.evaluateDifficultyOf(current, this.isHidden, this.withSliders) * this.skillMultiplier;
|
|
1567
|
-
this.currentRhythmMultiplier = current.rhythmMultiplier;
|
|
1568
|
-
return this.currentVisualStrain * this.currentRhythmMultiplier;
|
|
1569
|
-
}
|
|
1570
|
-
calculateInitialStrain(time, current) {
|
|
1571
|
-
return (this.currentVisualStrain *
|
|
1572
|
-
this.currentRhythmMultiplier *
|
|
1573
|
-
this.strainDecay(time - (current.previous(0)?.startTime ?? 0)));
|
|
1574
|
-
}
|
|
1575
|
-
saveToHitObject(current) {
|
|
1576
|
-
const strain = this.currentVisualStrain * this.currentRhythmMultiplier;
|
|
1577
|
-
if (this.withSliders) {
|
|
1578
|
-
current.visualStrainWithSliders = strain;
|
|
1566
|
+
for (const hitObject of prevVisibleObjects) {
|
|
1567
|
+
const distance = this.object
|
|
1568
|
+
.getStackedPosition(this.mode)
|
|
1569
|
+
.getDistance(hitObject.getStackedEndPosition(this.mode));
|
|
1570
|
+
const deltaTime = this.startTime - hitObject.endTime / clockRate;
|
|
1571
|
+
this.applyToOverlappingFactor(distance, deltaTime);
|
|
1579
1572
|
}
|
|
1580
|
-
|
|
1581
|
-
|
|
1573
|
+
for (const hitObject of nextVisibleObjects) {
|
|
1574
|
+
const distance = hitObject
|
|
1575
|
+
.getStackedPosition(this.mode)
|
|
1576
|
+
.getDistance(this.object.getStackedEndPosition(this.mode));
|
|
1577
|
+
const deltaTime = hitObject.startTime / clockRate - this.endTime;
|
|
1578
|
+
if (deltaTime >= 0) {
|
|
1579
|
+
this.noteDensity += 1 - deltaTime / this.timePreempt;
|
|
1580
|
+
}
|
|
1581
|
+
this.applyToOverlappingFactor(distance, deltaTime);
|
|
1582
1582
|
}
|
|
1583
1583
|
}
|
|
1584
|
+
applyToOverlappingFactor(distance, deltaTime) {
|
|
1585
|
+
// Penalize objects that are too close to the object in both distance
|
|
1586
|
+
// and delta time to prevent stream maps from being overweighted.
|
|
1587
|
+
this.overlappingFactor +=
|
|
1588
|
+
Math.max(0, 1 - distance / (3 * this.object.radius)) *
|
|
1589
|
+
(7.5 /
|
|
1590
|
+
(1 +
|
|
1591
|
+
Math.exp(0.15 * (Math.max(deltaTime, this.minDeltaTime) - 75))));
|
|
1592
|
+
}
|
|
1584
1593
|
}
|
|
1585
1594
|
|
|
1586
1595
|
/**
|
|
@@ -1590,23 +1599,33 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
|
1590
1599
|
/**
|
|
1591
1600
|
* The aim star rating of the beatmap.
|
|
1592
1601
|
*/
|
|
1593
|
-
aim
|
|
1602
|
+
get aim() {
|
|
1603
|
+
return this.attributes.aimDifficulty;
|
|
1604
|
+
}
|
|
1594
1605
|
/**
|
|
1595
1606
|
* The tap star rating of the beatmap.
|
|
1596
1607
|
*/
|
|
1597
|
-
tap
|
|
1608
|
+
get tap() {
|
|
1609
|
+
return this.attributes.tapDifficulty;
|
|
1610
|
+
}
|
|
1598
1611
|
/**
|
|
1599
1612
|
* The rhythm star rating of the beatmap.
|
|
1600
1613
|
*/
|
|
1601
|
-
rhythm
|
|
1614
|
+
get rhythm() {
|
|
1615
|
+
return this.attributes.rhythmDifficulty;
|
|
1616
|
+
}
|
|
1602
1617
|
/**
|
|
1603
1618
|
* The flashlight star rating of the beatmap.
|
|
1604
1619
|
*/
|
|
1605
|
-
flashlight
|
|
1620
|
+
get flashlight() {
|
|
1621
|
+
return this.attributes.flashlightDifficulty;
|
|
1622
|
+
}
|
|
1606
1623
|
/**
|
|
1607
1624
|
* The visual star rating of the beatmap.
|
|
1608
1625
|
*/
|
|
1609
|
-
visual
|
|
1626
|
+
get visual() {
|
|
1627
|
+
return this.attributes.visualDifficulty;
|
|
1628
|
+
}
|
|
1610
1629
|
/**
|
|
1611
1630
|
* The strain threshold to start detecting for possible three-fingered section.
|
|
1612
1631
|
*
|
|
@@ -1614,6 +1633,7 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
|
1614
1633
|
*/
|
|
1615
1634
|
static threeFingerStrainThreshold = 175;
|
|
1616
1635
|
attributes = {
|
|
1636
|
+
mode: "rebalance",
|
|
1617
1637
|
tapDifficulty: 0,
|
|
1618
1638
|
rhythmDifficulty: 0,
|
|
1619
1639
|
visualDifficulty: 0,
|
|
@@ -1640,6 +1660,7 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
|
1640
1660
|
possibleThreeFingeredSections: [],
|
|
1641
1661
|
difficultSliders: [],
|
|
1642
1662
|
averageSpeedDeltaTime: 0,
|
|
1663
|
+
vibroFactor: 1,
|
|
1643
1664
|
};
|
|
1644
1665
|
get cacheableAttributes() {
|
|
1645
1666
|
return {
|
|
@@ -1664,6 +1685,7 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
|
1664
1685
|
flashlightDifficultStrainCount: this.attributes.flashlightDifficultStrainCount,
|
|
1665
1686
|
visualDifficultStrainCount: this.attributes.visualDifficultStrainCount,
|
|
1666
1687
|
averageSpeedDeltaTime: this.attributes.averageSpeedDeltaTime,
|
|
1688
|
+
vibroFactor: this.attributes.vibroFactor,
|
|
1667
1689
|
};
|
|
1668
1690
|
}
|
|
1669
1691
|
difficultyMultiplier = 0.18;
|
|
@@ -1681,17 +1703,19 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
|
1681
1703
|
* Calculates the tap star rating of the beatmap and stores it in this instance.
|
|
1682
1704
|
*/
|
|
1683
1705
|
calculateTap() {
|
|
1684
|
-
const od = this.
|
|
1706
|
+
const od = this.difficultyStatistics.overallDifficulty;
|
|
1685
1707
|
const tapSkillCheese = new DroidTap(this.mods, od, true);
|
|
1686
1708
|
const tapSkillNoCheese = new DroidTap(this.mods, od, false);
|
|
1687
1709
|
this.calculateSkills(tapSkillCheese, tapSkillNoCheese);
|
|
1688
|
-
this.
|
|
1710
|
+
const tapSkillVibro = new DroidTap(this.mods, od, true, tapSkillCheese.relevantDeltaTime());
|
|
1711
|
+
this.calculateSkills(tapSkillVibro);
|
|
1712
|
+
this.postCalculateTap(tapSkillCheese, tapSkillVibro);
|
|
1689
1713
|
}
|
|
1690
1714
|
/**
|
|
1691
1715
|
* Calculates the rhythm star rating of the beatmap and stores it in this instance.
|
|
1692
1716
|
*/
|
|
1693
1717
|
calculateRhythm() {
|
|
1694
|
-
const rhythmSkill = new DroidRhythm(this.mods, this.
|
|
1718
|
+
const rhythmSkill = new DroidRhythm(this.mods, this.difficultyStatistics.overallDifficulty);
|
|
1695
1719
|
this.calculateSkills(rhythmSkill);
|
|
1696
1720
|
this.postCalculateRhythm(rhythmSkill);
|
|
1697
1721
|
}
|
|
@@ -1709,7 +1733,7 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
|
1709
1733
|
*/
|
|
1710
1734
|
calculateVisual() {
|
|
1711
1735
|
if (this.mods.some((m) => m instanceof osuBase.ModRelax)) {
|
|
1712
|
-
this.
|
|
1736
|
+
this.attributes.visualDifficulty = 0;
|
|
1713
1737
|
return;
|
|
1714
1738
|
}
|
|
1715
1739
|
const visualSkill = new DroidVisual(this.mods, true);
|
|
@@ -1731,13 +1755,13 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
|
1731
1755
|
if (basePerformanceValue > 1e-5) {
|
|
1732
1756
|
// Document for formula derivation:
|
|
1733
1757
|
// https://docs.google.com/document/d/10DZGYYSsT_yjz2Mtp6yIJld0Rqx4E-vVHupCqiM4TNI/edit
|
|
1734
|
-
this.
|
|
1758
|
+
this.attributes.starRating =
|
|
1735
1759
|
0.027 *
|
|
1736
1760
|
(Math.cbrt((100000 / Math.pow(2, 1 / 1.1)) * basePerformanceValue) +
|
|
1737
1761
|
4);
|
|
1738
1762
|
}
|
|
1739
1763
|
else {
|
|
1740
|
-
this.
|
|
1764
|
+
this.attributes.starRating = 0;
|
|
1741
1765
|
}
|
|
1742
1766
|
}
|
|
1743
1767
|
calculateAll() {
|
|
@@ -1751,8 +1775,10 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
|
1751
1775
|
const flashlightSkillWithoutSliders = skills[6];
|
|
1752
1776
|
const visualSkill = skills[7];
|
|
1753
1777
|
const visualSkillWithoutSliders = skills[8];
|
|
1778
|
+
const tapSkillVibro = new DroidTap(this.mods, this.difficultyStatistics.overallDifficulty, true, tapSkillCheese.relevantDeltaTime());
|
|
1779
|
+
this.calculateSkills(tapSkillVibro);
|
|
1754
1780
|
this.postCalculateAim(aimSkill, aimSkillWithoutSliders);
|
|
1755
|
-
this.postCalculateTap(tapSkillCheese);
|
|
1781
|
+
this.postCalculateTap(tapSkillCheese, tapSkillVibro);
|
|
1756
1782
|
this.postCalculateRhythm(rhythmSkill);
|
|
1757
1783
|
this.postCalculateFlashlight(flashlightSkill, flashlightSkillWithoutSliders);
|
|
1758
1784
|
this.postCalculateVisual(visualSkill, visualSkillWithoutSliders);
|
|
@@ -1772,21 +1798,39 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
|
1772
1798
|
this.visual.toFixed(2) +
|
|
1773
1799
|
" visual)");
|
|
1774
1800
|
}
|
|
1775
|
-
|
|
1776
|
-
const
|
|
1777
|
-
|
|
1778
|
-
|
|
1801
|
+
generateDifficultyHitObjects(beatmap) {
|
|
1802
|
+
const difficultyObjects = [];
|
|
1803
|
+
const { objects } = beatmap.hitObjects;
|
|
1804
|
+
const difficultyAdjustMod = this.mods.find((m) => m instanceof osuBase.ModDifficultyAdjust);
|
|
1805
|
+
for (let i = 0; i < objects.length; ++i) {
|
|
1806
|
+
const difficultyObject = new DroidDifficultyHitObject(objects[i], objects[i - 1] ?? null, objects[i - 2] ?? null, difficultyObjects, this.difficultyStatistics.overallSpeedMultiplier, difficultyAdjustMod?.ar !== undefined);
|
|
1807
|
+
difficultyObject.computeProperties(this.difficultyStatistics.overallSpeedMultiplier, objects);
|
|
1808
|
+
difficultyObjects.push(difficultyObject);
|
|
1779
1809
|
}
|
|
1780
|
-
|
|
1810
|
+
return difficultyObjects;
|
|
1811
|
+
}
|
|
1812
|
+
computeDifficultyStatistics(options) {
|
|
1813
|
+
const { difficulty } = this.beatmap;
|
|
1814
|
+
return osuBase.calculateDroidDifficultyStatistics({
|
|
1815
|
+
circleSize: difficulty.cs,
|
|
1816
|
+
approachRate: difficulty.ar ?? difficulty.od,
|
|
1817
|
+
overallDifficulty: difficulty.od,
|
|
1818
|
+
healthDrain: difficulty.hp,
|
|
1819
|
+
mods: this.mods,
|
|
1820
|
+
customSpeedMultiplier: options?.customSpeedMultiplier,
|
|
1821
|
+
oldStatistics: options?.oldStatistics,
|
|
1822
|
+
});
|
|
1781
1823
|
}
|
|
1782
1824
|
createSkills() {
|
|
1783
|
-
const od = this.
|
|
1825
|
+
const od = this.difficultyStatistics.overallDifficulty;
|
|
1784
1826
|
return [
|
|
1785
1827
|
new DroidAim(this.mods, true),
|
|
1786
1828
|
new DroidAim(this.mods, false),
|
|
1787
1829
|
// Tap skill depends on rhythm skill, so we put it first
|
|
1788
1830
|
new DroidRhythm(this.mods, od),
|
|
1831
|
+
// Cheesability tap
|
|
1789
1832
|
new DroidTap(this.mods, od, true),
|
|
1833
|
+
// Non-cheesability tap
|
|
1790
1834
|
new DroidTap(this.mods, od, false),
|
|
1791
1835
|
new DroidFlashlight(this.mods, true),
|
|
1792
1836
|
new DroidFlashlight(this.mods, false),
|
|
@@ -1803,29 +1847,26 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
|
1803
1847
|
postCalculateAim(aimSkill, aimSkillWithoutSliders) {
|
|
1804
1848
|
this.strainPeaks.aimWithSliders = aimSkill.strainPeaks;
|
|
1805
1849
|
this.strainPeaks.aimWithoutSliders = aimSkillWithoutSliders.strainPeaks;
|
|
1806
|
-
this.
|
|
1850
|
+
this.attributes.aimDifficulty = this.starValue(aimSkill.difficultyValue());
|
|
1807
1851
|
if (this.aim) {
|
|
1808
1852
|
this.attributes.sliderFactor =
|
|
1809
1853
|
this.starValue(aimSkillWithoutSliders.difficultyValue()) /
|
|
1810
1854
|
this.aim;
|
|
1811
1855
|
}
|
|
1812
1856
|
if (this.mods.some((m) => m instanceof osuBase.ModRelax)) {
|
|
1813
|
-
this.
|
|
1857
|
+
this.attributes.aimDifficulty *= 0.9;
|
|
1814
1858
|
}
|
|
1815
|
-
this.attributes.
|
|
1859
|
+
this.attributes.aimDifficultStrainCount =
|
|
1860
|
+
aimSkill.countDifficultStrains();
|
|
1816
1861
|
this.calculateAimAttributes();
|
|
1817
1862
|
}
|
|
1818
1863
|
/**
|
|
1819
1864
|
* Calculates aim-related attributes.
|
|
1820
1865
|
*/
|
|
1821
1866
|
calculateAimAttributes() {
|
|
1822
|
-
const objectStrains = [];
|
|
1823
|
-
let maxStrain = 0;
|
|
1824
1867
|
const topDifficultSliders = [];
|
|
1825
1868
|
for (let i = 0; i < this.objects.length; ++i) {
|
|
1826
1869
|
const object = this.objects[i];
|
|
1827
|
-
objectStrains.push(object.aimStrainWithSliders);
|
|
1828
|
-
maxStrain = Math.max(maxStrain, object.aimStrainWithSliders);
|
|
1829
1870
|
const velocity = object.travelDistance / object.travelTime;
|
|
1830
1871
|
if (velocity > 0) {
|
|
1831
1872
|
topDifficultSliders.push({
|
|
@@ -1834,10 +1875,6 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
|
1834
1875
|
});
|
|
1835
1876
|
}
|
|
1836
1877
|
}
|
|
1837
|
-
if (maxStrain) {
|
|
1838
|
-
this.attributes.aimNoteCount = objectStrains.reduce((total, next) => total + 1 / (1 + Math.exp(-((next / maxStrain) * 12 - 6))), 0);
|
|
1839
|
-
this.attributes.aimDifficultStrainCount = objectStrains.reduce((total, next) => total + Math.pow(next / maxStrain, 4), 0);
|
|
1840
|
-
}
|
|
1841
1878
|
const velocitySum = topDifficultSliders.reduce((a, v) => a + v.velocity, 0);
|
|
1842
1879
|
for (const slider of topDifficultSliders) {
|
|
1843
1880
|
const difficultyRating = slider.velocity / velocitySum;
|
|
@@ -1860,16 +1897,22 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
|
1860
1897
|
* Called after tap skill calculation.
|
|
1861
1898
|
*
|
|
1862
1899
|
* @param tapSkillCheese The tap skill that considers cheesing.
|
|
1900
|
+
* @param tapSkillVibro The tap skill that considers vibro.
|
|
1863
1901
|
*/
|
|
1864
|
-
postCalculateTap(tapSkillCheese) {
|
|
1902
|
+
postCalculateTap(tapSkillCheese, tapSkillVibro) {
|
|
1865
1903
|
this.strainPeaks.speed = tapSkillCheese.strainPeaks;
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
this.
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
}
|
|
1904
|
+
this.attributes.tapDifficulty = this.mods.some((m) => m instanceof osuBase.ModRelax)
|
|
1905
|
+
? 0
|
|
1906
|
+
: this.starValue(tapSkillCheese.difficultyValue());
|
|
1907
|
+
if (this.tap) {
|
|
1908
|
+
this.attributes.vibroFactor =
|
|
1909
|
+
this.starValue(tapSkillVibro.difficultyValue()) / this.tap;
|
|
1910
|
+
}
|
|
1911
|
+
this.attributes.speedNoteCount = tapSkillCheese.relevantNoteCount();
|
|
1912
|
+
this.attributes.averageSpeedDeltaTime =
|
|
1913
|
+
tapSkillCheese.relevantDeltaTime();
|
|
1914
|
+
this.attributes.tapDifficultStrainCount =
|
|
1915
|
+
tapSkillCheese.countDifficultStrains();
|
|
1873
1916
|
this.calculateTapAttributes();
|
|
1874
1917
|
}
|
|
1875
1918
|
/**
|
|
@@ -1877,110 +1920,46 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
|
1877
1920
|
*/
|
|
1878
1921
|
calculateTapAttributes() {
|
|
1879
1922
|
this.attributes.possibleThreeFingeredSections = [];
|
|
1880
|
-
const
|
|
1881
|
-
const objectStrains = [];
|
|
1882
|
-
const objectDeltaTimes = [];
|
|
1883
|
-
let maxStrain = 0;
|
|
1884
|
-
const maxSectionDeltaTime = 2000;
|
|
1923
|
+
const { threeFingerStrainThreshold } = DroidDifficultyCalculator;
|
|
1885
1924
|
const minSectionObjectCount = 5;
|
|
1886
|
-
let
|
|
1887
|
-
|
|
1925
|
+
let inSpeedSection = false;
|
|
1926
|
+
let firstSpeedObjectIndex = 0;
|
|
1927
|
+
for (let i = 2; i < this.objects.length; ++i) {
|
|
1888
1928
|
const current = this.objects[i];
|
|
1889
|
-
const
|
|
1890
|
-
if (
|
|
1891
|
-
|
|
1892
|
-
|
|
1929
|
+
const prev = this.objects[i - 1];
|
|
1930
|
+
if (!inSpeedSection &&
|
|
1931
|
+
current.originalTapStrain >= threeFingerStrainThreshold) {
|
|
1932
|
+
inSpeedSection = true;
|
|
1933
|
+
firstSpeedObjectIndex = i;
|
|
1934
|
+
continue;
|
|
1893
1935
|
}
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
if (
|
|
1936
|
+
const currentDelta = current.deltaTime;
|
|
1937
|
+
const prevDelta = prev.deltaTime;
|
|
1938
|
+
const deltaRatio = Math.min(prevDelta, currentDelta) /
|
|
1939
|
+
Math.max(prevDelta, currentDelta);
|
|
1940
|
+
if (inSpeedSection &&
|
|
1941
|
+
(current.originalTapStrain < threeFingerStrainThreshold ||
|
|
1942
|
+
// Stop speed section on slowing down 1/2 rhythm change or anything slower.
|
|
1943
|
+
(prevDelta < currentDelta && deltaRatio <= 0.5) ||
|
|
1944
|
+
// Don't forget to manually add the last section, which would otherwise be ignored.
|
|
1945
|
+
i === this.objects.length - 1)) {
|
|
1946
|
+
const lastSpeedObjectIndex = i - (i === this.objects.length - 1 ? 0 : 1);
|
|
1947
|
+
inSpeedSection = false;
|
|
1899
1948
|
// Ignore sections that don't meet object count requirement.
|
|
1900
|
-
if (i -
|
|
1901
|
-
firstObjectIndex = i + 1;
|
|
1902
|
-
continue;
|
|
1903
|
-
}
|
|
1904
|
-
tempSections.push({
|
|
1905
|
-
firstObjectIndex,
|
|
1906
|
-
lastObjectIndex: i,
|
|
1907
|
-
});
|
|
1908
|
-
firstObjectIndex = i + 1;
|
|
1909
|
-
}
|
|
1910
|
-
}
|
|
1911
|
-
// Don't forget to manually add the last beatmap section, which would otherwise be ignored.
|
|
1912
|
-
if (this.objects.length - firstObjectIndex > minSectionObjectCount) {
|
|
1913
|
-
tempSections.push({
|
|
1914
|
-
firstObjectIndex,
|
|
1915
|
-
lastObjectIndex: this.objects.length - 1,
|
|
1916
|
-
});
|
|
1917
|
-
}
|
|
1918
|
-
// Refilter with tap strain in mind.
|
|
1919
|
-
const { threeFingerStrainThreshold } = DroidDifficultyCalculator;
|
|
1920
|
-
for (const section of tempSections) {
|
|
1921
|
-
let inSpeedSection = false;
|
|
1922
|
-
let newFirstObjectIndex = section.firstObjectIndex;
|
|
1923
|
-
for (let i = section.firstObjectIndex; i <= section.lastObjectIndex; ++i) {
|
|
1924
|
-
const current = this.objects[i];
|
|
1925
|
-
if (!inSpeedSection &&
|
|
1926
|
-
current.originalTapStrain >= threeFingerStrainThreshold) {
|
|
1927
|
-
inSpeedSection = true;
|
|
1928
|
-
newFirstObjectIndex = i;
|
|
1949
|
+
if (i - firstSpeedObjectIndex < minSectionObjectCount) {
|
|
1929
1950
|
continue;
|
|
1930
1951
|
}
|
|
1931
|
-
if (inSpeedSection &&
|
|
1932
|
-
current.originalTapStrain < threeFingerStrainThreshold) {
|
|
1933
|
-
inSpeedSection = false;
|
|
1934
|
-
// Ignore sections that don't meet object count requirement.
|
|
1935
|
-
if (i - newFirstObjectIndex < minSectionObjectCount) {
|
|
1936
|
-
continue;
|
|
1937
|
-
}
|
|
1938
|
-
this.attributes.possibleThreeFingeredSections.push({
|
|
1939
|
-
firstObjectIndex: newFirstObjectIndex,
|
|
1940
|
-
lastObjectIndex: i,
|
|
1941
|
-
sumStrain: this.calculateThreeFingerSummedStrain(newFirstObjectIndex, i),
|
|
1942
|
-
});
|
|
1943
|
-
}
|
|
1944
|
-
}
|
|
1945
|
-
// Don't forget to manually add the last beatmap section, which would otherwise be ignored.
|
|
1946
|
-
// Ignore sections that don't meet object count requirement.
|
|
1947
|
-
if (inSpeedSection &&
|
|
1948
|
-
section.lastObjectIndex - newFirstObjectIndex >=
|
|
1949
|
-
minSectionObjectCount) {
|
|
1950
1952
|
this.attributes.possibleThreeFingeredSections.push({
|
|
1951
|
-
firstObjectIndex:
|
|
1952
|
-
lastObjectIndex:
|
|
1953
|
-
sumStrain:
|
|
1953
|
+
firstObjectIndex: firstSpeedObjectIndex,
|
|
1954
|
+
lastObjectIndex: lastSpeedObjectIndex,
|
|
1955
|
+
sumStrain: Math.pow(this.objects
|
|
1956
|
+
.slice(firstSpeedObjectIndex, lastSpeedObjectIndex + 1)
|
|
1957
|
+
.reduce((a, v) => a +
|
|
1958
|
+
v.originalTapStrain /
|
|
1959
|
+
threeFingerStrainThreshold, 0), 0.75),
|
|
1954
1960
|
});
|
|
1955
1961
|
}
|
|
1956
1962
|
}
|
|
1957
|
-
if (maxStrain) {
|
|
1958
|
-
this.attributes.speedNoteCount = objectStrains.reduce((total, next) => total + 1 / (1 + Math.exp(-((next / maxStrain) * 12 - 6))), 0);
|
|
1959
|
-
this.attributes.averageSpeedDeltaTime =
|
|
1960
|
-
objectDeltaTimes.reduce((total, next, index) => total +
|
|
1961
|
-
(next * 1) /
|
|
1962
|
-
(1 +
|
|
1963
|
-
Math.exp(-((objectStrains[index] / maxStrain) *
|
|
1964
|
-
25 -
|
|
1965
|
-
20))), 0) /
|
|
1966
|
-
objectStrains.reduce((total, next) => total +
|
|
1967
|
-
1 / (1 + Math.exp(-((next / maxStrain) * 25 - 20))), 0);
|
|
1968
|
-
this.attributes.tapDifficultStrainCount = objectStrains.reduce((total, next) => total + Math.pow(next / maxStrain, 4), 0);
|
|
1969
|
-
}
|
|
1970
|
-
}
|
|
1971
|
-
/**
|
|
1972
|
-
* Calculates the sum of strains for possible three-fingered sections.
|
|
1973
|
-
*
|
|
1974
|
-
* @param firstObjectIndex The index of the first object in the section.
|
|
1975
|
-
* @param lastObjectIndex The index of the last object in the section.
|
|
1976
|
-
* @returns The summed strain of the section.
|
|
1977
|
-
*/
|
|
1978
|
-
calculateThreeFingerSummedStrain(firstObjectIndex, lastObjectIndex) {
|
|
1979
|
-
return Math.pow(this.objects
|
|
1980
|
-
.slice(firstObjectIndex, lastObjectIndex)
|
|
1981
|
-
.reduce((a, v) => a +
|
|
1982
|
-
v.originalTapStrain /
|
|
1983
|
-
DroidDifficultyCalculator.threeFingerStrainThreshold, 0), 0.75);
|
|
1984
1963
|
}
|
|
1985
1964
|
/**
|
|
1986
1965
|
* Called after rhythm skill calculation.
|
|
@@ -1988,7 +1967,7 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
|
1988
1967
|
* @param rhythmSkill The rhythm skill.
|
|
1989
1968
|
*/
|
|
1990
1969
|
postCalculateRhythm(rhythmSkill) {
|
|
1991
|
-
this.
|
|
1970
|
+
this.attributes.rhythmDifficulty = this.mods.some((m) => m instanceof osuBase.ModRelax)
|
|
1992
1971
|
? 0
|
|
1993
1972
|
: this.starValue(rhythmSkill.difficultyValue());
|
|
1994
1973
|
}
|
|
@@ -2000,21 +1979,17 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
|
2000
1979
|
*/
|
|
2001
1980
|
postCalculateFlashlight(flashlightSkill, flashlightSkillWithoutSliders) {
|
|
2002
1981
|
this.strainPeaks.flashlight = flashlightSkill.strainPeaks;
|
|
2003
|
-
this.
|
|
1982
|
+
this.attributes.flashlightDifficulty = this.starValue(flashlightSkill.difficultyValue());
|
|
2004
1983
|
if (this.flashlight) {
|
|
2005
1984
|
this.attributes.flashlightSliderFactor =
|
|
2006
1985
|
this.starValue(flashlightSkillWithoutSliders.difficultyValue()) / this.flashlight;
|
|
2007
1986
|
}
|
|
2008
1987
|
if (this.mods.some((m) => m instanceof osuBase.ModRelax)) {
|
|
2009
|
-
this.
|
|
2010
|
-
}
|
|
2011
|
-
const objectStrains = this.objects.map((v) => v.flashlightStrainWithSliders);
|
|
2012
|
-
const maxStrain = Math.max(...objectStrains);
|
|
2013
|
-
if (maxStrain) {
|
|
2014
|
-
this.attributes.flashlightDifficultStrainCount =
|
|
2015
|
-
objectStrains.reduce((total, next) => total + Math.pow(next / maxStrain, 4), 0);
|
|
1988
|
+
this.attributes.flashlightDifficulty *= 0.7;
|
|
2016
1989
|
}
|
|
2017
1990
|
this.attributes.flashlightDifficulty = this.flashlight;
|
|
1991
|
+
this.attributes.flashlightDifficultStrainCount =
|
|
1992
|
+
flashlightSkill.countDifficultStrains();
|
|
2018
1993
|
}
|
|
2019
1994
|
/**
|
|
2020
1995
|
* Called after visual skill calculation.
|
|
@@ -2023,7 +1998,7 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
|
2023
1998
|
* @param visualSkillWithoutSliders The visual skill that doesn't consider sliders.
|
|
2024
1999
|
*/
|
|
2025
2000
|
postCalculateVisual(visualSkillWithSliders, visualSkillWithoutSliders) {
|
|
2026
|
-
this.
|
|
2001
|
+
this.attributes.visualDifficulty = this.mods.some((m) => m instanceof osuBase.ModRelax)
|
|
2027
2002
|
? 0
|
|
2028
2003
|
: this.starValue(visualSkillWithSliders.difficultyValue());
|
|
2029
2004
|
if (this.visual) {
|
|
@@ -2031,11 +2006,8 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
|
2031
2006
|
this.starValue(visualSkillWithoutSliders.difficultyValue()) /
|
|
2032
2007
|
this.visual;
|
|
2033
2008
|
}
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
if (maxStrain) {
|
|
2037
|
-
this.attributes.visualDifficultStrainCount = objectStrains.reduce((total, next) => total + Math.pow(next / maxStrain, 4), 0);
|
|
2038
|
-
}
|
|
2009
|
+
this.attributes.visualDifficultStrainCount =
|
|
2010
|
+
visualSkillWithSliders.countDifficultStrains();
|
|
2039
2011
|
}
|
|
2040
2012
|
}
|
|
2041
2013
|
|
|
@@ -2402,7 +2374,7 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
|
|
|
2402
2374
|
*/
|
|
2403
2375
|
calculateAimValue() {
|
|
2404
2376
|
let aimValue = this.baseValue(Math.pow(this.difficultyAttributes.aimDifficulty, 0.8));
|
|
2405
|
-
aimValue *= this.proportionalMissPenalty;
|
|
2377
|
+
aimValue *= Math.min(this.calculateStrainBasedMissPenalty(this.difficultyAttributes.aimDifficultStrainCount), this.proportionalMissPenalty);
|
|
2406
2378
|
// Scale the aim value with estimated full combo deviation.
|
|
2407
2379
|
aimValue *= this.calculateDeviationBasedLengthScaling();
|
|
2408
2380
|
// Scale the aim value with slider factor to nerf very likely dropped sliderends.
|
|
@@ -2432,16 +2404,26 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
|
|
|
2432
2404
|
// We expect the player to get 7500/x deviation when doubletapping x BPM.
|
|
2433
2405
|
// Using this expectation, we penalize scores with deviation above 25.
|
|
2434
2406
|
const averageBPM = 60000 / 4 / this.difficultyAttributes.averageSpeedDeltaTime;
|
|
2407
|
+
const adjustedDeviation = normalizedDeviation *
|
|
2408
|
+
(1 +
|
|
2409
|
+
1 /
|
|
2410
|
+
(1 +
|
|
2411
|
+
Math.exp(-(normalizedDeviation - 7500 / averageBPM) /
|
|
2412
|
+
((2 * 300) / averageBPM))));
|
|
2435
2413
|
// Scale the tap value with tap deviation.
|
|
2436
2414
|
tapValue *=
|
|
2437
2415
|
1.1 *
|
|
2438
|
-
Math.pow(osuBase.ErrorFunction.erf(20 / (Math.SQRT2 *
|
|
2439
|
-
//
|
|
2416
|
+
Math.pow(osuBase.ErrorFunction.erf(20 / (Math.SQRT2 * adjustedDeviation)), 0.625);
|
|
2417
|
+
// Additional scaling for tap value based on average BPM and how "vibroable" the beatmap is.
|
|
2418
|
+
// Higher BPMs require more precise tapping. When the deviation is too high,
|
|
2419
|
+
// it can be assumed that the player taps invariant to rhythm.
|
|
2420
|
+
// We harshen the punishment for such scenario.
|
|
2440
2421
|
tapValue *=
|
|
2441
|
-
1 /
|
|
2422
|
+
(1 - Math.pow(this.difficultyAttributes.vibroFactor, 6)) /
|
|
2442
2423
|
(1 +
|
|
2443
|
-
Math.exp((this.
|
|
2444
|
-
((
|
|
2424
|
+
Math.exp((this._tapDeviation - 7500 / averageBPM) /
|
|
2425
|
+
((2 * 300) / averageBPM))) +
|
|
2426
|
+
Math.pow(this.difficultyAttributes.vibroFactor, 6);
|
|
2445
2427
|
// Scale the tap value with three-fingered penalty.
|
|
2446
2428
|
tapValue /= this._tapPenalty;
|
|
2447
2429
|
// OD 8 SS stays the same.
|
|
@@ -2482,7 +2464,7 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
|
|
|
2482
2464
|
return 0;
|
|
2483
2465
|
}
|
|
2484
2466
|
let flashlightValue = Math.pow(this.difficultyAttributes.flashlightDifficulty, 1.6) * 25;
|
|
2485
|
-
flashlightValue *= this.proportionalMissPenalty;
|
|
2467
|
+
flashlightValue *= Math.min(this.calculateStrainBasedMissPenalty(this.difficultyAttributes.flashlightDifficultStrainCount), this.proportionalMissPenalty);
|
|
2486
2468
|
// Account for shorter maps having a higher ratio of 0 combo/100 combo flashlight radius.
|
|
2487
2469
|
flashlightValue *=
|
|
2488
2470
|
0.7 +
|
|
@@ -2501,7 +2483,7 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
|
|
|
2501
2483
|
*/
|
|
2502
2484
|
calculateVisualValue() {
|
|
2503
2485
|
let visualValue = Math.pow(this.difficultyAttributes.visualDifficulty, 1.6) * 22.5;
|
|
2504
|
-
visualValue *= this.proportionalMissPenalty;
|
|
2486
|
+
visualValue *= Math.min(this.calculateStrainBasedMissPenalty(this.difficultyAttributes.visualDifficultStrainCount), this.proportionalMissPenalty);
|
|
2505
2487
|
// Scale the visual value with estimated full combo deviation.
|
|
2506
2488
|
// As visual is easily "bypassable" with memorization, punish for memorization.
|
|
2507
2489
|
visualValue *= this.calculateDeviationBasedLengthScaling(undefined, true);
|
|
@@ -2665,23 +2647,59 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
|
|
|
2665
2647
|
if (this.totalSuccessfulHits === 0) {
|
|
2666
2648
|
return Number.POSITIVE_INFINITY;
|
|
2667
2649
|
}
|
|
2668
|
-
const
|
|
2650
|
+
const { speedNoteCount, clockRate, overallDifficulty } = this.difficultyAttributes;
|
|
2651
|
+
const hitWindow300 = new osuBase.OsuHitWindow(overallDifficulty).hitWindowFor300();
|
|
2652
|
+
// Obtain the 50 and 100 hit window for droid.
|
|
2653
|
+
const isPrecise = this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModPrecise);
|
|
2654
|
+
const droidHitWindow = new osuBase.DroidHitWindow(osuBase.DroidHitWindow.hitWindow300ToOD(hitWindow300 * clockRate, isPrecise));
|
|
2655
|
+
const hitWindow50 = droidHitWindow.hitWindowFor50(isPrecise) / clockRate;
|
|
2656
|
+
const hitWindow100 = droidHitWindow.hitWindowFor100(isPrecise) / clockRate;
|
|
2669
2657
|
const { n100, n50, nmiss } = this.computedAccuracy;
|
|
2670
2658
|
// Assume a fixed ratio of non-300s hit in speed notes based on speed note count ratio and OD.
|
|
2671
2659
|
// Graph: https://www.desmos.com/calculator/iskvgjkxr4
|
|
2672
|
-
const speedNoteRatio =
|
|
2660
|
+
const speedNoteRatio = speedNoteCount / this.totalHits;
|
|
2673
2661
|
const nonGreatCount = n100 + n50 + nmiss;
|
|
2674
2662
|
const nonGreatRatio = 1 -
|
|
2675
2663
|
(Math.pow(Math.exp(Math.sqrt(hitWindow300)) + 1, 1 - speedNoteRatio) -
|
|
2676
2664
|
1) /
|
|
2677
2665
|
Math.exp(Math.sqrt(hitWindow300));
|
|
2678
|
-
const relevantCountGreat = Math.max(0,
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2666
|
+
const relevantCountGreat = Math.max(0, speedNoteCount - nonGreatCount * nonGreatRatio);
|
|
2667
|
+
const relevantCountOk = n100 * nonGreatRatio;
|
|
2668
|
+
const relevantCountMeh = n50 * nonGreatRatio;
|
|
2669
|
+
const relevantCountMiss = nmiss * nonGreatRatio;
|
|
2670
|
+
// Assume 100s, 50s, and misses happen on circles. If there are less non-300s on circles than 300s,
|
|
2671
|
+
// compute the deviation on circles.
|
|
2672
|
+
if (relevantCountGreat > 0) {
|
|
2673
|
+
// The probability that a player hits a circle is unknown, but we can estimate it to be
|
|
2674
|
+
// the number of greats on circles divided by the number of circles, and then add one
|
|
2675
|
+
// to the number of circles as a bias correction.
|
|
2676
|
+
const greatProbabilityCircle = relevantCountGreat /
|
|
2677
|
+
(speedNoteCount - relevantCountMiss - relevantCountMeh + 1);
|
|
2678
|
+
// Compute the deviation assuming 300s and 100s are normally distributed, and 50s are uniformly distributed.
|
|
2679
|
+
// Begin with the normal distribution first.
|
|
2680
|
+
let deviationOnCircles = hitWindow300 /
|
|
2681
|
+
(Math.SQRT2 * osuBase.ErrorFunction.erfInv(greatProbabilityCircle));
|
|
2682
|
+
deviationOnCircles *= Math.sqrt(1 -
|
|
2683
|
+
(Math.sqrt(2 / Math.PI) *
|
|
2684
|
+
hitWindow100 *
|
|
2685
|
+
Math.exp(-0.5 *
|
|
2686
|
+
Math.pow(hitWindow100 / deviationOnCircles, 2))) /
|
|
2687
|
+
(deviationOnCircles *
|
|
2688
|
+
osuBase.ErrorFunction.erf(hitWindow100 /
|
|
2689
|
+
(Math.SQRT2 * deviationOnCircles))));
|
|
2690
|
+
// Then compute the variance for 50s.
|
|
2691
|
+
const mehVariance = (hitWindow50 * hitWindow50 +
|
|
2692
|
+
hitWindow100 * hitWindow50 +
|
|
2693
|
+
hitWindow100 * hitWindow100) /
|
|
2694
|
+
3;
|
|
2695
|
+
// Find the total deviation.
|
|
2696
|
+
deviationOnCircles = Math.sqrt(((relevantCountGreat + relevantCountOk) *
|
|
2697
|
+
Math.pow(deviationOnCircles, 2) +
|
|
2698
|
+
relevantCountMeh * mehVariance) /
|
|
2699
|
+
(relevantCountGreat + relevantCountOk + relevantCountMeh));
|
|
2700
|
+
return deviationOnCircles;
|
|
2682
2701
|
}
|
|
2683
|
-
|
|
2684
|
-
return (hitWindow300 / (Math.SQRT2 * osuBase.ErrorFunction.erfInv(greatProbability)));
|
|
2702
|
+
return Number.POSITIVE_INFINITY;
|
|
2685
2703
|
}
|
|
2686
2704
|
toString() {
|
|
2687
2705
|
return (this.total.toFixed(2) +
|
|
@@ -3079,9 +3097,9 @@ class OsuSpeed extends OsuSkill {
|
|
|
3079
3097
|
currentRhythm = 0;
|
|
3080
3098
|
skillMultiplier = 1375;
|
|
3081
3099
|
greatWindow;
|
|
3082
|
-
constructor(mods,
|
|
3100
|
+
constructor(mods, overallDifficulty) {
|
|
3083
3101
|
super(mods);
|
|
3084
|
-
this.greatWindow =
|
|
3102
|
+
this.greatWindow = new osuBase.OsuHitWindow(overallDifficulty).hitWindowFor300();
|
|
3085
3103
|
}
|
|
3086
3104
|
/**
|
|
3087
3105
|
* @param current The hitobject to calculate.
|
|
@@ -3128,7 +3146,7 @@ class OsuFlashlightEvaluator extends FlashlightEvaluator {
|
|
|
3128
3146
|
if (current.object instanceof osuBase.Spinner) {
|
|
3129
3147
|
return 0;
|
|
3130
3148
|
}
|
|
3131
|
-
const scalingFactor = 52 / current.object.
|
|
3149
|
+
const scalingFactor = 52 / current.object.radius;
|
|
3132
3150
|
let smallDistNerf = 1;
|
|
3133
3151
|
let cumulativeStrainTime = 0;
|
|
3134
3152
|
let result = 0;
|
|
@@ -3182,8 +3200,8 @@ class OsuFlashlightEvaluator extends FlashlightEvaluator {
|
|
|
3182
3200
|
// Longer sliders require more memorization.
|
|
3183
3201
|
sliderBonus *= pixelTravelDistance;
|
|
3184
3202
|
// Nerf sliders with repeats, as less memorization is required.
|
|
3185
|
-
if (current.object.
|
|
3186
|
-
sliderBonus /= current.object.
|
|
3203
|
+
if (current.object.repeatCount > 0)
|
|
3204
|
+
sliderBonus /= current.object.repeatCount + 1;
|
|
3187
3205
|
}
|
|
3188
3206
|
result += sliderBonus * this.sliderMultiplier;
|
|
3189
3207
|
return result;
|
|
@@ -3220,6 +3238,46 @@ class OsuFlashlight extends OsuSkill {
|
|
|
3220
3238
|
}
|
|
3221
3239
|
}
|
|
3222
3240
|
|
|
3241
|
+
/**
|
|
3242
|
+
* Represents an osu!standard hit object with difficulty calculation values.
|
|
3243
|
+
*/
|
|
3244
|
+
class OsuDifficultyHitObject extends DifficultyHitObject {
|
|
3245
|
+
/**
|
|
3246
|
+
* The speed strain generated by the hitobject.
|
|
3247
|
+
*/
|
|
3248
|
+
speedStrain = 0;
|
|
3249
|
+
/**
|
|
3250
|
+
* The flashlight strain generated by this hitobject.
|
|
3251
|
+
*/
|
|
3252
|
+
flashlightStrain = 0;
|
|
3253
|
+
radiusBuffThreshold = 30;
|
|
3254
|
+
mode = osuBase.Modes.osu;
|
|
3255
|
+
get scalingFactor() {
|
|
3256
|
+
const radius = this.object.radius;
|
|
3257
|
+
// We will scale distances by this factor, so we can assume a uniform CircleSize among beatmaps.
|
|
3258
|
+
let scalingFactor = this.normalizedRadius / radius;
|
|
3259
|
+
// High circle size (small CS) bonus
|
|
3260
|
+
if (radius < this.radiusBuffThreshold) {
|
|
3261
|
+
scalingFactor *=
|
|
3262
|
+
1 + Math.min(this.radiusBuffThreshold - radius, 5) / 50;
|
|
3263
|
+
}
|
|
3264
|
+
return scalingFactor;
|
|
3265
|
+
}
|
|
3266
|
+
/**
|
|
3267
|
+
* Note: You **must** call `computeProperties` at some point due to how TypeScript handles
|
|
3268
|
+
* overridden properties (see [this](https://github.com/microsoft/TypeScript/issues/1617) GitHub issue.).
|
|
3269
|
+
*
|
|
3270
|
+
* @param object The underlying hitobject.
|
|
3271
|
+
* @param lastObject The hitobject before this hitobject.
|
|
3272
|
+
* @param lastLastObject The hitobject before the last hitobject.
|
|
3273
|
+
* @param difficultyHitObjects All difficulty hitobjects in the processed beatmap.
|
|
3274
|
+
* @param clockRate The clock rate of the beatmap.
|
|
3275
|
+
*/
|
|
3276
|
+
constructor(object, lastObject, lastLastObject, difficultyHitObjects, clockRate) {
|
|
3277
|
+
super(object, lastObject, lastLastObject, difficultyHitObjects, clockRate);
|
|
3278
|
+
}
|
|
3279
|
+
}
|
|
3280
|
+
|
|
3223
3281
|
/**
|
|
3224
3282
|
* A difficulty calculator for osu!standard gamemode.
|
|
3225
3283
|
*/
|
|
@@ -3227,15 +3285,21 @@ class OsuDifficultyCalculator extends DifficultyCalculator {
|
|
|
3227
3285
|
/**
|
|
3228
3286
|
* The aim star rating of the beatmap.
|
|
3229
3287
|
*/
|
|
3230
|
-
aim
|
|
3288
|
+
get aim() {
|
|
3289
|
+
return this.attributes.aimDifficulty;
|
|
3290
|
+
}
|
|
3231
3291
|
/**
|
|
3232
3292
|
* The speed star rating of the beatmap.
|
|
3233
3293
|
*/
|
|
3234
|
-
speed
|
|
3294
|
+
get speed() {
|
|
3295
|
+
return this.attributes.speedDifficulty;
|
|
3296
|
+
}
|
|
3235
3297
|
/**
|
|
3236
3298
|
* The flashlight star rating of the beatmap.
|
|
3237
3299
|
*/
|
|
3238
|
-
flashlight
|
|
3300
|
+
get flashlight() {
|
|
3301
|
+
return this.attributes.flashlightDifficulty;
|
|
3302
|
+
}
|
|
3239
3303
|
attributes = {
|
|
3240
3304
|
speedDifficulty: 0,
|
|
3241
3305
|
mods: [],
|
|
@@ -3273,7 +3337,7 @@ class OsuDifficultyCalculator extends DifficultyCalculator {
|
|
|
3273
3337
|
* Calculates the speed star rating of the beatmap and stores it in this instance.
|
|
3274
3338
|
*/
|
|
3275
3339
|
calculateSpeed() {
|
|
3276
|
-
const speedSkill = new OsuSpeed(this.mods,
|
|
3340
|
+
const speedSkill = new OsuSpeed(this.mods, this.difficultyStatistics.overallDifficulty);
|
|
3277
3341
|
this.calculateSkills(speedSkill);
|
|
3278
3342
|
this.postCalculateSpeed(speedSkill);
|
|
3279
3343
|
}
|
|
@@ -3298,14 +3362,14 @@ class OsuDifficultyCalculator extends DifficultyCalculator {
|
|
|
3298
3362
|
if (basePerformanceValue > 1e-5) {
|
|
3299
3363
|
// Document for formula derivation:
|
|
3300
3364
|
// https://docs.google.com/document/d/10DZGYYSsT_yjz2Mtp6yIJld0Rqx4E-vVHupCqiM4TNI/edit
|
|
3301
|
-
this.
|
|
3365
|
+
this.attributes.starRating =
|
|
3302
3366
|
Math.cbrt(1.14) *
|
|
3303
3367
|
0.027 *
|
|
3304
3368
|
(Math.cbrt((100000 / Math.pow(2, 1 / 1.1)) * basePerformanceValue) +
|
|
3305
3369
|
4);
|
|
3306
3370
|
}
|
|
3307
3371
|
else {
|
|
3308
|
-
this.
|
|
3372
|
+
this.attributes.starRating = 0;
|
|
3309
3373
|
}
|
|
3310
3374
|
}
|
|
3311
3375
|
calculateAll() {
|
|
@@ -3331,22 +3395,32 @@ class OsuDifficultyCalculator extends DifficultyCalculator {
|
|
|
3331
3395
|
this.flashlight.toFixed(2) +
|
|
3332
3396
|
" flashlight)");
|
|
3333
3397
|
}
|
|
3334
|
-
|
|
3335
|
-
const
|
|
3336
|
-
|
|
3337
|
-
|
|
3398
|
+
generateDifficultyHitObjects(beatmap) {
|
|
3399
|
+
const difficultyObjects = [];
|
|
3400
|
+
const { objects } = beatmap.hitObjects;
|
|
3401
|
+
for (let i = 0; i < objects.length; ++i) {
|
|
3402
|
+
const difficultyObject = new OsuDifficultyHitObject(objects[i], objects[i - 1] ?? null, objects[i - 2] ?? null, difficultyObjects, this.difficultyStatistics.overallSpeedMultiplier);
|
|
3403
|
+
difficultyObject.computeProperties(this.difficultyStatistics.overallSpeedMultiplier, objects);
|
|
3404
|
+
difficultyObjects.push(difficultyObject);
|
|
3338
3405
|
}
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
}
|
|
3343
|
-
osuBase.
|
|
3406
|
+
return difficultyObjects;
|
|
3407
|
+
}
|
|
3408
|
+
computeDifficultyStatistics(options) {
|
|
3409
|
+
const { difficulty } = this.beatmap;
|
|
3410
|
+
return osuBase.calculateOsuDifficultyStatistics({
|
|
3411
|
+
circleSize: difficulty.cs,
|
|
3412
|
+
approachRate: difficulty.ar ?? difficulty.od,
|
|
3413
|
+
overallDifficulty: difficulty.od,
|
|
3414
|
+
healthDrain: difficulty.hp,
|
|
3415
|
+
mods: options?.mods,
|
|
3416
|
+
customSpeedMultiplier: options?.customSpeedMultiplier,
|
|
3417
|
+
});
|
|
3344
3418
|
}
|
|
3345
3419
|
createSkills() {
|
|
3346
3420
|
return [
|
|
3347
3421
|
new OsuAim(this.mods, true),
|
|
3348
3422
|
new OsuAim(this.mods, false),
|
|
3349
|
-
new OsuSpeed(this.mods,
|
|
3423
|
+
new OsuSpeed(this.mods, this.difficultyStatistics.overallDifficulty),
|
|
3350
3424
|
new OsuFlashlight(this.mods),
|
|
3351
3425
|
];
|
|
3352
3426
|
}
|
|
@@ -3359,19 +3433,18 @@ class OsuDifficultyCalculator extends DifficultyCalculator {
|
|
|
3359
3433
|
postCalculateAim(aimSkill, aimSkillWithoutSliders) {
|
|
3360
3434
|
this.strainPeaks.aimWithSliders = aimSkill.strainPeaks;
|
|
3361
3435
|
this.strainPeaks.aimWithoutSliders = aimSkillWithoutSliders.strainPeaks;
|
|
3362
|
-
this.
|
|
3436
|
+
this.attributes.aimDifficulty = this.starValue(aimSkill.difficultyValue());
|
|
3363
3437
|
if (this.aim) {
|
|
3364
3438
|
this.attributes.sliderFactor =
|
|
3365
3439
|
this.starValue(aimSkillWithoutSliders.difficultyValue()) /
|
|
3366
3440
|
this.aim;
|
|
3367
3441
|
}
|
|
3368
3442
|
if (this.mods.some((m) => m instanceof osuBase.ModTouchDevice)) {
|
|
3369
|
-
this.
|
|
3443
|
+
this.attributes.aimDifficulty = Math.pow(this.aim, 0.8);
|
|
3370
3444
|
}
|
|
3371
3445
|
if (this.mods.some((m) => m instanceof osuBase.ModRelax)) {
|
|
3372
|
-
this.
|
|
3446
|
+
this.attributes.aimDifficulty *= 0.9;
|
|
3373
3447
|
}
|
|
3374
|
-
this.attributes.aimDifficulty = this.aim;
|
|
3375
3448
|
}
|
|
3376
3449
|
/**
|
|
3377
3450
|
* Called after speed skill calculation.
|
|
@@ -3380,7 +3453,7 @@ class OsuDifficultyCalculator extends DifficultyCalculator {
|
|
|
3380
3453
|
*/
|
|
3381
3454
|
postCalculateSpeed(speedSkill) {
|
|
3382
3455
|
this.strainPeaks.speed = speedSkill.strainPeaks;
|
|
3383
|
-
this.
|
|
3456
|
+
this.attributes.speedDifficulty = this.mods.some((m) => m instanceof osuBase.ModRelax)
|
|
3384
3457
|
? 0
|
|
3385
3458
|
: this.starValue(speedSkill.difficultyValue());
|
|
3386
3459
|
this.calculateSpeedAttributes();
|
|
@@ -3402,51 +3475,13 @@ class OsuDifficultyCalculator extends DifficultyCalculator {
|
|
|
3402
3475
|
*/
|
|
3403
3476
|
postCalculateFlashlight(flashlightSkill) {
|
|
3404
3477
|
this.strainPeaks.flashlight = flashlightSkill.strainPeaks;
|
|
3405
|
-
this.
|
|
3478
|
+
this.attributes.flashlightDifficulty = this.starValue(flashlightSkill.difficultyValue());
|
|
3406
3479
|
if (this.mods.some((m) => m instanceof osuBase.ModTouchDevice)) {
|
|
3407
|
-
this.
|
|
3480
|
+
this.attributes.flashlightDifficulty = Math.pow(this.flashlight, 0.8);
|
|
3408
3481
|
}
|
|
3409
3482
|
if (this.mods.some((m) => m instanceof osuBase.ModRelax)) {
|
|
3410
|
-
this.
|
|
3483
|
+
this.attributes.flashlightDifficulty *= 0.7;
|
|
3411
3484
|
}
|
|
3412
|
-
this.attributes.flashlightDifficulty = this.flashlight;
|
|
3413
|
-
}
|
|
3414
|
-
}
|
|
3415
|
-
|
|
3416
|
-
/**
|
|
3417
|
-
* A difficulty calculator that calculates for both osu!droid and osu!standard gamemode.
|
|
3418
|
-
*/
|
|
3419
|
-
class MapStars {
|
|
3420
|
-
/**
|
|
3421
|
-
* The osu!droid difficulty calculator of the beatmap.
|
|
3422
|
-
*/
|
|
3423
|
-
droid;
|
|
3424
|
-
/**
|
|
3425
|
-
* The osu!standard difficulty calculator of the beatmap.
|
|
3426
|
-
*/
|
|
3427
|
-
osu;
|
|
3428
|
-
/**
|
|
3429
|
-
* Constructs this instance and calculates the given beatmap's osu!droid and osu!standard difficulty.
|
|
3430
|
-
*
|
|
3431
|
-
* @param beatmap The beatmap to calculate.
|
|
3432
|
-
* @param options Options for the difficulty calculation.
|
|
3433
|
-
*/
|
|
3434
|
-
constructor(beatmap, options) {
|
|
3435
|
-
const stats = new osuBase.MapStats(options?.stats);
|
|
3436
|
-
this.droid = new DroidDifficultyCalculator(beatmap).calculate({
|
|
3437
|
-
...options,
|
|
3438
|
-
stats,
|
|
3439
|
-
});
|
|
3440
|
-
this.osu = new OsuDifficultyCalculator(beatmap).calculate({
|
|
3441
|
-
...options,
|
|
3442
|
-
stats,
|
|
3443
|
-
});
|
|
3444
|
-
}
|
|
3445
|
-
/**
|
|
3446
|
-
* Returns a string representative of the class.
|
|
3447
|
-
*/
|
|
3448
|
-
toString() {
|
|
3449
|
-
return `${this.droid.toString()}\n${this.osu.toString()}`;
|
|
3450
3485
|
}
|
|
3451
3486
|
}
|
|
3452
3487
|
|
|
@@ -3673,7 +3708,6 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
|
|
|
3673
3708
|
exports.AimEvaluator = AimEvaluator;
|
|
3674
3709
|
exports.DifficultyCalculator = DifficultyCalculator;
|
|
3675
3710
|
exports.DifficultyHitObject = DifficultyHitObject;
|
|
3676
|
-
exports.DifficultyHitObjectCreator = DifficultyHitObjectCreator;
|
|
3677
3711
|
exports.DroidAim = DroidAim;
|
|
3678
3712
|
exports.DroidAimEvaluator = DroidAimEvaluator;
|
|
3679
3713
|
exports.DroidDifficultyCalculator = DroidDifficultyCalculator;
|
|
@@ -3688,7 +3722,6 @@ exports.DroidTapEvaluator = DroidTapEvaluator;
|
|
|
3688
3722
|
exports.DroidVisual = DroidVisual;
|
|
3689
3723
|
exports.DroidVisualEvaluator = DroidVisualEvaluator;
|
|
3690
3724
|
exports.FlashlightEvaluator = FlashlightEvaluator;
|
|
3691
|
-
exports.MapStars = MapStars;
|
|
3692
3725
|
exports.OsuAim = OsuAim;
|
|
3693
3726
|
exports.OsuAimEvaluator = OsuAimEvaluator;
|
|
3694
3727
|
exports.OsuDifficultyCalculator = OsuDifficultyCalculator;
|