@rian8337/osu-rebalance-difficulty-calculator 4.0.0-beta.14 → 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 +891 -854
- 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
|
|
@@ -529,201 +445,25 @@ class DifficultyHitObjectCreator {
|
|
|
529
445
|
if (currentMovementLength > requiredMovement) {
|
|
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
|
-
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
|
-
this.stats = new osuBase.MapStats({
|
|
653
|
-
cs: this.beatmap.difficulty.cs,
|
|
654
|
-
ar: this.beatmap.difficulty.ar,
|
|
655
|
-
od: this.beatmap.difficulty.od,
|
|
656
|
-
hp: this.beatmap.difficulty.hp,
|
|
657
|
-
mods: options?.mods,
|
|
658
|
-
speedMultiplier: options?.stats?.speedMultiplier ?? 1,
|
|
659
|
-
oldStatistics: options?.stats?.oldStatistics ?? false,
|
|
660
|
-
}).calculate({ mode: this.mode });
|
|
661
|
-
this.preProcess();
|
|
662
|
-
this.populateDifficultyAttributes();
|
|
663
|
-
this.generateDifficultyHitObjects();
|
|
664
|
-
this.calculateAll();
|
|
665
|
-
return this;
|
|
666
|
-
}
|
|
667
|
-
/**
|
|
668
|
-
* Generates difficulty hitobjects for this calculator.
|
|
669
|
-
*/
|
|
670
|
-
generateDifficultyHitObjects() {
|
|
671
|
-
this.objects.length = 0;
|
|
672
|
-
this.objects.push(...new DifficultyHitObjectCreator().generateDifficultyObjects({
|
|
673
|
-
objects: this.beatmap.hitObjects.objects,
|
|
674
|
-
circleSize: this.beatmap.difficulty.cs,
|
|
675
|
-
mods: this.mods,
|
|
676
|
-
speedMultiplier: this.stats.speedMultiplier,
|
|
677
|
-
mode: this.mode,
|
|
678
|
-
preempt: osuBase.MapStats.arToMS(this.stats.ar),
|
|
679
|
-
}));
|
|
680
|
-
}
|
|
681
|
-
/**
|
|
682
|
-
* Performs some pre-processing before proceeding with difficulty calculation.
|
|
683
|
-
*/
|
|
684
|
-
preProcess() {
|
|
685
|
-
}
|
|
686
|
-
/**
|
|
687
|
-
* Calculates the skills provided.
|
|
688
|
-
*
|
|
689
|
-
* @param skills The skills to calculate.
|
|
690
|
-
*/
|
|
691
|
-
calculateSkills(...skills) {
|
|
692
|
-
// The first object doesn't generate a strain, so we begin calculating from the second object.
|
|
693
|
-
for (const object of this.objects.slice(1)) {
|
|
694
|
-
for (const skill of skills) {
|
|
695
|
-
skill.process(object);
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
/**
|
|
700
|
-
* Populates the stored difficulty attributes with necessary data.
|
|
701
|
-
*/
|
|
702
|
-
populateDifficultyAttributes() {
|
|
703
|
-
this.attributes.approachRate = this.stats.ar;
|
|
704
|
-
this.attributes.hitCircleCount = this.beatmap.hitObjects.circles;
|
|
705
|
-
this.attributes.maxCombo = this.beatmap.maxCombo;
|
|
706
|
-
this.attributes.mods = this.mods.slice();
|
|
707
|
-
this.attributes.overallDifficulty = this.stats.od;
|
|
708
|
-
this.attributes.sliderCount = this.beatmap.hitObjects.sliders;
|
|
709
|
-
this.attributes.spinnerCount = this.beatmap.hitObjects.spinners;
|
|
710
|
-
this.attributes.clockRate = this.stats.speedMultiplier;
|
|
711
|
-
}
|
|
712
|
-
/**
|
|
713
|
-
* Calculates the star rating value of a difficulty.
|
|
714
|
-
*
|
|
715
|
-
* @param difficulty The difficulty to calculate.
|
|
716
|
-
*/
|
|
717
|
-
starValue(difficulty) {
|
|
718
|
-
return Math.sqrt(difficulty) * this.difficultyMultiplier;
|
|
448
|
+
currentCursorPosition = currentCursorPosition.add(currentMovement.scale((currentMovementLength - requiredMovement) /
|
|
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
|
+
}
|
|
719
459
|
}
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
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;
|
|
727
467
|
}
|
|
728
468
|
}
|
|
729
469
|
|
|
@@ -914,9 +654,7 @@ class StrainSkill extends Skill {
|
|
|
914
654
|
process(current) {
|
|
915
655
|
// The first object doesn't generate a strain, so we begin with an incremented section end
|
|
916
656
|
if (current.index === 0) {
|
|
917
|
-
this.currentSectionEnd =
|
|
918
|
-
Math.ceil(current.startTime / this.sectionLength) *
|
|
919
|
-
this.sectionLength;
|
|
657
|
+
this.currentSectionEnd = this.calculateCurrentSectionStart(current);
|
|
920
658
|
}
|
|
921
659
|
while (current.startTime > this.currentSectionEnd) {
|
|
922
660
|
this.saveCurrentPeak();
|
|
@@ -946,6 +684,16 @@ class StrainSkill extends Skill {
|
|
|
946
684
|
strainDecay(ms) {
|
|
947
685
|
return Math.pow(this.strainDecayBase, ms / 1000);
|
|
948
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
|
+
}
|
|
949
697
|
/**
|
|
950
698
|
* Sets the initial strain level for a new section.
|
|
951
699
|
*
|
|
@@ -964,6 +712,32 @@ class StrainSkill extends Skill {
|
|
|
964
712
|
* and to calculate a final difficulty value representing the difficulty of hitting all the processed objects.
|
|
965
713
|
*/
|
|
966
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
|
+
}
|
|
967
741
|
difficultyValue() {
|
|
968
742
|
const strains = this.strainPeaks.slice();
|
|
969
743
|
if (this.reducedSectionCount > 0) {
|
|
@@ -983,6 +757,9 @@ class DroidSkill extends StrainSkill {
|
|
|
983
757
|
return a + Math.pow(v, 1 / Math.log2(this.starsPerDouble));
|
|
984
758
|
}, 0), Math.log2(this.starsPerDouble));
|
|
985
759
|
}
|
|
760
|
+
calculateCurrentSectionStart(current) {
|
|
761
|
+
return current.startTime;
|
|
762
|
+
}
|
|
986
763
|
}
|
|
987
764
|
|
|
988
765
|
/**
|
|
@@ -1011,6 +788,9 @@ class DroidAim extends DroidSkill {
|
|
|
1011
788
|
return (this.currentAimStrain *
|
|
1012
789
|
this.strainDecay(time - (current.previous(0)?.startTime ?? 0)));
|
|
1013
790
|
}
|
|
791
|
+
getObjectStrain() {
|
|
792
|
+
return this.currentAimStrain;
|
|
793
|
+
}
|
|
1014
794
|
/**
|
|
1015
795
|
* @param current The hitobject to save to.
|
|
1016
796
|
*/
|
|
@@ -1043,13 +823,15 @@ class DroidTapEvaluator extends SpeedEvaluator {
|
|
|
1043
823
|
*
|
|
1044
824
|
* - time between pressing the previous and current object,
|
|
1045
825
|
* - distance between those objects,
|
|
1046
|
-
* -
|
|
826
|
+
* - how easily they can be cheesed,
|
|
827
|
+
* - and the strain time cap.
|
|
1047
828
|
*
|
|
1048
829
|
* @param current The current object.
|
|
1049
830
|
* @param greatWindow The great hit window of the current object.
|
|
1050
831
|
* @param considerCheesability Whether to consider cheesability.
|
|
832
|
+
* @param strainTimeCap The strain time to cap the object's strain time to.
|
|
1051
833
|
*/
|
|
1052
|
-
static evaluateDifficultyOf(current, greatWindow, considerCheesability) {
|
|
834
|
+
static evaluateDifficultyOf(current, greatWindow, considerCheesability, strainTimeCap) {
|
|
1053
835
|
if (current.object instanceof osuBase.Spinner ||
|
|
1054
836
|
// Exclude overlapping objects that can be tapped at once.
|
|
1055
837
|
current.isOverlapping(false)) {
|
|
@@ -1070,13 +852,17 @@ class DroidTapEvaluator extends SpeedEvaluator {
|
|
|
1070
852
|
doubletapness = Math.pow(speedRatio, 1 - windowRatio);
|
|
1071
853
|
}
|
|
1072
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;
|
|
1073
859
|
let speedBonus = 1;
|
|
1074
|
-
if (
|
|
860
|
+
if (strainTime < this.minSpeedBonus) {
|
|
1075
861
|
speedBonus +=
|
|
1076
862
|
0.75 *
|
|
1077
|
-
Math.pow(osuBase.ErrorFunction.erf((this.minSpeedBonus -
|
|
863
|
+
Math.pow(osuBase.ErrorFunction.erf((this.minSpeedBonus - strainTime) / 40), 2);
|
|
1078
864
|
}
|
|
1079
|
-
return (speedBonus * Math.pow(doubletapness, 1.5)) /
|
|
865
|
+
return (speedBonus * Math.pow(doubletapness, 1.5)) / strainTime;
|
|
1080
866
|
}
|
|
1081
867
|
}
|
|
1082
868
|
|
|
@@ -1093,17 +879,59 @@ class DroidTap extends DroidSkill {
|
|
|
1093
879
|
skillMultiplier = 1375;
|
|
1094
880
|
greatWindow;
|
|
1095
881
|
considerCheesability;
|
|
1096
|
-
|
|
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) {
|
|
1097
891
|
super(mods);
|
|
1098
892
|
this.greatWindow = new osuBase.OsuHitWindow(overallDifficulty).hitWindowFor300();
|
|
1099
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));
|
|
1100
927
|
}
|
|
1101
928
|
strainValueAt(current) {
|
|
1102
929
|
const decay = this.strainDecay(current.strainTime);
|
|
1103
930
|
this.currentTapStrain *= decay;
|
|
1104
931
|
this.currentTapStrain +=
|
|
1105
|
-
DroidTapEvaluator.evaluateDifficultyOf(current, this.greatWindow, this.considerCheesability) * this.skillMultiplier;
|
|
932
|
+
DroidTapEvaluator.evaluateDifficultyOf(current, this.greatWindow, this.considerCheesability, this.strainTimeCap) * this.skillMultiplier;
|
|
1106
933
|
this.currentRhythmMultiplier = current.rhythmMultiplier;
|
|
934
|
+
this._objectDeltaTimes.push(current.deltaTime);
|
|
1107
935
|
return this.currentTapStrain * current.rhythmMultiplier;
|
|
1108
936
|
}
|
|
1109
937
|
calculateInitialStrain(time, current) {
|
|
@@ -1111,10 +939,16 @@ class DroidTap extends DroidSkill {
|
|
|
1111
939
|
this.currentRhythmMultiplier *
|
|
1112
940
|
this.strainDecay(time - (current.previous(0)?.startTime ?? 0)));
|
|
1113
941
|
}
|
|
942
|
+
getObjectStrain() {
|
|
943
|
+
return this.currentTapStrain * this.currentRhythmMultiplier;
|
|
944
|
+
}
|
|
1114
945
|
/**
|
|
1115
946
|
* @param current The hitobject to save to.
|
|
1116
947
|
*/
|
|
1117
948
|
saveToHitObject(current) {
|
|
949
|
+
if (this.strainTimeCap !== undefined) {
|
|
950
|
+
return;
|
|
951
|
+
}
|
|
1118
952
|
const strain = this.currentTapStrain * this.currentRhythmMultiplier;
|
|
1119
953
|
if (this.considerCheesability) {
|
|
1120
954
|
current.tapStrain = strain;
|
|
@@ -1161,7 +995,7 @@ class DroidFlashlightEvaluator extends FlashlightEvaluator {
|
|
|
1161
995
|
current.isOverlapping(true)) {
|
|
1162
996
|
return 0;
|
|
1163
997
|
}
|
|
1164
|
-
const scalingFactor = 52 / current.object.
|
|
998
|
+
const scalingFactor = 52 / current.object.radius;
|
|
1165
999
|
let smallDistNerf = 1;
|
|
1166
1000
|
let cumulativeStrainTime = 0;
|
|
1167
1001
|
let result = 0;
|
|
@@ -1217,8 +1051,8 @@ class DroidFlashlightEvaluator extends FlashlightEvaluator {
|
|
|
1217
1051
|
// Longer sliders require more memorization.
|
|
1218
1052
|
sliderBonus *= pixelTravelDistance;
|
|
1219
1053
|
// Nerf sliders with repeats, as less memorization is required.
|
|
1220
|
-
if (current.object.
|
|
1221
|
-
sliderBonus /= current.object.
|
|
1054
|
+
if (current.object.repeatCount > 0)
|
|
1055
|
+
sliderBonus /= current.object.repeatCount + 1;
|
|
1222
1056
|
}
|
|
1223
1057
|
result += sliderBonus * this.sliderMultiplier;
|
|
1224
1058
|
return result;
|
|
@@ -1252,6 +1086,9 @@ class DroidFlashlight extends DroidSkill {
|
|
|
1252
1086
|
return (this.currentFlashlightStrain *
|
|
1253
1087
|
this.strainDecay(time - (current.previous(0)?.startTime ?? 0)));
|
|
1254
1088
|
}
|
|
1089
|
+
getObjectStrain() {
|
|
1090
|
+
return this.currentFlashlightStrain;
|
|
1091
|
+
}
|
|
1255
1092
|
saveToHitObject(current) {
|
|
1256
1093
|
if (this.withSliders) {
|
|
1257
1094
|
current.flashlightStrainWithSliders = this.currentFlashlightStrain;
|
|
@@ -1432,6 +1269,9 @@ class DroidRhythm extends DroidSkill {
|
|
|
1432
1269
|
return (this.currentRhythmStrain *
|
|
1433
1270
|
this.strainDecay(time - (current.previous(0)?.startTime ?? 0)));
|
|
1434
1271
|
}
|
|
1272
|
+
getObjectStrain() {
|
|
1273
|
+
return this.currentRhythmStrain;
|
|
1274
|
+
}
|
|
1435
1275
|
saveToHitObject(current) {
|
|
1436
1276
|
current.rhythmStrain = this.currentRhythmStrain;
|
|
1437
1277
|
current.rhythmMultiplier = this.currentRhythmMultiplier;
|
|
@@ -1470,109 +1310,286 @@ class DroidVisualEvaluator {
|
|
|
1470
1310
|
if (isHiddenMod) {
|
|
1471
1311
|
strain = Math.min(30, Math.pow(current.noteDensity, 3));
|
|
1472
1312
|
}
|
|
1473
|
-
else {
|
|
1474
|
-
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;
|
|
1475
1534
|
}
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
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) {
|
|
1482
1546
|
continue;
|
|
1483
1547
|
}
|
|
1484
|
-
|
|
1485
|
-
if (current.object.startTime - previous.object.endTime >
|
|
1486
|
-
current.baseTimePreempt) {
|
|
1548
|
+
if (o.startTime / clockRate > this.endTime + this.timePreempt) {
|
|
1487
1549
|
break;
|
|
1488
1550
|
}
|
|
1489
|
-
|
|
1490
|
-
(1 -
|
|
1491
|
-
current.opacityAt(previous.object.startTime, isHiddenMod)) /
|
|
1492
|
-
4;
|
|
1493
|
-
}
|
|
1494
|
-
// Scale the value with overlapping factor.
|
|
1495
|
-
strain /= 10 * (1 + current.overlappingFactor);
|
|
1496
|
-
if (current.timePreempt < 400) {
|
|
1497
|
-
// Give bonus for AR higher than 10.33.
|
|
1498
|
-
strain += Math.pow(400 - current.timePreempt, 1.3) / 100;
|
|
1551
|
+
nextVisibleObjects.push(o);
|
|
1499
1552
|
}
|
|
1500
|
-
|
|
1501
|
-
const
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
const currentVelocity = pixelTravelDistance / current.travelTime;
|
|
1505
|
-
strain +=
|
|
1506
|
-
// Reward sliders based on velocity, while also avoiding overbuffing extremely fast sliders.
|
|
1507
|
-
Math.min(6, currentVelocity * 1.5) *
|
|
1508
|
-
// Longer sliders require more reading.
|
|
1509
|
-
(pixelTravelDistance / 100);
|
|
1510
|
-
let cumulativeStrainTime = 0;
|
|
1511
|
-
// Reward for velocity changes based on last few sliders.
|
|
1512
|
-
for (let i = 0; i < Math.min(current.index, 4); ++i) {
|
|
1513
|
-
const last = current.previous(i);
|
|
1514
|
-
cumulativeStrainTime += last.strainTime;
|
|
1515
|
-
if (!(last.object instanceof osuBase.Slider) ||
|
|
1516
|
-
// Exclude overlapping objects that can be tapped at once.
|
|
1517
|
-
last.isOverlapping(true)) {
|
|
1518
|
-
continue;
|
|
1519
|
-
}
|
|
1520
|
-
// Invert the scaling factor to determine the true travel distance independent of circle size.
|
|
1521
|
-
const pixelTravelDistance = last.object.lazyTravelDistance / scalingFactor;
|
|
1522
|
-
const lastVelocity = pixelTravelDistance / last.travelTime;
|
|
1523
|
-
strain +=
|
|
1524
|
-
// Reward past sliders based on velocity changes, while also
|
|
1525
|
-
// avoiding overbuffing extremely fast velocity changes.
|
|
1526
|
-
Math.min(10, 2.5 * Math.abs(currentVelocity - lastVelocity)) *
|
|
1527
|
-
// Longer sliders require more reading.
|
|
1528
|
-
(pixelTravelDistance / 125) *
|
|
1529
|
-
// Avoid overbuffing past sliders.
|
|
1530
|
-
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;
|
|
1531
1557
|
}
|
|
1558
|
+
if (prev.startTime >= this.startTime) {
|
|
1559
|
+
continue;
|
|
1560
|
+
}
|
|
1561
|
+
if (prev.startTime < this.startTime - this.timePreempt) {
|
|
1562
|
+
break;
|
|
1563
|
+
}
|
|
1564
|
+
prevVisibleObjects.push(prev.object);
|
|
1532
1565
|
}
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
*/
|
|
1540
|
-
class DroidVisual extends DroidSkill {
|
|
1541
|
-
starsPerDouble = 1.025;
|
|
1542
|
-
reducedSectionCount = 10;
|
|
1543
|
-
reducedSectionBaseline = 0.75;
|
|
1544
|
-
strainDecayBase = 0.1;
|
|
1545
|
-
isHidden;
|
|
1546
|
-
withSliders;
|
|
1547
|
-
currentVisualStrain = 0;
|
|
1548
|
-
currentRhythmMultiplier = 1;
|
|
1549
|
-
skillMultiplier = 10;
|
|
1550
|
-
constructor(mods, withSliders) {
|
|
1551
|
-
super(mods);
|
|
1552
|
-
this.isHidden = mods.some((m) => m instanceof osuBase.ModHidden);
|
|
1553
|
-
this.withSliders = withSliders;
|
|
1554
|
-
}
|
|
1555
|
-
strainValueAt(current) {
|
|
1556
|
-
this.currentVisualStrain *= this.strainDecay(current.deltaTime);
|
|
1557
|
-
this.currentVisualStrain +=
|
|
1558
|
-
DroidVisualEvaluator.evaluateDifficultyOf(current, this.isHidden, this.withSliders) * this.skillMultiplier;
|
|
1559
|
-
this.currentRhythmMultiplier = current.rhythmMultiplier;
|
|
1560
|
-
return this.currentVisualStrain * this.currentRhythmMultiplier;
|
|
1561
|
-
}
|
|
1562
|
-
calculateInitialStrain(time, current) {
|
|
1563
|
-
return (this.currentVisualStrain *
|
|
1564
|
-
this.currentRhythmMultiplier *
|
|
1565
|
-
this.strainDecay(time - (current.previous(0)?.startTime ?? 0)));
|
|
1566
|
-
}
|
|
1567
|
-
saveToHitObject(current) {
|
|
1568
|
-
const strain = this.currentVisualStrain * this.currentRhythmMultiplier;
|
|
1569
|
-
if (this.withSliders) {
|
|
1570
|
-
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);
|
|
1571
1572
|
}
|
|
1572
|
-
|
|
1573
|
-
|
|
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);
|
|
1574
1582
|
}
|
|
1575
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
|
+
}
|
|
1576
1593
|
}
|
|
1577
1594
|
|
|
1578
1595
|
/**
|
|
@@ -1582,23 +1599,33 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
|
1582
1599
|
/**
|
|
1583
1600
|
* The aim star rating of the beatmap.
|
|
1584
1601
|
*/
|
|
1585
|
-
aim
|
|
1602
|
+
get aim() {
|
|
1603
|
+
return this.attributes.aimDifficulty;
|
|
1604
|
+
}
|
|
1586
1605
|
/**
|
|
1587
1606
|
* The tap star rating of the beatmap.
|
|
1588
1607
|
*/
|
|
1589
|
-
tap
|
|
1608
|
+
get tap() {
|
|
1609
|
+
return this.attributes.tapDifficulty;
|
|
1610
|
+
}
|
|
1590
1611
|
/**
|
|
1591
1612
|
* The rhythm star rating of the beatmap.
|
|
1592
1613
|
*/
|
|
1593
|
-
rhythm
|
|
1614
|
+
get rhythm() {
|
|
1615
|
+
return this.attributes.rhythmDifficulty;
|
|
1616
|
+
}
|
|
1594
1617
|
/**
|
|
1595
1618
|
* The flashlight star rating of the beatmap.
|
|
1596
1619
|
*/
|
|
1597
|
-
flashlight
|
|
1620
|
+
get flashlight() {
|
|
1621
|
+
return this.attributes.flashlightDifficulty;
|
|
1622
|
+
}
|
|
1598
1623
|
/**
|
|
1599
1624
|
* The visual star rating of the beatmap.
|
|
1600
1625
|
*/
|
|
1601
|
-
visual
|
|
1626
|
+
get visual() {
|
|
1627
|
+
return this.attributes.visualDifficulty;
|
|
1628
|
+
}
|
|
1602
1629
|
/**
|
|
1603
1630
|
* The strain threshold to start detecting for possible three-fingered section.
|
|
1604
1631
|
*
|
|
@@ -1606,6 +1633,7 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
|
1606
1633
|
*/
|
|
1607
1634
|
static threeFingerStrainThreshold = 175;
|
|
1608
1635
|
attributes = {
|
|
1636
|
+
mode: "rebalance",
|
|
1609
1637
|
tapDifficulty: 0,
|
|
1610
1638
|
rhythmDifficulty: 0,
|
|
1611
1639
|
visualDifficulty: 0,
|
|
@@ -1632,6 +1660,7 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
|
1632
1660
|
possibleThreeFingeredSections: [],
|
|
1633
1661
|
difficultSliders: [],
|
|
1634
1662
|
averageSpeedDeltaTime: 0,
|
|
1663
|
+
vibroFactor: 1,
|
|
1635
1664
|
};
|
|
1636
1665
|
get cacheableAttributes() {
|
|
1637
1666
|
return {
|
|
@@ -1656,6 +1685,7 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
|
1656
1685
|
flashlightDifficultStrainCount: this.attributes.flashlightDifficultStrainCount,
|
|
1657
1686
|
visualDifficultStrainCount: this.attributes.visualDifficultStrainCount,
|
|
1658
1687
|
averageSpeedDeltaTime: this.attributes.averageSpeedDeltaTime,
|
|
1688
|
+
vibroFactor: this.attributes.vibroFactor,
|
|
1659
1689
|
};
|
|
1660
1690
|
}
|
|
1661
1691
|
difficultyMultiplier = 0.18;
|
|
@@ -1673,17 +1703,19 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
|
1673
1703
|
* Calculates the tap star rating of the beatmap and stores it in this instance.
|
|
1674
1704
|
*/
|
|
1675
1705
|
calculateTap() {
|
|
1676
|
-
const od = this.
|
|
1706
|
+
const od = this.difficultyStatistics.overallDifficulty;
|
|
1677
1707
|
const tapSkillCheese = new DroidTap(this.mods, od, true);
|
|
1678
1708
|
const tapSkillNoCheese = new DroidTap(this.mods, od, false);
|
|
1679
1709
|
this.calculateSkills(tapSkillCheese, tapSkillNoCheese);
|
|
1680
|
-
this.
|
|
1710
|
+
const tapSkillVibro = new DroidTap(this.mods, od, true, tapSkillCheese.relevantDeltaTime());
|
|
1711
|
+
this.calculateSkills(tapSkillVibro);
|
|
1712
|
+
this.postCalculateTap(tapSkillCheese, tapSkillVibro);
|
|
1681
1713
|
}
|
|
1682
1714
|
/**
|
|
1683
1715
|
* Calculates the rhythm star rating of the beatmap and stores it in this instance.
|
|
1684
1716
|
*/
|
|
1685
1717
|
calculateRhythm() {
|
|
1686
|
-
const rhythmSkill = new DroidRhythm(this.mods, this.
|
|
1718
|
+
const rhythmSkill = new DroidRhythm(this.mods, this.difficultyStatistics.overallDifficulty);
|
|
1687
1719
|
this.calculateSkills(rhythmSkill);
|
|
1688
1720
|
this.postCalculateRhythm(rhythmSkill);
|
|
1689
1721
|
}
|
|
@@ -1701,7 +1733,7 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
|
1701
1733
|
*/
|
|
1702
1734
|
calculateVisual() {
|
|
1703
1735
|
if (this.mods.some((m) => m instanceof osuBase.ModRelax)) {
|
|
1704
|
-
this.
|
|
1736
|
+
this.attributes.visualDifficulty = 0;
|
|
1705
1737
|
return;
|
|
1706
1738
|
}
|
|
1707
1739
|
const visualSkill = new DroidVisual(this.mods, true);
|
|
@@ -1723,13 +1755,13 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
|
1723
1755
|
if (basePerformanceValue > 1e-5) {
|
|
1724
1756
|
// Document for formula derivation:
|
|
1725
1757
|
// https://docs.google.com/document/d/10DZGYYSsT_yjz2Mtp6yIJld0Rqx4E-vVHupCqiM4TNI/edit
|
|
1726
|
-
this.
|
|
1758
|
+
this.attributes.starRating =
|
|
1727
1759
|
0.027 *
|
|
1728
1760
|
(Math.cbrt((100000 / Math.pow(2, 1 / 1.1)) * basePerformanceValue) +
|
|
1729
1761
|
4);
|
|
1730
1762
|
}
|
|
1731
1763
|
else {
|
|
1732
|
-
this.
|
|
1764
|
+
this.attributes.starRating = 0;
|
|
1733
1765
|
}
|
|
1734
1766
|
}
|
|
1735
1767
|
calculateAll() {
|
|
@@ -1743,8 +1775,10 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
|
1743
1775
|
const flashlightSkillWithoutSliders = skills[6];
|
|
1744
1776
|
const visualSkill = skills[7];
|
|
1745
1777
|
const visualSkillWithoutSliders = skills[8];
|
|
1778
|
+
const tapSkillVibro = new DroidTap(this.mods, this.difficultyStatistics.overallDifficulty, true, tapSkillCheese.relevantDeltaTime());
|
|
1779
|
+
this.calculateSkills(tapSkillVibro);
|
|
1746
1780
|
this.postCalculateAim(aimSkill, aimSkillWithoutSliders);
|
|
1747
|
-
this.postCalculateTap(tapSkillCheese);
|
|
1781
|
+
this.postCalculateTap(tapSkillCheese, tapSkillVibro);
|
|
1748
1782
|
this.postCalculateRhythm(rhythmSkill);
|
|
1749
1783
|
this.postCalculateFlashlight(flashlightSkill, flashlightSkillWithoutSliders);
|
|
1750
1784
|
this.postCalculateVisual(visualSkill, visualSkillWithoutSliders);
|
|
@@ -1764,21 +1798,39 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
|
1764
1798
|
this.visual.toFixed(2) +
|
|
1765
1799
|
" visual)");
|
|
1766
1800
|
}
|
|
1767
|
-
|
|
1768
|
-
const
|
|
1769
|
-
|
|
1770
|
-
|
|
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);
|
|
1771
1809
|
}
|
|
1772
|
-
|
|
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
|
+
});
|
|
1773
1823
|
}
|
|
1774
1824
|
createSkills() {
|
|
1775
|
-
const od = this.
|
|
1825
|
+
const od = this.difficultyStatistics.overallDifficulty;
|
|
1776
1826
|
return [
|
|
1777
1827
|
new DroidAim(this.mods, true),
|
|
1778
1828
|
new DroidAim(this.mods, false),
|
|
1779
1829
|
// Tap skill depends on rhythm skill, so we put it first
|
|
1780
1830
|
new DroidRhythm(this.mods, od),
|
|
1831
|
+
// Cheesability tap
|
|
1781
1832
|
new DroidTap(this.mods, od, true),
|
|
1833
|
+
// Non-cheesability tap
|
|
1782
1834
|
new DroidTap(this.mods, od, false),
|
|
1783
1835
|
new DroidFlashlight(this.mods, true),
|
|
1784
1836
|
new DroidFlashlight(this.mods, false),
|
|
@@ -1795,29 +1847,26 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
|
1795
1847
|
postCalculateAim(aimSkill, aimSkillWithoutSliders) {
|
|
1796
1848
|
this.strainPeaks.aimWithSliders = aimSkill.strainPeaks;
|
|
1797
1849
|
this.strainPeaks.aimWithoutSliders = aimSkillWithoutSliders.strainPeaks;
|
|
1798
|
-
this.
|
|
1850
|
+
this.attributes.aimDifficulty = this.starValue(aimSkill.difficultyValue());
|
|
1799
1851
|
if (this.aim) {
|
|
1800
1852
|
this.attributes.sliderFactor =
|
|
1801
1853
|
this.starValue(aimSkillWithoutSliders.difficultyValue()) /
|
|
1802
1854
|
this.aim;
|
|
1803
1855
|
}
|
|
1804
1856
|
if (this.mods.some((m) => m instanceof osuBase.ModRelax)) {
|
|
1805
|
-
this.
|
|
1857
|
+
this.attributes.aimDifficulty *= 0.9;
|
|
1806
1858
|
}
|
|
1807
|
-
this.attributes.
|
|
1859
|
+
this.attributes.aimDifficultStrainCount =
|
|
1860
|
+
aimSkill.countDifficultStrains();
|
|
1808
1861
|
this.calculateAimAttributes();
|
|
1809
1862
|
}
|
|
1810
1863
|
/**
|
|
1811
1864
|
* Calculates aim-related attributes.
|
|
1812
1865
|
*/
|
|
1813
1866
|
calculateAimAttributes() {
|
|
1814
|
-
const objectStrains = [];
|
|
1815
|
-
let maxStrain = 0;
|
|
1816
1867
|
const topDifficultSliders = [];
|
|
1817
1868
|
for (let i = 0; i < this.objects.length; ++i) {
|
|
1818
1869
|
const object = this.objects[i];
|
|
1819
|
-
objectStrains.push(object.aimStrainWithSliders);
|
|
1820
|
-
maxStrain = Math.max(maxStrain, object.aimStrainWithSliders);
|
|
1821
1870
|
const velocity = object.travelDistance / object.travelTime;
|
|
1822
1871
|
if (velocity > 0) {
|
|
1823
1872
|
topDifficultSliders.push({
|
|
@@ -1826,10 +1875,6 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
|
1826
1875
|
});
|
|
1827
1876
|
}
|
|
1828
1877
|
}
|
|
1829
|
-
if (maxStrain) {
|
|
1830
|
-
this.attributes.aimNoteCount = objectStrains.reduce((total, next) => total + 1 / (1 + Math.exp(-((next / maxStrain) * 12 - 6))), 0);
|
|
1831
|
-
this.attributes.aimDifficultStrainCount = objectStrains.reduce((total, next) => total + Math.pow(next / maxStrain, 4), 0);
|
|
1832
|
-
}
|
|
1833
1878
|
const velocitySum = topDifficultSliders.reduce((a, v) => a + v.velocity, 0);
|
|
1834
1879
|
for (const slider of topDifficultSliders) {
|
|
1835
1880
|
const difficultyRating = slider.velocity / velocitySum;
|
|
@@ -1852,16 +1897,22 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
|
1852
1897
|
* Called after tap skill calculation.
|
|
1853
1898
|
*
|
|
1854
1899
|
* @param tapSkillCheese The tap skill that considers cheesing.
|
|
1900
|
+
* @param tapSkillVibro The tap skill that considers vibro.
|
|
1855
1901
|
*/
|
|
1856
|
-
postCalculateTap(tapSkillCheese) {
|
|
1902
|
+
postCalculateTap(tapSkillCheese, tapSkillVibro) {
|
|
1857
1903
|
this.strainPeaks.speed = tapSkillCheese.strainPeaks;
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
this.
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
}
|
|
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();
|
|
1865
1916
|
this.calculateTapAttributes();
|
|
1866
1917
|
}
|
|
1867
1918
|
/**
|
|
@@ -1869,110 +1920,46 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
|
1869
1920
|
*/
|
|
1870
1921
|
calculateTapAttributes() {
|
|
1871
1922
|
this.attributes.possibleThreeFingeredSections = [];
|
|
1872
|
-
const
|
|
1873
|
-
const objectStrains = [];
|
|
1874
|
-
const objectDeltaTimes = [];
|
|
1875
|
-
let maxStrain = 0;
|
|
1876
|
-
const maxSectionDeltaTime = 2000;
|
|
1923
|
+
const { threeFingerStrainThreshold } = DroidDifficultyCalculator;
|
|
1877
1924
|
const minSectionObjectCount = 5;
|
|
1878
|
-
let
|
|
1879
|
-
|
|
1925
|
+
let inSpeedSection = false;
|
|
1926
|
+
let firstSpeedObjectIndex = 0;
|
|
1927
|
+
for (let i = 2; i < this.objects.length; ++i) {
|
|
1880
1928
|
const current = this.objects[i];
|
|
1881
|
-
const
|
|
1882
|
-
if (
|
|
1883
|
-
|
|
1884
|
-
|
|
1929
|
+
const prev = this.objects[i - 1];
|
|
1930
|
+
if (!inSpeedSection &&
|
|
1931
|
+
current.originalTapStrain >= threeFingerStrainThreshold) {
|
|
1932
|
+
inSpeedSection = true;
|
|
1933
|
+
firstSpeedObjectIndex = i;
|
|
1934
|
+
continue;
|
|
1885
1935
|
}
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
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;
|
|
1891
1948
|
// Ignore sections that don't meet object count requirement.
|
|
1892
|
-
if (i -
|
|
1893
|
-
firstObjectIndex = i + 1;
|
|
1894
|
-
continue;
|
|
1895
|
-
}
|
|
1896
|
-
tempSections.push({
|
|
1897
|
-
firstObjectIndex,
|
|
1898
|
-
lastObjectIndex: i,
|
|
1899
|
-
});
|
|
1900
|
-
firstObjectIndex = i + 1;
|
|
1901
|
-
}
|
|
1902
|
-
}
|
|
1903
|
-
// Don't forget to manually add the last beatmap section, which would otherwise be ignored.
|
|
1904
|
-
if (this.objects.length - firstObjectIndex > minSectionObjectCount) {
|
|
1905
|
-
tempSections.push({
|
|
1906
|
-
firstObjectIndex,
|
|
1907
|
-
lastObjectIndex: this.objects.length - 1,
|
|
1908
|
-
});
|
|
1909
|
-
}
|
|
1910
|
-
// Refilter with tap strain in mind.
|
|
1911
|
-
const { threeFingerStrainThreshold } = DroidDifficultyCalculator;
|
|
1912
|
-
for (const section of tempSections) {
|
|
1913
|
-
let inSpeedSection = false;
|
|
1914
|
-
let newFirstObjectIndex = section.firstObjectIndex;
|
|
1915
|
-
for (let i = section.firstObjectIndex; i <= section.lastObjectIndex; ++i) {
|
|
1916
|
-
const current = this.objects[i];
|
|
1917
|
-
if (!inSpeedSection &&
|
|
1918
|
-
current.originalTapStrain >= threeFingerStrainThreshold) {
|
|
1919
|
-
inSpeedSection = true;
|
|
1920
|
-
newFirstObjectIndex = i;
|
|
1949
|
+
if (i - firstSpeedObjectIndex < minSectionObjectCount) {
|
|
1921
1950
|
continue;
|
|
1922
1951
|
}
|
|
1923
|
-
if (inSpeedSection &&
|
|
1924
|
-
current.originalTapStrain < threeFingerStrainThreshold) {
|
|
1925
|
-
inSpeedSection = false;
|
|
1926
|
-
// Ignore sections that don't meet object count requirement.
|
|
1927
|
-
if (i - newFirstObjectIndex < minSectionObjectCount) {
|
|
1928
|
-
continue;
|
|
1929
|
-
}
|
|
1930
|
-
this.attributes.possibleThreeFingeredSections.push({
|
|
1931
|
-
firstObjectIndex: newFirstObjectIndex,
|
|
1932
|
-
lastObjectIndex: i,
|
|
1933
|
-
sumStrain: this.calculateThreeFingerSummedStrain(newFirstObjectIndex, i),
|
|
1934
|
-
});
|
|
1935
|
-
}
|
|
1936
|
-
}
|
|
1937
|
-
// Don't forget to manually add the last beatmap section, which would otherwise be ignored.
|
|
1938
|
-
// Ignore sections that don't meet object count requirement.
|
|
1939
|
-
if (inSpeedSection &&
|
|
1940
|
-
section.lastObjectIndex - newFirstObjectIndex >=
|
|
1941
|
-
minSectionObjectCount) {
|
|
1942
1952
|
this.attributes.possibleThreeFingeredSections.push({
|
|
1943
|
-
firstObjectIndex:
|
|
1944
|
-
lastObjectIndex:
|
|
1945
|
-
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),
|
|
1946
1960
|
});
|
|
1947
1961
|
}
|
|
1948
1962
|
}
|
|
1949
|
-
if (maxStrain) {
|
|
1950
|
-
this.attributes.speedNoteCount = objectStrains.reduce((total, next) => total + 1 / (1 + Math.exp(-((next / maxStrain) * 12 - 6))), 0);
|
|
1951
|
-
this.attributes.averageSpeedDeltaTime =
|
|
1952
|
-
objectDeltaTimes.reduce((total, next, index) => total +
|
|
1953
|
-
(next * 1) /
|
|
1954
|
-
(1 +
|
|
1955
|
-
Math.exp(-((objectStrains[index] / maxStrain) *
|
|
1956
|
-
25 -
|
|
1957
|
-
20))), 0) /
|
|
1958
|
-
objectStrains.reduce((total, next) => total +
|
|
1959
|
-
1 / (1 + Math.exp(-((next / maxStrain) * 25 - 20))), 0);
|
|
1960
|
-
this.attributes.tapDifficultStrainCount = objectStrains.reduce((total, next) => total + Math.pow(next / maxStrain, 4), 0);
|
|
1961
|
-
}
|
|
1962
|
-
}
|
|
1963
|
-
/**
|
|
1964
|
-
* Calculates the sum of strains for possible three-fingered sections.
|
|
1965
|
-
*
|
|
1966
|
-
* @param firstObjectIndex The index of the first object in the section.
|
|
1967
|
-
* @param lastObjectIndex The index of the last object in the section.
|
|
1968
|
-
* @returns The summed strain of the section.
|
|
1969
|
-
*/
|
|
1970
|
-
calculateThreeFingerSummedStrain(firstObjectIndex, lastObjectIndex) {
|
|
1971
|
-
return Math.pow(this.objects
|
|
1972
|
-
.slice(firstObjectIndex, lastObjectIndex)
|
|
1973
|
-
.reduce((a, v) => a +
|
|
1974
|
-
v.originalTapStrain /
|
|
1975
|
-
DroidDifficultyCalculator.threeFingerStrainThreshold, 0), 0.75);
|
|
1976
1963
|
}
|
|
1977
1964
|
/**
|
|
1978
1965
|
* Called after rhythm skill calculation.
|
|
@@ -1980,7 +1967,7 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
|
1980
1967
|
* @param rhythmSkill The rhythm skill.
|
|
1981
1968
|
*/
|
|
1982
1969
|
postCalculateRhythm(rhythmSkill) {
|
|
1983
|
-
this.
|
|
1970
|
+
this.attributes.rhythmDifficulty = this.mods.some((m) => m instanceof osuBase.ModRelax)
|
|
1984
1971
|
? 0
|
|
1985
1972
|
: this.starValue(rhythmSkill.difficultyValue());
|
|
1986
1973
|
}
|
|
@@ -1992,21 +1979,17 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
|
1992
1979
|
*/
|
|
1993
1980
|
postCalculateFlashlight(flashlightSkill, flashlightSkillWithoutSliders) {
|
|
1994
1981
|
this.strainPeaks.flashlight = flashlightSkill.strainPeaks;
|
|
1995
|
-
this.
|
|
1982
|
+
this.attributes.flashlightDifficulty = this.starValue(flashlightSkill.difficultyValue());
|
|
1996
1983
|
if (this.flashlight) {
|
|
1997
1984
|
this.attributes.flashlightSliderFactor =
|
|
1998
1985
|
this.starValue(flashlightSkillWithoutSliders.difficultyValue()) / this.flashlight;
|
|
1999
1986
|
}
|
|
2000
1987
|
if (this.mods.some((m) => m instanceof osuBase.ModRelax)) {
|
|
2001
|
-
this.
|
|
2002
|
-
}
|
|
2003
|
-
const objectStrains = this.objects.map((v) => v.flashlightStrainWithSliders);
|
|
2004
|
-
const maxStrain = Math.max(...objectStrains);
|
|
2005
|
-
if (maxStrain) {
|
|
2006
|
-
this.attributes.flashlightDifficultStrainCount =
|
|
2007
|
-
objectStrains.reduce((total, next) => total + Math.pow(next / maxStrain, 4), 0);
|
|
1988
|
+
this.attributes.flashlightDifficulty *= 0.7;
|
|
2008
1989
|
}
|
|
2009
1990
|
this.attributes.flashlightDifficulty = this.flashlight;
|
|
1991
|
+
this.attributes.flashlightDifficultStrainCount =
|
|
1992
|
+
flashlightSkill.countDifficultStrains();
|
|
2010
1993
|
}
|
|
2011
1994
|
/**
|
|
2012
1995
|
* Called after visual skill calculation.
|
|
@@ -2015,7 +1998,7 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
|
2015
1998
|
* @param visualSkillWithoutSliders The visual skill that doesn't consider sliders.
|
|
2016
1999
|
*/
|
|
2017
2000
|
postCalculateVisual(visualSkillWithSliders, visualSkillWithoutSliders) {
|
|
2018
|
-
this.
|
|
2001
|
+
this.attributes.visualDifficulty = this.mods.some((m) => m instanceof osuBase.ModRelax)
|
|
2019
2002
|
? 0
|
|
2020
2003
|
: this.starValue(visualSkillWithSliders.difficultyValue());
|
|
2021
2004
|
if (this.visual) {
|
|
@@ -2023,11 +2006,8 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
|
2023
2006
|
this.starValue(visualSkillWithoutSliders.difficultyValue()) /
|
|
2024
2007
|
this.visual;
|
|
2025
2008
|
}
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
if (maxStrain) {
|
|
2029
|
-
this.attributes.visualDifficultStrainCount = objectStrains.reduce((total, next) => total + Math.pow(next / maxStrain, 4), 0);
|
|
2030
|
-
}
|
|
2009
|
+
this.attributes.visualDifficultStrainCount =
|
|
2010
|
+
visualSkillWithSliders.countDifficultStrains();
|
|
2031
2011
|
}
|
|
2032
2012
|
}
|
|
2033
2013
|
|
|
@@ -2394,7 +2374,7 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
|
|
|
2394
2374
|
*/
|
|
2395
2375
|
calculateAimValue() {
|
|
2396
2376
|
let aimValue = this.baseValue(Math.pow(this.difficultyAttributes.aimDifficulty, 0.8));
|
|
2397
|
-
aimValue *= this.proportionalMissPenalty;
|
|
2377
|
+
aimValue *= Math.min(this.calculateStrainBasedMissPenalty(this.difficultyAttributes.aimDifficultStrainCount), this.proportionalMissPenalty);
|
|
2398
2378
|
// Scale the aim value with estimated full combo deviation.
|
|
2399
2379
|
aimValue *= this.calculateDeviationBasedLengthScaling();
|
|
2400
2380
|
// Scale the aim value with slider factor to nerf very likely dropped sliderends.
|
|
@@ -2424,16 +2404,26 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
|
|
|
2424
2404
|
// We expect the player to get 7500/x deviation when doubletapping x BPM.
|
|
2425
2405
|
// Using this expectation, we penalize scores with deviation above 25.
|
|
2426
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))));
|
|
2427
2413
|
// Scale the tap value with tap deviation.
|
|
2428
2414
|
tapValue *=
|
|
2429
2415
|
1.1 *
|
|
2430
|
-
Math.pow(osuBase.ErrorFunction.erf(20 / (Math.SQRT2 *
|
|
2431
|
-
//
|
|
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.
|
|
2432
2421
|
tapValue *=
|
|
2433
|
-
1 /
|
|
2422
|
+
(1 - Math.pow(this.difficultyAttributes.vibroFactor, 6)) /
|
|
2434
2423
|
(1 +
|
|
2435
|
-
Math.exp((this.
|
|
2436
|
-
((
|
|
2424
|
+
Math.exp((this._tapDeviation - 7500 / averageBPM) /
|
|
2425
|
+
((2 * 300) / averageBPM))) +
|
|
2426
|
+
Math.pow(this.difficultyAttributes.vibroFactor, 6);
|
|
2437
2427
|
// Scale the tap value with three-fingered penalty.
|
|
2438
2428
|
tapValue /= this._tapPenalty;
|
|
2439
2429
|
// OD 8 SS stays the same.
|
|
@@ -2474,7 +2464,7 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
|
|
|
2474
2464
|
return 0;
|
|
2475
2465
|
}
|
|
2476
2466
|
let flashlightValue = Math.pow(this.difficultyAttributes.flashlightDifficulty, 1.6) * 25;
|
|
2477
|
-
flashlightValue *= this.proportionalMissPenalty;
|
|
2467
|
+
flashlightValue *= Math.min(this.calculateStrainBasedMissPenalty(this.difficultyAttributes.flashlightDifficultStrainCount), this.proportionalMissPenalty);
|
|
2478
2468
|
// Account for shorter maps having a higher ratio of 0 combo/100 combo flashlight radius.
|
|
2479
2469
|
flashlightValue *=
|
|
2480
2470
|
0.7 +
|
|
@@ -2493,7 +2483,7 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
|
|
|
2493
2483
|
*/
|
|
2494
2484
|
calculateVisualValue() {
|
|
2495
2485
|
let visualValue = Math.pow(this.difficultyAttributes.visualDifficulty, 1.6) * 22.5;
|
|
2496
|
-
visualValue *= this.proportionalMissPenalty;
|
|
2486
|
+
visualValue *= Math.min(this.calculateStrainBasedMissPenalty(this.difficultyAttributes.visualDifficultStrainCount), this.proportionalMissPenalty);
|
|
2497
2487
|
// Scale the visual value with estimated full combo deviation.
|
|
2498
2488
|
// As visual is easily "bypassable" with memorization, punish for memorization.
|
|
2499
2489
|
visualValue *= this.calculateDeviationBasedLengthScaling(undefined, true);
|
|
@@ -2657,23 +2647,59 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
|
|
|
2657
2647
|
if (this.totalSuccessfulHits === 0) {
|
|
2658
2648
|
return Number.POSITIVE_INFINITY;
|
|
2659
2649
|
}
|
|
2660
|
-
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;
|
|
2661
2657
|
const { n100, n50, nmiss } = this.computedAccuracy;
|
|
2662
2658
|
// Assume a fixed ratio of non-300s hit in speed notes based on speed note count ratio and OD.
|
|
2663
2659
|
// Graph: https://www.desmos.com/calculator/iskvgjkxr4
|
|
2664
|
-
const speedNoteRatio =
|
|
2660
|
+
const speedNoteRatio = speedNoteCount / this.totalHits;
|
|
2665
2661
|
const nonGreatCount = n100 + n50 + nmiss;
|
|
2666
2662
|
const nonGreatRatio = 1 -
|
|
2667
2663
|
(Math.pow(Math.exp(Math.sqrt(hitWindow300)) + 1, 1 - speedNoteRatio) -
|
|
2668
2664
|
1) /
|
|
2669
2665
|
Math.exp(Math.sqrt(hitWindow300));
|
|
2670
|
-
const relevantCountGreat = Math.max(0,
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
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;
|
|
2674
2701
|
}
|
|
2675
|
-
|
|
2676
|
-
return (hitWindow300 / (Math.SQRT2 * osuBase.ErrorFunction.erfInv(greatProbability)));
|
|
2702
|
+
return Number.POSITIVE_INFINITY;
|
|
2677
2703
|
}
|
|
2678
2704
|
toString() {
|
|
2679
2705
|
return (this.total.toFixed(2) +
|
|
@@ -3071,9 +3097,9 @@ class OsuSpeed extends OsuSkill {
|
|
|
3071
3097
|
currentRhythm = 0;
|
|
3072
3098
|
skillMultiplier = 1375;
|
|
3073
3099
|
greatWindow;
|
|
3074
|
-
constructor(mods,
|
|
3100
|
+
constructor(mods, overallDifficulty) {
|
|
3075
3101
|
super(mods);
|
|
3076
|
-
this.greatWindow =
|
|
3102
|
+
this.greatWindow = new osuBase.OsuHitWindow(overallDifficulty).hitWindowFor300();
|
|
3077
3103
|
}
|
|
3078
3104
|
/**
|
|
3079
3105
|
* @param current The hitobject to calculate.
|
|
@@ -3120,7 +3146,7 @@ class OsuFlashlightEvaluator extends FlashlightEvaluator {
|
|
|
3120
3146
|
if (current.object instanceof osuBase.Spinner) {
|
|
3121
3147
|
return 0;
|
|
3122
3148
|
}
|
|
3123
|
-
const scalingFactor = 52 / current.object.
|
|
3149
|
+
const scalingFactor = 52 / current.object.radius;
|
|
3124
3150
|
let smallDistNerf = 1;
|
|
3125
3151
|
let cumulativeStrainTime = 0;
|
|
3126
3152
|
let result = 0;
|
|
@@ -3174,8 +3200,8 @@ class OsuFlashlightEvaluator extends FlashlightEvaluator {
|
|
|
3174
3200
|
// Longer sliders require more memorization.
|
|
3175
3201
|
sliderBonus *= pixelTravelDistance;
|
|
3176
3202
|
// Nerf sliders with repeats, as less memorization is required.
|
|
3177
|
-
if (current.object.
|
|
3178
|
-
sliderBonus /= current.object.
|
|
3203
|
+
if (current.object.repeatCount > 0)
|
|
3204
|
+
sliderBonus /= current.object.repeatCount + 1;
|
|
3179
3205
|
}
|
|
3180
3206
|
result += sliderBonus * this.sliderMultiplier;
|
|
3181
3207
|
return result;
|
|
@@ -3212,6 +3238,46 @@ class OsuFlashlight extends OsuSkill {
|
|
|
3212
3238
|
}
|
|
3213
3239
|
}
|
|
3214
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
|
+
|
|
3215
3281
|
/**
|
|
3216
3282
|
* A difficulty calculator for osu!standard gamemode.
|
|
3217
3283
|
*/
|
|
@@ -3219,15 +3285,21 @@ class OsuDifficultyCalculator extends DifficultyCalculator {
|
|
|
3219
3285
|
/**
|
|
3220
3286
|
* The aim star rating of the beatmap.
|
|
3221
3287
|
*/
|
|
3222
|
-
aim
|
|
3288
|
+
get aim() {
|
|
3289
|
+
return this.attributes.aimDifficulty;
|
|
3290
|
+
}
|
|
3223
3291
|
/**
|
|
3224
3292
|
* The speed star rating of the beatmap.
|
|
3225
3293
|
*/
|
|
3226
|
-
speed
|
|
3294
|
+
get speed() {
|
|
3295
|
+
return this.attributes.speedDifficulty;
|
|
3296
|
+
}
|
|
3227
3297
|
/**
|
|
3228
3298
|
* The flashlight star rating of the beatmap.
|
|
3229
3299
|
*/
|
|
3230
|
-
flashlight
|
|
3300
|
+
get flashlight() {
|
|
3301
|
+
return this.attributes.flashlightDifficulty;
|
|
3302
|
+
}
|
|
3231
3303
|
attributes = {
|
|
3232
3304
|
speedDifficulty: 0,
|
|
3233
3305
|
mods: [],
|
|
@@ -3265,7 +3337,7 @@ class OsuDifficultyCalculator extends DifficultyCalculator {
|
|
|
3265
3337
|
* Calculates the speed star rating of the beatmap and stores it in this instance.
|
|
3266
3338
|
*/
|
|
3267
3339
|
calculateSpeed() {
|
|
3268
|
-
const speedSkill = new OsuSpeed(this.mods,
|
|
3340
|
+
const speedSkill = new OsuSpeed(this.mods, this.difficultyStatistics.overallDifficulty);
|
|
3269
3341
|
this.calculateSkills(speedSkill);
|
|
3270
3342
|
this.postCalculateSpeed(speedSkill);
|
|
3271
3343
|
}
|
|
@@ -3290,14 +3362,14 @@ class OsuDifficultyCalculator extends DifficultyCalculator {
|
|
|
3290
3362
|
if (basePerformanceValue > 1e-5) {
|
|
3291
3363
|
// Document for formula derivation:
|
|
3292
3364
|
// https://docs.google.com/document/d/10DZGYYSsT_yjz2Mtp6yIJld0Rqx4E-vVHupCqiM4TNI/edit
|
|
3293
|
-
this.
|
|
3365
|
+
this.attributes.starRating =
|
|
3294
3366
|
Math.cbrt(1.14) *
|
|
3295
3367
|
0.027 *
|
|
3296
3368
|
(Math.cbrt((100000 / Math.pow(2, 1 / 1.1)) * basePerformanceValue) +
|
|
3297
3369
|
4);
|
|
3298
3370
|
}
|
|
3299
3371
|
else {
|
|
3300
|
-
this.
|
|
3372
|
+
this.attributes.starRating = 0;
|
|
3301
3373
|
}
|
|
3302
3374
|
}
|
|
3303
3375
|
calculateAll() {
|
|
@@ -3323,22 +3395,32 @@ class OsuDifficultyCalculator extends DifficultyCalculator {
|
|
|
3323
3395
|
this.flashlight.toFixed(2) +
|
|
3324
3396
|
" flashlight)");
|
|
3325
3397
|
}
|
|
3326
|
-
|
|
3327
|
-
const
|
|
3328
|
-
|
|
3329
|
-
|
|
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);
|
|
3330
3405
|
}
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
}
|
|
3335
|
-
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
|
+
});
|
|
3336
3418
|
}
|
|
3337
3419
|
createSkills() {
|
|
3338
3420
|
return [
|
|
3339
3421
|
new OsuAim(this.mods, true),
|
|
3340
3422
|
new OsuAim(this.mods, false),
|
|
3341
|
-
new OsuSpeed(this.mods,
|
|
3423
|
+
new OsuSpeed(this.mods, this.difficultyStatistics.overallDifficulty),
|
|
3342
3424
|
new OsuFlashlight(this.mods),
|
|
3343
3425
|
];
|
|
3344
3426
|
}
|
|
@@ -3351,19 +3433,18 @@ class OsuDifficultyCalculator extends DifficultyCalculator {
|
|
|
3351
3433
|
postCalculateAim(aimSkill, aimSkillWithoutSliders) {
|
|
3352
3434
|
this.strainPeaks.aimWithSliders = aimSkill.strainPeaks;
|
|
3353
3435
|
this.strainPeaks.aimWithoutSliders = aimSkillWithoutSliders.strainPeaks;
|
|
3354
|
-
this.
|
|
3436
|
+
this.attributes.aimDifficulty = this.starValue(aimSkill.difficultyValue());
|
|
3355
3437
|
if (this.aim) {
|
|
3356
3438
|
this.attributes.sliderFactor =
|
|
3357
3439
|
this.starValue(aimSkillWithoutSliders.difficultyValue()) /
|
|
3358
3440
|
this.aim;
|
|
3359
3441
|
}
|
|
3360
3442
|
if (this.mods.some((m) => m instanceof osuBase.ModTouchDevice)) {
|
|
3361
|
-
this.
|
|
3443
|
+
this.attributes.aimDifficulty = Math.pow(this.aim, 0.8);
|
|
3362
3444
|
}
|
|
3363
3445
|
if (this.mods.some((m) => m instanceof osuBase.ModRelax)) {
|
|
3364
|
-
this.
|
|
3446
|
+
this.attributes.aimDifficulty *= 0.9;
|
|
3365
3447
|
}
|
|
3366
|
-
this.attributes.aimDifficulty = this.aim;
|
|
3367
3448
|
}
|
|
3368
3449
|
/**
|
|
3369
3450
|
* Called after speed skill calculation.
|
|
@@ -3372,7 +3453,7 @@ class OsuDifficultyCalculator extends DifficultyCalculator {
|
|
|
3372
3453
|
*/
|
|
3373
3454
|
postCalculateSpeed(speedSkill) {
|
|
3374
3455
|
this.strainPeaks.speed = speedSkill.strainPeaks;
|
|
3375
|
-
this.
|
|
3456
|
+
this.attributes.speedDifficulty = this.mods.some((m) => m instanceof osuBase.ModRelax)
|
|
3376
3457
|
? 0
|
|
3377
3458
|
: this.starValue(speedSkill.difficultyValue());
|
|
3378
3459
|
this.calculateSpeedAttributes();
|
|
@@ -3394,55 +3475,13 @@ class OsuDifficultyCalculator extends DifficultyCalculator {
|
|
|
3394
3475
|
*/
|
|
3395
3476
|
postCalculateFlashlight(flashlightSkill) {
|
|
3396
3477
|
this.strainPeaks.flashlight = flashlightSkill.strainPeaks;
|
|
3397
|
-
this.
|
|
3478
|
+
this.attributes.flashlightDifficulty = this.starValue(flashlightSkill.difficultyValue());
|
|
3398
3479
|
if (this.mods.some((m) => m instanceof osuBase.ModTouchDevice)) {
|
|
3399
|
-
this.
|
|
3480
|
+
this.attributes.flashlightDifficulty = Math.pow(this.flashlight, 0.8);
|
|
3400
3481
|
}
|
|
3401
3482
|
if (this.mods.some((m) => m instanceof osuBase.ModRelax)) {
|
|
3402
|
-
this.
|
|
3483
|
+
this.attributes.flashlightDifficulty *= 0.7;
|
|
3403
3484
|
}
|
|
3404
|
-
this.attributes.flashlightDifficulty = this.flashlight;
|
|
3405
|
-
}
|
|
3406
|
-
}
|
|
3407
|
-
|
|
3408
|
-
/**
|
|
3409
|
-
* A difficulty calculator that calculates for both osu!droid and osu!standard gamemode.
|
|
3410
|
-
*/
|
|
3411
|
-
class MapStars {
|
|
3412
|
-
/**
|
|
3413
|
-
* The osu!droid difficulty calculator of the beatmap.
|
|
3414
|
-
*/
|
|
3415
|
-
droid;
|
|
3416
|
-
/**
|
|
3417
|
-
* The osu!standard difficulty calculator of the beatmap.
|
|
3418
|
-
*/
|
|
3419
|
-
osu;
|
|
3420
|
-
/**
|
|
3421
|
-
* Constructs this instance and calculates the given beatmap's osu!droid and osu!standard difficulty.
|
|
3422
|
-
*
|
|
3423
|
-
* @param beatmap The beatmap to calculate.
|
|
3424
|
-
* @param options Options for the difficulty calculation.
|
|
3425
|
-
*/
|
|
3426
|
-
constructor(beatmap, options) {
|
|
3427
|
-
const stats = new osuBase.MapStats({
|
|
3428
|
-
speedMultiplier: options?.stats?.speedMultiplier ?? 1,
|
|
3429
|
-
isForceAR: options?.stats?.isForceAR ?? false,
|
|
3430
|
-
oldStatistics: options?.stats?.oldStatistics ?? false,
|
|
3431
|
-
});
|
|
3432
|
-
this.droid = new DroidDifficultyCalculator(beatmap).calculate({
|
|
3433
|
-
...options,
|
|
3434
|
-
stats,
|
|
3435
|
-
});
|
|
3436
|
-
this.osu = new OsuDifficultyCalculator(beatmap).calculate({
|
|
3437
|
-
...options,
|
|
3438
|
-
stats,
|
|
3439
|
-
});
|
|
3440
|
-
}
|
|
3441
|
-
/**
|
|
3442
|
-
* Returns a string representative of the class.
|
|
3443
|
-
*/
|
|
3444
|
-
toString() {
|
|
3445
|
-
return `${this.droid.toString()}\n${this.osu.toString()}`;
|
|
3446
3485
|
}
|
|
3447
3486
|
}
|
|
3448
3487
|
|
|
@@ -3669,7 +3708,6 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
|
|
|
3669
3708
|
exports.AimEvaluator = AimEvaluator;
|
|
3670
3709
|
exports.DifficultyCalculator = DifficultyCalculator;
|
|
3671
3710
|
exports.DifficultyHitObject = DifficultyHitObject;
|
|
3672
|
-
exports.DifficultyHitObjectCreator = DifficultyHitObjectCreator;
|
|
3673
3711
|
exports.DroidAim = DroidAim;
|
|
3674
3712
|
exports.DroidAimEvaluator = DroidAimEvaluator;
|
|
3675
3713
|
exports.DroidDifficultyCalculator = DroidDifficultyCalculator;
|
|
@@ -3684,7 +3722,6 @@ exports.DroidTapEvaluator = DroidTapEvaluator;
|
|
|
3684
3722
|
exports.DroidVisual = DroidVisual;
|
|
3685
3723
|
exports.DroidVisualEvaluator = DroidVisualEvaluator;
|
|
3686
3724
|
exports.FlashlightEvaluator = FlashlightEvaluator;
|
|
3687
|
-
exports.MapStars = MapStars;
|
|
3688
3725
|
exports.OsuAim = OsuAim;
|
|
3689
3726
|
exports.OsuAimEvaluator = OsuAimEvaluator;
|
|
3690
3727
|
exports.OsuDifficultyCalculator = OsuDifficultyCalculator;
|