@rian8337/osu-difficulty-calculator 4.0.0-beta.102 → 4.0.0-beta.104
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/README.md +10 -10
- package/dist/index.cjs +3945 -0
- package/dist/index.d.cts +2038 -0
- package/dist/index.d.mts +2038 -0
- package/dist/index.mjs +3909 -0
- package/package.json +28 -12
- package/dist/index.js +0 -5727
- package/typings/index.d.ts +0 -2098
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,3945 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let _rian8337_osu_base = require("@rian8337/osu-base");
|
|
3
|
+
// src/base/DifficultyCalculator.ts
|
|
4
|
+
/**
|
|
5
|
+
* The base of a difficulty calculator.
|
|
6
|
+
*/
|
|
7
|
+
var DifficultyCalculator = class {
|
|
8
|
+
/**
|
|
9
|
+
* `Mod`s that adjust the difficulty of a beatmap.
|
|
10
|
+
*/
|
|
11
|
+
difficultyAdjustmentMods = [
|
|
12
|
+
_rian8337_osu_base.ModDifficultyAdjust,
|
|
13
|
+
_rian8337_osu_base.ModRateAdjust,
|
|
14
|
+
_rian8337_osu_base.ModTimeRamp,
|
|
15
|
+
_rian8337_osu_base.ModEasy,
|
|
16
|
+
_rian8337_osu_base.ModHardRock,
|
|
17
|
+
_rian8337_osu_base.ModFlashlight,
|
|
18
|
+
_rian8337_osu_base.ModHidden,
|
|
19
|
+
_rian8337_osu_base.ModRelax,
|
|
20
|
+
_rian8337_osu_base.ModAutopilot,
|
|
21
|
+
_rian8337_osu_base.ModMirror,
|
|
22
|
+
_rian8337_osu_base.ModRandom
|
|
23
|
+
];
|
|
24
|
+
/**
|
|
25
|
+
* Calculates the difficulty of a `Beatmap` with specific `Mod`s.
|
|
26
|
+
*
|
|
27
|
+
* @param beatmap The `Beatmap` whose difficulty is to be calculated.
|
|
28
|
+
* @param mods The `Mod`s to apply to the beatmap. Defaults to No Mod.
|
|
29
|
+
* @returns A `DifficultyAttributes` object describing the difficulty of the `Beatmap`.
|
|
30
|
+
*/
|
|
31
|
+
calculate(beatmap, mods) {
|
|
32
|
+
const playableBeatmap = this.createPlayableBeatmap(beatmap, mods);
|
|
33
|
+
const skills = this.createSkills(playableBeatmap);
|
|
34
|
+
const objects = this.createDifficultyHitObjects(playableBeatmap);
|
|
35
|
+
for (const object of objects) for (const skill of skills) skill.process(object);
|
|
36
|
+
return this.createDifficultyAttributes(beatmap, playableBeatmap, skills, objects);
|
|
37
|
+
}
|
|
38
|
+
calculateStrainPeaks(beatmap, mods) {
|
|
39
|
+
const playableBeatmap = beatmap instanceof _rian8337_osu_base.PlayableBeatmap ? beatmap : this.createPlayableBeatmap(beatmap, mods);
|
|
40
|
+
const skills = this.createStrainPeakSkills(playableBeatmap);
|
|
41
|
+
const objects = this.createDifficultyHitObjects(playableBeatmap);
|
|
42
|
+
for (const object of objects) for (const skill of skills) skill.process(object);
|
|
43
|
+
return {
|
|
44
|
+
aimWithSliders: skills[0].peaks,
|
|
45
|
+
aimWithoutSliders: skills[1].peaks,
|
|
46
|
+
speed: skills[2].peaks,
|
|
47
|
+
flashlight: skills[3].peaks
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Calculates the difficulty of a `Beatmap` with specific `Mod`s and returns a set of
|
|
52
|
+
* `TimedDifficultyAttributes` representing the difficulty at every relevant time value in the `Beatmap`.
|
|
53
|
+
*
|
|
54
|
+
* @param beatmap The `Beatmap` whose difficulty is to be calculated.
|
|
55
|
+
* @param mods The `Mod`s to apply to the `Beatmap`.
|
|
56
|
+
* @return The set of `TimedDifficultyAttributes`.
|
|
57
|
+
*/
|
|
58
|
+
calculateTimed(beatmap, mods) {
|
|
59
|
+
if (beatmap.hitObjects.objects.length === 0) return [];
|
|
60
|
+
const playableBeatmap = this.createPlayableBeatmap(beatmap, mods);
|
|
61
|
+
const attributes = _rian8337_osu_base.Utils.initializeArray(beatmap.hitObjects.objects.length);
|
|
62
|
+
const skills = this.createSkills(playableBeatmap);
|
|
63
|
+
const progressiveBeatmap = new ProgressiveCalculationBeatmap(playableBeatmap);
|
|
64
|
+
const { objects } = playableBeatmap.hitObjects;
|
|
65
|
+
const difficultyObjects = this.createDifficultyHitObjects(playableBeatmap);
|
|
66
|
+
let currentIndex = 0;
|
|
67
|
+
for (let i = 0; i < objects.length; ++i) {
|
|
68
|
+
const obj = objects[i];
|
|
69
|
+
progressiveBeatmap.hitObjects.add(obj);
|
|
70
|
+
while (currentIndex < difficultyObjects.length && difficultyObjects[currentIndex].object.endTime <= obj.endTime) {
|
|
71
|
+
for (const skill of skills) skill.process(difficultyObjects[currentIndex]);
|
|
72
|
+
++currentIndex;
|
|
73
|
+
}
|
|
74
|
+
attributes[i] = {
|
|
75
|
+
time: obj.endTime,
|
|
76
|
+
attributes: this.createDifficultyAttributes(beatmap, progressiveBeatmap, skills, difficultyObjects.slice(0, currentIndex)),
|
|
77
|
+
sliderCount: progressiveBeatmap.hitObjects.sliders,
|
|
78
|
+
sliderTickCount: progressiveBeatmap.hitObjects.sliderTicks,
|
|
79
|
+
sliderRepeatCount: progressiveBeatmap.hitObjects.sliderRepeatPoints
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
return attributes;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* A {@link PlayableBeatmap} for timed difficulty calculation.
|
|
87
|
+
*/
|
|
88
|
+
var ProgressiveCalculationBeatmap = class extends _rian8337_osu_base.PlayableBeatmap {
|
|
89
|
+
get maxCombo() {
|
|
90
|
+
return this.hitObjects.maxCombo;
|
|
91
|
+
}
|
|
92
|
+
baseHitWindow;
|
|
93
|
+
constructor(baseBeatmap) {
|
|
94
|
+
super(baseBeatmap, baseBeatmap.mods);
|
|
95
|
+
this.hitObjects = new ProgressiveCalculationHitObjects();
|
|
96
|
+
this.baseHitWindow = baseBeatmap.hitWindow;
|
|
97
|
+
}
|
|
98
|
+
createHitWindow() {
|
|
99
|
+
return this.baseHitWindow;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
var ProgressiveCalculationHitObjects = class extends _rian8337_osu_base.BeatmapHitObjects {
|
|
103
|
+
maxCombo = 0;
|
|
104
|
+
sliderTickCount = 0;
|
|
105
|
+
sliderRepeatCount = 0;
|
|
106
|
+
get sliderTicks() {
|
|
107
|
+
return this.sliderTickCount;
|
|
108
|
+
}
|
|
109
|
+
get sliderRepeatPoints() {
|
|
110
|
+
return this.sliderRepeatCount;
|
|
111
|
+
}
|
|
112
|
+
add(...objects) {
|
|
113
|
+
super.add(...objects);
|
|
114
|
+
for (const obj of objects) if (obj instanceof _rian8337_osu_base.Slider) {
|
|
115
|
+
this.maxCombo += obj.nestedHitObjects.length;
|
|
116
|
+
for (const nestedObj of obj.nestedHitObjects) if (nestedObj instanceof _rian8337_osu_base.SliderTick) ++this.sliderTickCount;
|
|
117
|
+
else if (nestedObj instanceof _rian8337_osu_base.SliderRepeat) ++this.sliderRepeatCount;
|
|
118
|
+
} else ++this.maxCombo;
|
|
119
|
+
}
|
|
120
|
+
removeAt(index) {
|
|
121
|
+
const obj = super.removeAt(index);
|
|
122
|
+
if (obj !== null) {
|
|
123
|
+
if (obj instanceof _rian8337_osu_base.Slider) {
|
|
124
|
+
this.maxCombo -= obj.nestedHitObjects.length;
|
|
125
|
+
for (const nestedObj of obj.nestedHitObjects) if (nestedObj instanceof _rian8337_osu_base.SliderTick) --this.sliderTickCount;
|
|
126
|
+
else if (nestedObj instanceof _rian8337_osu_base.SliderRepeat) --this.sliderRepeatCount;
|
|
127
|
+
} else --this.maxCombo;
|
|
128
|
+
}
|
|
129
|
+
return obj;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
// src/base/PerformanceCalculator.ts
|
|
133
|
+
/**
|
|
134
|
+
* The base class of performance calculators.
|
|
135
|
+
*/
|
|
136
|
+
var PerformanceCalculator = class {
|
|
137
|
+
/**
|
|
138
|
+
* The calculated accuracy.
|
|
139
|
+
*/
|
|
140
|
+
computedAccuracy = new _rian8337_osu_base.Accuracy({});
|
|
141
|
+
/**
|
|
142
|
+
* The calculated maximum combo.
|
|
143
|
+
*/
|
|
144
|
+
combo = 0;
|
|
145
|
+
/**
|
|
146
|
+
* The difficulty attributes that is being calculated.
|
|
147
|
+
*/
|
|
148
|
+
difficultyAttributes;
|
|
149
|
+
/**
|
|
150
|
+
* The mods that were used.
|
|
151
|
+
*/
|
|
152
|
+
mods;
|
|
153
|
+
_sliderEndsDropped = 0;
|
|
154
|
+
/**
|
|
155
|
+
* The amount of slider ends dropped in the score.
|
|
156
|
+
*/
|
|
157
|
+
get sliderEndsDropped() {
|
|
158
|
+
return this._sliderEndsDropped;
|
|
159
|
+
}
|
|
160
|
+
_sliderTicksMissed = 0;
|
|
161
|
+
/**
|
|
162
|
+
* The amount of slider ticks missed in the score.
|
|
163
|
+
*
|
|
164
|
+
* This is used to calculate the slider accuracy.
|
|
165
|
+
*/
|
|
166
|
+
get sliderTicksMissed() {
|
|
167
|
+
return this._sliderTicksMissed;
|
|
168
|
+
}
|
|
169
|
+
_usingClassicSliderAccuracy = false;
|
|
170
|
+
/**
|
|
171
|
+
* Whether this score uses classic slider accuracy.
|
|
172
|
+
*/
|
|
173
|
+
get usingClassicSliderAccuracy() {
|
|
174
|
+
return this._usingClassicSliderAccuracy;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* @param difficultyAttributes The difficulty attributes to calculate.
|
|
178
|
+
*/
|
|
179
|
+
constructor(difficultyAttributes) {
|
|
180
|
+
this.difficultyAttributes = difficultyAttributes;
|
|
181
|
+
this.mods = this.isCacheableAttribute(difficultyAttributes) ? _rian8337_osu_base.ModUtil.deserializeMods(difficultyAttributes.mods) : difficultyAttributes.mods;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Calculates the performance points of the beatmap.
|
|
185
|
+
*
|
|
186
|
+
* @param options Options for performance calculation.
|
|
187
|
+
* @returns The attributes representing the performance.
|
|
188
|
+
*/
|
|
189
|
+
calculate(options) {
|
|
190
|
+
this.handleOptions(options);
|
|
191
|
+
return this.createPerformanceAttributes();
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* The total hits that can be done in the beatmap.
|
|
195
|
+
*/
|
|
196
|
+
get totalHits() {
|
|
197
|
+
return this.difficultyAttributes.hitCircleCount + this.difficultyAttributes.sliderCount + this.difficultyAttributes.spinnerCount;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* The total hits that were successfully done.
|
|
201
|
+
*/
|
|
202
|
+
get totalSuccessfulHits() {
|
|
203
|
+
return this.computedAccuracy.n300 + this.computedAccuracy.n100 + this.computedAccuracy.n50;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* The total of imperfect hits (100s, 50s, misses).
|
|
207
|
+
*/
|
|
208
|
+
get totalImperfectHits() {
|
|
209
|
+
return this.computedAccuracy.n100 + this.computedAccuracy.n50 + this.computedAccuracy.nmiss;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Processes given options for usage in performance calculation.
|
|
213
|
+
*
|
|
214
|
+
* @param options Options for performance calculation.
|
|
215
|
+
*/
|
|
216
|
+
handleOptions(options) {
|
|
217
|
+
if (options?.accPercent instanceof _rian8337_osu_base.Accuracy) {
|
|
218
|
+
this.computedAccuracy = new _rian8337_osu_base.Accuracy(options.accPercent);
|
|
219
|
+
if (!this.computedAccuracy.isN300Resolved) this.computedAccuracy.n300 = Math.max(0, this.totalHits - this.computedAccuracy.n100 - this.computedAccuracy.n50 - this.computedAccuracy.nmiss);
|
|
220
|
+
else this.computedAccuracy.nmiss = Math.max(0, this.totalHits - this.totalSuccessfulHits);
|
|
221
|
+
} else if (options?.accPercent !== void 0) this.computedAccuracy = _rian8337_osu_base.Accuracy.fromPercent(options.accPercent, this.totalHits, options.miss ?? 0);
|
|
222
|
+
else this.computedAccuracy = _rian8337_osu_base.Accuracy.fromHitCounts({ nmiss: options?.miss ?? 0 }, this.totalHits);
|
|
223
|
+
const maxCombo = this.difficultyAttributes.maxCombo;
|
|
224
|
+
const miss = this.computedAccuracy.nmiss;
|
|
225
|
+
this.combo = options?.combo ?? maxCombo - miss;
|
|
226
|
+
if (options?.sliderEndsDropped !== void 0 && options.sliderTicksMissed !== void 0) {
|
|
227
|
+
this._usingClassicSliderAccuracy = false;
|
|
228
|
+
this._sliderEndsDropped = options.sliderEndsDropped;
|
|
229
|
+
this._sliderTicksMissed = options.sliderTicksMissed;
|
|
230
|
+
} else {
|
|
231
|
+
this._usingClassicSliderAccuracy = true;
|
|
232
|
+
this._sliderEndsDropped = 0;
|
|
233
|
+
this._sliderTicksMissed = 0;
|
|
234
|
+
}
|
|
235
|
+
this.combo = _rian8337_osu_base.MathUtils.clamp(this.combo, 0, maxCombo - miss - this.sliderEndsDropped - this.sliderTicksMissed);
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Determines whether an attribute is a cacheable attribute.
|
|
239
|
+
*
|
|
240
|
+
* @param attributes The attributes to check.
|
|
241
|
+
* @returns Whether the attributes are cacheable.
|
|
242
|
+
*/
|
|
243
|
+
isCacheableAttribute(attributes) {
|
|
244
|
+
return Array.isArray(attributes.mods);
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
// src/structures/StrainPeak.ts
|
|
248
|
+
/**
|
|
249
|
+
* Data class for variable length strain.
|
|
250
|
+
*/
|
|
251
|
+
var StrainPeak = class {
|
|
252
|
+
value;
|
|
253
|
+
sectionLength;
|
|
254
|
+
constructor(value, sectionLength) {
|
|
255
|
+
this.value = value;
|
|
256
|
+
this.sectionLength = Math.round(sectionLength);
|
|
257
|
+
}
|
|
258
|
+
compareTo(other) {
|
|
259
|
+
return this.value - other.value;
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
// src/base/Skill.ts
|
|
263
|
+
/**
|
|
264
|
+
* A bare minimal abstract skill for fully custom skill implementations.
|
|
265
|
+
*/
|
|
266
|
+
var Skill = class {
|
|
267
|
+
/**
|
|
268
|
+
* The mods that this skill processes.
|
|
269
|
+
*/
|
|
270
|
+
mods;
|
|
271
|
+
_objectDifficulties = [];
|
|
272
|
+
/**
|
|
273
|
+
* The difficulties of {@link DifficultyHitObject}s, populated by {@link Skill.process}.
|
|
274
|
+
*/
|
|
275
|
+
get objectDifficulties() {
|
|
276
|
+
return this._objectDifficulties;
|
|
277
|
+
}
|
|
278
|
+
constructor(mods) {
|
|
279
|
+
this.mods = mods;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Calculates the strain value of a hitobject and stores the value in it.
|
|
283
|
+
* This value is affected by previously processed objects.
|
|
284
|
+
*
|
|
285
|
+
* @param current The hitobject to process.
|
|
286
|
+
*/
|
|
287
|
+
process(current) {
|
|
288
|
+
if (current.index < 0) return;
|
|
289
|
+
const difficultyValue = this.processInternal(current);
|
|
290
|
+
this.saveToHitObject(current, difficultyValue);
|
|
291
|
+
this._objectDifficulties.push(difficultyValue);
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Saves the calculated difficulty to a {@link DifficultyHitObject}.
|
|
295
|
+
*
|
|
296
|
+
* @param current The {@link DifficultyHitObject} to save the difficulty to.
|
|
297
|
+
* @param difficulty The difficulty to save.
|
|
298
|
+
*/
|
|
299
|
+
saveToHitObject(current, difficulty) {}
|
|
300
|
+
};
|
|
301
|
+
// src/base/VariableLengthStrainSkill.ts
|
|
302
|
+
/**
|
|
303
|
+
* A skill that evaluates strain over a variable length of time. A new strain peak is created for every
|
|
304
|
+
* {@link DifficultyHitObject}.
|
|
305
|
+
*/
|
|
306
|
+
var VariableLengthStrainSkill = class extends Skill {
|
|
307
|
+
/**
|
|
308
|
+
* The weight by which each strain value decays.
|
|
309
|
+
*/
|
|
310
|
+
decayWeight = .9;
|
|
311
|
+
/**
|
|
312
|
+
* The maximum length of a strain section, in milliseconds.
|
|
313
|
+
*/
|
|
314
|
+
maxSectionLength = 400;
|
|
315
|
+
/**
|
|
316
|
+
* The number of {@link maxSectionLength} sections calculated such that enough of the difficulty value is preserved.
|
|
317
|
+
*
|
|
318
|
+
* This should be overridden if strains are ever used outside of {@link difficultyValue}, or if {@link difficultyValue}
|
|
319
|
+
* is overridden to not use the default geometric sum.
|
|
320
|
+
*
|
|
321
|
+
* This should be removed in the future when a better memory-saving technique is implemented.
|
|
322
|
+
*/
|
|
323
|
+
get maxStoredSections() {
|
|
324
|
+
return 11 / (1 - this.decayWeight);
|
|
325
|
+
}
|
|
326
|
+
currentSectionPeak = 0;
|
|
327
|
+
currentSectionBegin = 0;
|
|
328
|
+
currentSectionEnd = 0;
|
|
329
|
+
totalLength = 0;
|
|
330
|
+
strainPeaks = [];
|
|
331
|
+
/**
|
|
332
|
+
* The peaks of this skill in chronological order, used for graphing purposes.
|
|
333
|
+
*
|
|
334
|
+
* Unlike {@link strainPeaks}, this is never trimmed, as it does not contribute to {@link difficultyValue}.
|
|
335
|
+
*/
|
|
336
|
+
chronologicalPeaks = [];
|
|
337
|
+
get peaks() {
|
|
338
|
+
return this.chronologicalPeaks.concat({
|
|
339
|
+
time: this.currentSectionEnd,
|
|
340
|
+
value: this.currentSectionPeak
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Stores previous strains so that, if a difficult {@link DifficultyHitObject} is followed by an easier
|
|
345
|
+
* {@link DifficultyHitObject}, the difficult one gets a full strain instead of being cut short.
|
|
346
|
+
*/
|
|
347
|
+
queuedStrains = [];
|
|
348
|
+
static difficultyToPerformance(difficulty) {
|
|
349
|
+
return 4 * Math.pow(difficulty, 3);
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Obtains the live strain peaks for each {@link maxSectionLength} of the beatmap, including the
|
|
353
|
+
* peak of the current section.
|
|
354
|
+
*/
|
|
355
|
+
get currentStrainPeaks() {
|
|
356
|
+
return this.strainPeaks.concat(new StrainPeak(this.currentSectionPeak, this.currentSectionEnd - this.currentSectionBegin));
|
|
357
|
+
}
|
|
358
|
+
difficultyValue() {
|
|
359
|
+
const strains = this.currentStrainPeaks.filter((s) => s.value > 0).sort((a, b) => {
|
|
360
|
+
if (a.value === b.value) return b.sectionLength - a.sectionLength;
|
|
361
|
+
return b.value - a.value;
|
|
362
|
+
});
|
|
363
|
+
let time = 0;
|
|
364
|
+
let difficulty = 0;
|
|
365
|
+
for (const strain of strains) {
|
|
366
|
+
const startTime = time;
|
|
367
|
+
const endTime = time + strain.sectionLength;
|
|
368
|
+
const weight = Math.pow(this.decayWeight, startTime) - Math.pow(this.decayWeight, endTime);
|
|
369
|
+
difficulty += strain.value * weight;
|
|
370
|
+
time = endTime;
|
|
371
|
+
}
|
|
372
|
+
return difficulty / (1 - this.decayWeight);
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Returns the number of strains weighed against the top strain.
|
|
376
|
+
*
|
|
377
|
+
* The result is scaled by clock rate as it affects the total number of strains.
|
|
378
|
+
*/
|
|
379
|
+
countTopWeightedStrains(difficultyValue) {
|
|
380
|
+
if (this.objectDifficulties.length === 0) return 0;
|
|
381
|
+
const consistentTopStrain = difficultyValue * (1 - this.decayWeight);
|
|
382
|
+
if (consistentTopStrain === 0) return this.objectDifficulties.length;
|
|
383
|
+
return this.objectDifficulties.reduce((total, next) => total + 1.1 / (1 + Math.exp(-10 * (next / consistentTopStrain - .88))), 0);
|
|
384
|
+
}
|
|
385
|
+
processInternal(current) {
|
|
386
|
+
if (current.index === 0) {
|
|
387
|
+
this.currentSectionBegin = current.startTime;
|
|
388
|
+
this.currentSectionEnd = this.currentSectionBegin + this.maxSectionLength;
|
|
389
|
+
this.currentSectionPeak = this.strainValueAt(current);
|
|
390
|
+
return this.currentSectionPeak;
|
|
391
|
+
}
|
|
392
|
+
this.backfillPeaks(current);
|
|
393
|
+
const currentStrain = this.strainValueAt(current);
|
|
394
|
+
if (currentStrain > this.currentSectionPeak) {
|
|
395
|
+
this.queuedStrains.length = 0;
|
|
396
|
+
this.saveCurrentPeak(current.startTime - this.currentSectionBegin);
|
|
397
|
+
this.currentSectionBegin = current.startTime;
|
|
398
|
+
this.currentSectionEnd = this.currentSectionBegin + this.maxSectionLength;
|
|
399
|
+
this.currentSectionPeak = currentStrain;
|
|
400
|
+
} else {
|
|
401
|
+
while (this.queuedStrains.length > 0 && this.queuedStrains.at(-1).strainValue < currentStrain) this.queuedStrains.pop();
|
|
402
|
+
this.queuedStrains.push({
|
|
403
|
+
strainValue: currentStrain,
|
|
404
|
+
startTime: current.startTime
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
return currentStrain;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Fills the space between the end of the current section and the current {@link DifficultyHitObject}, if any.
|
|
411
|
+
*
|
|
412
|
+
* @param current The current {@link DifficultyHitObject}.
|
|
413
|
+
*/
|
|
414
|
+
backfillPeaks(current) {
|
|
415
|
+
while (current.startTime > this.currentSectionEnd) {
|
|
416
|
+
this.saveCurrentPeak(this.currentSectionEnd - this.currentSectionBegin);
|
|
417
|
+
this.currentSectionBegin = this.currentSectionEnd;
|
|
418
|
+
if (this.queuedStrains.length > 0) {
|
|
419
|
+
const { strainValue, startTime } = this.queuedStrains.shift();
|
|
420
|
+
this.currentSectionEnd = startTime + this.maxSectionLength;
|
|
421
|
+
this.startNewSectionFrom(this.currentSectionBegin, current);
|
|
422
|
+
this.currentSectionPeak = Math.max(this.currentSectionPeak, strainValue);
|
|
423
|
+
} else {
|
|
424
|
+
this.currentSectionEnd = this.currentSectionBegin + this.maxSectionLength;
|
|
425
|
+
this.startNewSectionFrom(this.currentSectionBegin, current);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* Saves the current peak strain level to the list of strain peaks, which will be used to calculate an overall difficulty.
|
|
431
|
+
*/
|
|
432
|
+
saveCurrentPeak(sectionLength) {
|
|
433
|
+
this.addStrainPeakInPlace(new StrainPeak(this.currentSectionPeak, sectionLength));
|
|
434
|
+
this.chronologicalPeaks.push({
|
|
435
|
+
time: this.currentSectionBegin + sectionLength,
|
|
436
|
+
value: this.currentSectionPeak
|
|
437
|
+
});
|
|
438
|
+
this.totalLength += sectionLength;
|
|
439
|
+
const maxTotalLength = this.maxStoredSections * this.maxSectionLength;
|
|
440
|
+
while (this.totalLength > maxTotalLength) this.totalLength -= this.strainPeaks.shift().sectionLength;
|
|
441
|
+
}
|
|
442
|
+
startNewSectionFrom(time, current) {
|
|
443
|
+
this.currentSectionPeak = this.calculateInitialStrain(time, current);
|
|
444
|
+
}
|
|
445
|
+
addStrainPeakInPlace(strainPeak) {
|
|
446
|
+
const { index } = _rian8337_osu_base.Utils.binarySearch(this.strainPeaks, (s) => s.compareTo(strainPeak));
|
|
447
|
+
this.strainPeaks.splice(index, 0, strainPeak);
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
// src/evaluators/droid/DroidAgilityEvaluator.ts
|
|
451
|
+
/**
|
|
452
|
+
* An evaluator for calculating osu!droid agility aim difficulty.
|
|
453
|
+
*/
|
|
454
|
+
var DroidAgilityEvaluator = class {
|
|
455
|
+
/**
|
|
456
|
+
* Evaluates the difficulty of fast aiming the current object.
|
|
457
|
+
*
|
|
458
|
+
* @param current The current object.
|
|
459
|
+
*/
|
|
460
|
+
static evaluateDifficultyOf(current) {
|
|
461
|
+
if (current.object instanceof _rian8337_osu_base.Spinner) return 0;
|
|
462
|
+
const distance = (current.previous(0)?.lazyTravelDistance ?? 0) + current.lazyJumpDistance;
|
|
463
|
+
const distanceCap = current.normalizedDiameter * 1.2;
|
|
464
|
+
let strain = Math.min(distance, distanceCap) / distanceCap * 1e3 / current.strainTime;
|
|
465
|
+
strain *= Math.pow(current.smallCircleBonus, 1.5);
|
|
466
|
+
strain *= this.highBpmBonus(current.strainTime);
|
|
467
|
+
return strain;
|
|
468
|
+
}
|
|
469
|
+
static highBpmBonus(ms) {
|
|
470
|
+
return 1 / (1 - Math.pow(.2, ms / 1e3));
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
// src/evaluators/droid/DroidSnapAimEvaluator.ts
|
|
474
|
+
/**
|
|
475
|
+
* An evaluator for calculating osu!droid snap aim difficulty.
|
|
476
|
+
*/
|
|
477
|
+
var DroidSnapAimEvaluator = class {
|
|
478
|
+
static wideAngleMultiplier = 9.67;
|
|
479
|
+
static acuteAngleMultiplier = 2.41;
|
|
480
|
+
static sliderMultiplier = 1.5;
|
|
481
|
+
static velocityChangeMultiplier = .9;
|
|
482
|
+
static wiggleMultiplier = 1.02;
|
|
483
|
+
static angleRepetitionNoteLimit = 6;
|
|
484
|
+
static maximumRepetitionNerf = .15;
|
|
485
|
+
static maximumVectorInfluence = .5;
|
|
486
|
+
/**
|
|
487
|
+
* Evaluates the difficulty of aiming the current object, based on:
|
|
488
|
+
*
|
|
489
|
+
* - cursor velocity to the current object,
|
|
490
|
+
* - angle difficulty,
|
|
491
|
+
* - sharp velocity increases,
|
|
492
|
+
* - and slider difficulty.
|
|
493
|
+
*
|
|
494
|
+
* @param current The current object.
|
|
495
|
+
* @param withSliders Whether to take slider difficulty into account.
|
|
496
|
+
*/
|
|
497
|
+
static evaluateDifficultyOf(current, withSliders) {
|
|
498
|
+
if (current.object instanceof _rian8337_osu_base.Spinner || current.isOverlapping(true) || current.index <= 1 || current.previous(0)?.object instanceof _rian8337_osu_base.Spinner) return 0;
|
|
499
|
+
const last = current.previous(0);
|
|
500
|
+
const last2 = current.previous(2);
|
|
501
|
+
const radius = current.normalizedRadius;
|
|
502
|
+
const diameter = current.normalizedDiameter;
|
|
503
|
+
const currentDistance = withSliders ? current.lazyJumpDistance : current.jumpDistance;
|
|
504
|
+
let currentVelocity = currentDistance / current.strainTime;
|
|
505
|
+
if (last.object instanceof _rian8337_osu_base.Slider && withSliders) {
|
|
506
|
+
const sliderDistance = last.lazyTravelDistance + current.lazyJumpDistance;
|
|
507
|
+
currentVelocity = Math.max(currentVelocity, sliderDistance / current.strainTime);
|
|
508
|
+
}
|
|
509
|
+
const prevDistance = withSliders ? last.lazyJumpDistance : last.jumpDistance;
|
|
510
|
+
const prevVelocity = prevDistance / last.strainTime;
|
|
511
|
+
let strain = currentVelocity;
|
|
512
|
+
strain *= this.calculateVectorAngleRepetition(current, last);
|
|
513
|
+
if (current.angle !== null && last.angle !== null) {
|
|
514
|
+
const currentAngle = current.angle;
|
|
515
|
+
const lastAngle = last.angle;
|
|
516
|
+
const velocityInfluence = Math.min(currentVelocity, prevVelocity);
|
|
517
|
+
let acuteAngleBonus = 0;
|
|
518
|
+
if (Math.max(current.strainTime, last.strainTime) < 1.25 * Math.min(current.strainTime, last.strainTime)) {
|
|
519
|
+
acuteAngleBonus = this.calculateAcuteAngleAcuteness(current.angle);
|
|
520
|
+
acuteAngleBonus *= .08 + .92 * (1 - Math.min(acuteAngleBonus, Math.pow(this.calculateAcuteAngleAcuteness(lastAngle), 3)));
|
|
521
|
+
acuteAngleBonus *= velocityInfluence * _rian8337_osu_base.MathUtils.smootherstep(_rian8337_osu_base.MathUtils.millisecondsToBPM(current.strainTime, 2), 300, 450) * _rian8337_osu_base.MathUtils.smootherstep(current.lazyJumpDistance, 0, diameter * 2);
|
|
522
|
+
}
|
|
523
|
+
let wideAngleBonus = this.calculateWideAngleAcuteness(current.angle);
|
|
524
|
+
wideAngleBonus *= .25 + .75 * (1 - Math.min(wideAngleBonus, Math.pow(this.calculateWideAngleAcuteness(lastAngle), 3)));
|
|
525
|
+
const wideAngleTimeScale = 1.45;
|
|
526
|
+
let wideAngleCurrentVelocity = currentDistance / Math.pow(current.strainTime, wideAngleTimeScale);
|
|
527
|
+
const wideAnglePrevVelocity = prevDistance / Math.pow(last.strainTime, wideAngleTimeScale);
|
|
528
|
+
if (last.object instanceof _rian8337_osu_base.Slider && withSliders) {
|
|
529
|
+
const sliderDistance = last.lazyTravelDistance + current.lazyJumpDistance;
|
|
530
|
+
wideAngleCurrentVelocity = Math.max(wideAngleCurrentVelocity, sliderDistance / Math.pow(current.strainTime, wideAngleTimeScale));
|
|
531
|
+
}
|
|
532
|
+
wideAngleBonus *= Math.min(wideAngleCurrentVelocity, wideAnglePrevVelocity);
|
|
533
|
+
if (last2 !== null) {
|
|
534
|
+
const distance = last2.object.stackedPosition.getDistance(last.object.stackedPosition);
|
|
535
|
+
if (distance < 1) wideAngleBonus *= 1 - .55 * (1 - distance);
|
|
536
|
+
}
|
|
537
|
+
strain += Math.max(acuteAngleBonus * this.acuteAngleMultiplier, wideAngleBonus * this.wideAngleMultiplier);
|
|
538
|
+
strain += velocityInfluence * _rian8337_osu_base.MathUtils.smootherstep(currentDistance, radius, diameter) * Math.pow(_rian8337_osu_base.MathUtils.reverseLerp(currentDistance, diameter * 3, diameter), 1.8) * _rian8337_osu_base.MathUtils.smootherstep(currentAngle, _rian8337_osu_base.MathUtils.degreesToRadians(110), _rian8337_osu_base.MathUtils.degreesToRadians(60)) * _rian8337_osu_base.MathUtils.smootherstep(prevDistance, radius, diameter) * Math.pow(_rian8337_osu_base.MathUtils.reverseLerp(prevDistance, diameter * 3, diameter), 1.8) * _rian8337_osu_base.MathUtils.smootherstep(lastAngle, _rian8337_osu_base.MathUtils.degreesToRadians(110), _rian8337_osu_base.MathUtils.degreesToRadians(60)) * this.wiggleMultiplier;
|
|
539
|
+
}
|
|
540
|
+
if (Math.max(prevVelocity, currentVelocity)) {
|
|
541
|
+
if (withSliders) currentVelocity = currentDistance / current.strainTime;
|
|
542
|
+
const distanceRatio = _rian8337_osu_base.MathUtils.smoothstep(Math.abs(prevVelocity - currentVelocity) / Math.max(prevVelocity, currentVelocity), 0, 1);
|
|
543
|
+
let velocityChangeBonus = Math.min(diameter * 1.25 / Math.min(current.strainTime, last.strainTime), Math.abs(prevVelocity - currentVelocity)) * distanceRatio;
|
|
544
|
+
velocityChangeBonus *= Math.pow(Math.min(current.strainTime, last.strainTime) / Math.max(current.strainTime, last.strainTime), 2);
|
|
545
|
+
strain += velocityChangeBonus * this.velocityChangeMultiplier;
|
|
546
|
+
}
|
|
547
|
+
if (current.object instanceof _rian8337_osu_base.Slider && withSliders) {
|
|
548
|
+
let sliderBonus = current.travelDistance / current.travelTime;
|
|
549
|
+
sliderBonus = sliderBonus < 1 ? sliderBonus : Math.pow(sliderBonus, .75);
|
|
550
|
+
strain += Math.pow(1 + sliderBonus * this.sliderMultiplier, 1.25) - 1;
|
|
551
|
+
}
|
|
552
|
+
strain *= current.smallCircleBonus;
|
|
553
|
+
strain *= this.highBpmBonus(current.strainTime);
|
|
554
|
+
return strain;
|
|
555
|
+
}
|
|
556
|
+
static calculateWideAngleAcuteness(angle) {
|
|
557
|
+
return _rian8337_osu_base.MathUtils.smoothstep(angle, _rian8337_osu_base.MathUtils.degreesToRadians(40), _rian8337_osu_base.MathUtils.degreesToRadians(140));
|
|
558
|
+
}
|
|
559
|
+
static calculateAcuteAngleAcuteness(angle) {
|
|
560
|
+
return _rian8337_osu_base.MathUtils.smoothstep(angle, _rian8337_osu_base.MathUtils.degreesToRadians(140), _rian8337_osu_base.MathUtils.degreesToRadians(40));
|
|
561
|
+
}
|
|
562
|
+
static highBpmBonus(ms) {
|
|
563
|
+
return 1 / (1 - Math.pow(.03, Math.pow(ms / 1e3, .65)));
|
|
564
|
+
}
|
|
565
|
+
static calculateVectorAngleRepetition(current, prev) {
|
|
566
|
+
if (current.angle === null || prev.angle === null) return 1;
|
|
567
|
+
let constantAngleCount = 0;
|
|
568
|
+
for (let i = 0; i < this.angleRepetitionNoteLimit; ++i) {
|
|
569
|
+
const loopObj = current.previous(i);
|
|
570
|
+
if (!loopObj) break;
|
|
571
|
+
if (Math.max(current.strainTime, loopObj.strainTime) > 1.1 * Math.min(current.strainTime, loopObj.strainTime)) break;
|
|
572
|
+
if (loopObj.normalizedVectorAngle !== null && current.normalizedVectorAngle !== null) {
|
|
573
|
+
const angleDifference = Math.abs(current.normalizedVectorAngle - loopObj.normalizedVectorAngle);
|
|
574
|
+
constantAngleCount += Math.cos(8 * Math.min(_rian8337_osu_base.MathUtils.degreesToRadians(11.25), angleDifference));
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
const vectorRepetition = Math.pow(Math.min(.5 / constantAngleCount, 1), 2);
|
|
578
|
+
const stackFactor = _rian8337_osu_base.MathUtils.smootherstep(current.lazyJumpDistance, 0, current.normalizedDiameter);
|
|
579
|
+
const angleDifferenceAdjusted = Math.cos(2 * Math.min(_rian8337_osu_base.MathUtils.degreesToRadians(45), Math.abs(current.angle - prev.angle) * stackFactor));
|
|
580
|
+
const baseNerf = 1 - this.maximumRepetitionNerf * this.calculateAcuteAngleAcuteness(prev.angle) * angleDifferenceAdjusted;
|
|
581
|
+
return Math.pow(baseNerf + (1 - baseNerf) * vectorRepetition * this.maximumVectorInfluence * stackFactor, 2);
|
|
582
|
+
}
|
|
583
|
+
};
|
|
584
|
+
// src/evaluators/droid/DroidFlowAimEvaluator.ts
|
|
585
|
+
/**
|
|
586
|
+
* An evaluator for calculating osu!droid flow aim difficulty.
|
|
587
|
+
*/
|
|
588
|
+
var DroidFlowAimEvaluator = class {
|
|
589
|
+
static velocityChangeMultiplier = .52;
|
|
590
|
+
static evaluateDifficultyOf(current, withSliders) {
|
|
591
|
+
if (current.object instanceof _rian8337_osu_base.Spinner || current.index <= 1 || current.previous(0)?.object instanceof _rian8337_osu_base.Spinner) return 0;
|
|
592
|
+
const last = current.previous(0);
|
|
593
|
+
const lastLast = current.previous(1);
|
|
594
|
+
const currentDistance = withSliders ? current.lazyJumpDistance : current.jumpDistance;
|
|
595
|
+
const prevDistance = withSliders ? last.lazyJumpDistance : last.jumpDistance;
|
|
596
|
+
let currentVelocity = currentDistance / current.strainTime;
|
|
597
|
+
if (last.object instanceof _rian8337_osu_base.Slider && withSliders) {
|
|
598
|
+
const sliderDistance = last.lazyTravelDistance + current.lazyJumpDistance;
|
|
599
|
+
currentVelocity = Math.max(currentVelocity, sliderDistance / current.strainTime);
|
|
600
|
+
}
|
|
601
|
+
const prevVelocity = prevDistance / last.strainTime;
|
|
602
|
+
let flowDifficulty = currentVelocity;
|
|
603
|
+
flowDifficulty *= Math.sqrt(current.smallCircleBonus);
|
|
604
|
+
flowDifficulty *= 1 + Math.min(.25, Math.pow((Math.max(current.strainTime, last.strainTime) - Math.min(current.strainTime, last.strainTime)) / 50, 4));
|
|
605
|
+
if (current.angle !== null && last.angle !== null) {
|
|
606
|
+
const angleDifference = Math.abs(current.angle - last.angle);
|
|
607
|
+
const angularVelocity = Math.sin(angleDifference / 2) * 180 / (current.strainTime * .1);
|
|
608
|
+
flowDifficulty *= .8 + Math.sqrt(angularVelocity / 270);
|
|
609
|
+
}
|
|
610
|
+
let overlappedNotesWeight = 1;
|
|
611
|
+
if (current.index > 2) {
|
|
612
|
+
const o1 = this.calculateOverlapFactor(current, last);
|
|
613
|
+
const o2 = this.calculateOverlapFactor(current, lastLast);
|
|
614
|
+
const o3 = this.calculateOverlapFactor(last, lastLast);
|
|
615
|
+
overlappedNotesWeight = 1 - o1 * o2 * o3;
|
|
616
|
+
}
|
|
617
|
+
if (current.angle !== null) flowDifficulty += currentVelocity * DroidSnapAimEvaluator.calculateAcuteAngleAcuteness(current.angle) * overlappedNotesWeight;
|
|
618
|
+
if (Math.max(prevVelocity, currentVelocity)) {
|
|
619
|
+
if (withSliders) currentVelocity = currentDistance / current.strainTime;
|
|
620
|
+
const distanceRatio = _rian8337_osu_base.MathUtils.smoothstep(Math.abs(prevVelocity - currentVelocity) / Math.max(prevVelocity, currentVelocity), 0, 1);
|
|
621
|
+
const overlapVelocityBuff = Math.min(current.normalizedDiameter * 1.25 / Math.min(current.strainTime, last.strainTime), Math.abs(prevVelocity - currentVelocity));
|
|
622
|
+
flowDifficulty += overlapVelocityBuff * distanceRatio * overlappedNotesWeight * this.velocityChangeMultiplier;
|
|
623
|
+
}
|
|
624
|
+
if (current.object instanceof _rian8337_osu_base.Slider && withSliders) flowDifficulty += current.travelDistance / current.travelTime;
|
|
625
|
+
flowDifficulty = Math.pow(flowDifficulty, 1.45);
|
|
626
|
+
return flowDifficulty * _rian8337_osu_base.MathUtils.smootherstep(currentDistance, 0, current.normalizedRadius);
|
|
627
|
+
}
|
|
628
|
+
static calculateOverlapFactor(o1, o2) {
|
|
629
|
+
const distance = o1.object.stackedPosition.getDistance(o2.object.stackedPosition);
|
|
630
|
+
const { radius } = o1.object;
|
|
631
|
+
return _rian8337_osu_base.MathUtils.clamp(1 - Math.pow(Math.max(distance - radius, 0) / radius, 2), 0, 1);
|
|
632
|
+
}
|
|
633
|
+
};
|
|
634
|
+
// src/skills/droid/DroidAim.ts
|
|
635
|
+
/**
|
|
636
|
+
* Represents the skill required to correctly aim at every object in the map with a uniform CircleSize and normalized distances.
|
|
637
|
+
*/
|
|
638
|
+
var DroidAim = class extends VariableLengthStrainSkill {
|
|
639
|
+
currentStrain = 0;
|
|
640
|
+
skillMultiplierSnap = 70.9;
|
|
641
|
+
skillMultiplierAgility = 2.35;
|
|
642
|
+
skillMultiplierFlow = 242;
|
|
643
|
+
skillMultiplierTotal = 1.12;
|
|
644
|
+
combinedSnapNormExponent = 1.2;
|
|
645
|
+
/**
|
|
646
|
+
* The number of sections with the highest strains, which the peak strain reductions will apply to.
|
|
647
|
+
* This is done in order to decrease their impact on the overall difficulty of the beatmap.
|
|
648
|
+
*/
|
|
649
|
+
reducedSectionTime = 4e3;
|
|
650
|
+
/**
|
|
651
|
+
* The baseline multiplier applied to the section with the biggest strain.
|
|
652
|
+
*/
|
|
653
|
+
reducedStrainBaseline = .727;
|
|
654
|
+
sliderStrains = [];
|
|
655
|
+
maxSliderStrain = 0;
|
|
656
|
+
withSliders;
|
|
657
|
+
constructor(mods, withSliders) {
|
|
658
|
+
super(mods);
|
|
659
|
+
this.withSliders = withSliders;
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* Obtains the amount of sliders that are considered difficult in terms of relative strain.
|
|
663
|
+
*/
|
|
664
|
+
countDifficultSliders() {
|
|
665
|
+
if (this.sliderStrains.length === 0 || this.maxSliderStrain === 0) return 0;
|
|
666
|
+
return this.sliderStrains.reduce((total, strain) => total + 1 / (1 + Math.exp(-(strain / this.maxSliderStrain * 12 - 6))), 0);
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* Obtains the amount of sliders that are considered difficult in terms of relative strain, weighted by consistency.
|
|
670
|
+
*
|
|
671
|
+
* @param difficultyValue The final difficulty value.
|
|
672
|
+
*/
|
|
673
|
+
countTopWeightedSliders(difficultyValue) {
|
|
674
|
+
if (this.sliderStrains.length === 0) return 0;
|
|
675
|
+
const consistentTopStrain = difficultyValue / 10;
|
|
676
|
+
if (consistentTopStrain === 0) return 0;
|
|
677
|
+
return this.sliderStrains.reduce((total, next) => total + _rian8337_osu_base.MathUtils.offsetLogistic(next / consistentTopStrain, .88, 10, 1.1), 0);
|
|
678
|
+
}
|
|
679
|
+
strainValueAt(current) {
|
|
680
|
+
if (this.mods.has(_rian8337_osu_base.ModAutopilot)) return 0;
|
|
681
|
+
const decay = this.strainDecay(current.strainTime);
|
|
682
|
+
this.currentStrain *= decay;
|
|
683
|
+
this.currentStrain += this.calculateAdjustedDifficulty(current) * (1 - decay);
|
|
684
|
+
if (current.object instanceof _rian8337_osu_base.Slider) {
|
|
685
|
+
this.sliderStrains.push(this.currentStrain);
|
|
686
|
+
this.maxSliderStrain = Math.max(this.maxSliderStrain, this.currentStrain);
|
|
687
|
+
}
|
|
688
|
+
return this.currentStrain;
|
|
689
|
+
}
|
|
690
|
+
calculateInitialStrain(time, current) {
|
|
691
|
+
return this.currentStrain * this.strainDecay(time - (current.previous(0)?.startTime ?? 0));
|
|
692
|
+
}
|
|
693
|
+
saveToHitObject(current, difficulty) {
|
|
694
|
+
if (this.withSliders) current.aimStrainWithSliders = difficulty;
|
|
695
|
+
else current.aimStrainWithoutSliders = difficulty;
|
|
696
|
+
}
|
|
697
|
+
calculateAdjustedDifficulty(current) {
|
|
698
|
+
const snapDifficulty = DroidSnapAimEvaluator.evaluateDifficultyOf(current, this.withSliders) * this.skillMultiplierSnap;
|
|
699
|
+
const agilityDifficulty = DroidAgilityEvaluator.evaluateDifficultyOf(current) * this.skillMultiplierAgility;
|
|
700
|
+
const flowDifficulty = DroidFlowAimEvaluator.evaluateDifficultyOf(current, this.withSliders) * this.skillMultiplierFlow;
|
|
701
|
+
return this.calculateTotalValue(snapDifficulty, agilityDifficulty, flowDifficulty);
|
|
702
|
+
}
|
|
703
|
+
calculateTotalValue(snapDifficulty, agilityDifficulty, flowDifficulty) {
|
|
704
|
+
let combinedSnapDifficulty = _rian8337_osu_base.MathUtils.norm(this.combinedSnapNormExponent, snapDifficulty, agilityDifficulty);
|
|
705
|
+
const pSnap = this.calculateSnapFlowProbability(flowDifficulty / combinedSnapDifficulty);
|
|
706
|
+
const pFlow = 1 - pSnap;
|
|
707
|
+
snapDifficulty = Math.pow(.02275 * Math.pow(10, .63), (.8 - 1) / .63) * Math.pow(snapDifficulty, .8);
|
|
708
|
+
combinedSnapDifficulty = _rian8337_osu_base.MathUtils.norm(this.combinedSnapNormExponent, snapDifficulty, agilityDifficulty);
|
|
709
|
+
if (this.mods.has(_rian8337_osu_base.ModRelax)) {
|
|
710
|
+
combinedSnapDifficulty *= .75;
|
|
711
|
+
flowDifficulty *= .6;
|
|
712
|
+
}
|
|
713
|
+
return (combinedSnapDifficulty * pSnap + flowDifficulty * pFlow) * this.skillMultiplierTotal;
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* Converts the ratio of snap to flow into the probability of snapping or flowing.
|
|
717
|
+
*
|
|
718
|
+
* Constraints:
|
|
719
|
+
* - `P(snap) + P(flow) = 1` (the object is always either snapped or flowed)
|
|
720
|
+
* - `P(snap) = f(snap / flow)` and `P(flow) = f(flow/snap)` (i.e., snap and flow are symmetric and
|
|
721
|
+
* reversible). This means `f(x) + f(1/x) = 1`
|
|
722
|
+
* - `0 <= f(x) <= 1` (cannot have negative or greater than 100% probability of snapping or flowing)
|
|
723
|
+
*
|
|
724
|
+
* This logistic function is a solution, which fits nicely with the general idea of interpolation and
|
|
725
|
+
* provides a tuneable constant.
|
|
726
|
+
*
|
|
727
|
+
* @param ratio The ratio.
|
|
728
|
+
* @returns The probability.
|
|
729
|
+
*/
|
|
730
|
+
calculateSnapFlowProbability(ratio) {
|
|
731
|
+
if (ratio === 0) return 0;
|
|
732
|
+
if (Number.isNaN(ratio)) return 1;
|
|
733
|
+
return _rian8337_osu_base.MathUtils.logistic(-7.27 * Math.log(ratio));
|
|
734
|
+
}
|
|
735
|
+
difficultyValue() {
|
|
736
|
+
let time = 0;
|
|
737
|
+
let difficulty = 0;
|
|
738
|
+
for (const strain of this.getReducedStrainPeaks()) {
|
|
739
|
+
const startTime = time;
|
|
740
|
+
const endTime = time + strain.sectionLength / this.maxSectionLength;
|
|
741
|
+
const weight = Math.pow(this.decayWeight, startTime) - Math.pow(this.decayWeight, endTime);
|
|
742
|
+
difficulty += strain.value * weight;
|
|
743
|
+
time = endTime;
|
|
744
|
+
}
|
|
745
|
+
return difficulty / (1 - this.decayWeight);
|
|
746
|
+
}
|
|
747
|
+
getReducedStrainPeaks() {
|
|
748
|
+
const strains = this.currentStrainPeaks.filter((s) => s.value > 0).sort((a, b) => b.value - a.value);
|
|
749
|
+
let time = 0;
|
|
750
|
+
let strainsToRemove = 0;
|
|
751
|
+
const chunkSize = 20;
|
|
752
|
+
while (strains.length > strainsToRemove && time < this.reducedSectionTime) {
|
|
753
|
+
const strain = strains[strainsToRemove];
|
|
754
|
+
for (let addedTime = 0; addedTime < strain.sectionLength; addedTime += chunkSize) {
|
|
755
|
+
const scale = Math.log10(_rian8337_osu_base.Interpolation.lerp(1, 10, _rian8337_osu_base.MathUtils.clamp((time + addedTime) / this.reducedSectionTime, 0, 1)));
|
|
756
|
+
strains.push(new StrainPeak(strain.value * _rian8337_osu_base.Interpolation.lerp(this.reducedStrainBaseline, 1, scale), Math.min(chunkSize, strain.sectionLength - addedTime)));
|
|
757
|
+
}
|
|
758
|
+
time += strain.sectionLength;
|
|
759
|
+
++strainsToRemove;
|
|
760
|
+
}
|
|
761
|
+
strains.splice(0, strainsToRemove);
|
|
762
|
+
return strains.sort((a, b) => b.value - a.value);
|
|
763
|
+
}
|
|
764
|
+
strainDecay(ms) {
|
|
765
|
+
return Math.pow(.2, ms / 1e3);
|
|
766
|
+
}
|
|
767
|
+
};
|
|
768
|
+
// src/evaluators/droid/DroidFlashlightEvaluator.ts
|
|
769
|
+
/**
|
|
770
|
+
* An evaluator for calculating osu!droid Flashlight skill.
|
|
771
|
+
*/
|
|
772
|
+
var DroidFlashlightEvaluator = class {
|
|
773
|
+
static maxOpacityBonus = .4;
|
|
774
|
+
static hiddenBonus = .2;
|
|
775
|
+
static traceableCircleBonus = .15;
|
|
776
|
+
static traceableObjectBonus = .1;
|
|
777
|
+
static minVelocity = .5;
|
|
778
|
+
static sliderMultiplier = 1.3;
|
|
779
|
+
static minAngleMultiplier = .2;
|
|
780
|
+
/**
|
|
781
|
+
* Evaluates the difficulty of memorizing and hitting the current object, based on:
|
|
782
|
+
*
|
|
783
|
+
* - distance between a number of previous objects and the current object,
|
|
784
|
+
* - the visual opacity of the current object,
|
|
785
|
+
* - the angle made by the current object,
|
|
786
|
+
* - length and speed of the current object (for sliders),
|
|
787
|
+
* - and whether Hidden mod is enabled.
|
|
788
|
+
*
|
|
789
|
+
* @param current The current object.
|
|
790
|
+
* @param mods The mods used.
|
|
791
|
+
*/
|
|
792
|
+
static evaluateDifficultyOf(current, mods) {
|
|
793
|
+
if (current.object instanceof _rian8337_osu_base.Spinner || current.isOverlapping(true)) return 0;
|
|
794
|
+
const scalingFactor = 52 / current.object.radius;
|
|
795
|
+
let smallDistNerf = 1;
|
|
796
|
+
let cumulativeStrainTime = 0;
|
|
797
|
+
let result = 0;
|
|
798
|
+
let last = current;
|
|
799
|
+
let angleRepeatCount = 0;
|
|
800
|
+
const opacityMods = mods.get(_rian8337_osu_base.ModHidden)?.onlyFadeApproachCircles.value ? void 0 : mods;
|
|
801
|
+
for (let i = 0; i < Math.min(current.index, 10); ++i) {
|
|
802
|
+
const currentObject = current.previous(i);
|
|
803
|
+
cumulativeStrainTime += last.strainTime;
|
|
804
|
+
if (!(currentObject.object instanceof _rian8337_osu_base.Spinner) && !currentObject.isOverlapping(false)) {
|
|
805
|
+
const jumpDistance = current.object.stackedPosition.subtract(currentObject.object.stackedEndPosition).length;
|
|
806
|
+
if (i === 0) smallDistNerf = Math.min(1, jumpDistance / 75);
|
|
807
|
+
const stackNerf = Math.min(1, currentObject.lazyJumpDistance / scalingFactor / 25);
|
|
808
|
+
const opacityBonus = 1 + this.maxOpacityBonus * (1 - current.opacityAt(currentObject.object.startTime, opacityMods));
|
|
809
|
+
result += stackNerf * opacityBonus * scalingFactor * jumpDistance / cumulativeStrainTime;
|
|
810
|
+
if (currentObject.angle !== null && current.angle !== null) {
|
|
811
|
+
if (Math.abs(currentObject.angle - current.angle) < .02) angleRepeatCount += Math.max(0, 1 - .1 * i);
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
last = currentObject;
|
|
815
|
+
}
|
|
816
|
+
result = Math.pow(smallDistNerf * result, 2);
|
|
817
|
+
if (mods.has(_rian8337_osu_base.ModHidden)) result *= 1 + this.hiddenBonus;
|
|
818
|
+
else if (mods.has(_rian8337_osu_base.ModTraceable)) {
|
|
819
|
+
if (current.object instanceof _rian8337_osu_base.Circle) result *= 1 + this.traceableCircleBonus;
|
|
820
|
+
else result *= 1 + this.traceableObjectBonus;
|
|
821
|
+
}
|
|
822
|
+
result *= this.minAngleMultiplier + (1 - this.minAngleMultiplier) / (angleRepeatCount + 1);
|
|
823
|
+
let sliderBonus = 0;
|
|
824
|
+
if (current.object instanceof _rian8337_osu_base.Slider) {
|
|
825
|
+
const pixelTravelDistance = current.lazyTravelDistance / scalingFactor;
|
|
826
|
+
sliderBonus = Math.pow(Math.max(0, pixelTravelDistance / current.travelTime - this.minVelocity), .5);
|
|
827
|
+
sliderBonus *= pixelTravelDistance;
|
|
828
|
+
if (current.object.repeatCount > 0) sliderBonus /= current.object.repeatCount + 1;
|
|
829
|
+
}
|
|
830
|
+
result += sliderBonus * this.sliderMultiplier;
|
|
831
|
+
return result;
|
|
832
|
+
}
|
|
833
|
+
};
|
|
834
|
+
// src/base/StrainSkill.ts
|
|
835
|
+
/**
|
|
836
|
+
* Used to processes strain values of difficulty hitobjects, keep track of strain levels caused by the processed objects
|
|
837
|
+
* and to calculate a final difficulty value representing the difficulty of hitting all the processed objects.
|
|
838
|
+
*/
|
|
839
|
+
var StrainSkill = class extends Skill {
|
|
840
|
+
/**
|
|
841
|
+
* The number of sections with the highest strains, which the peak strain reductions will apply to.
|
|
842
|
+
* This is done in order to decrease their impact on the overall difficulty of the map for this skill.
|
|
843
|
+
*/
|
|
844
|
+
reducedSectionCount = 10;
|
|
845
|
+
/**
|
|
846
|
+
* The baseline multiplier applied to the section with the biggest strain.
|
|
847
|
+
*/
|
|
848
|
+
reducedSectionBaseline = .75;
|
|
849
|
+
_objectStrains = [];
|
|
850
|
+
/**
|
|
851
|
+
* The strains of hitobjects.
|
|
852
|
+
*/
|
|
853
|
+
get objectStrains() {
|
|
854
|
+
return this._objectStrains;
|
|
855
|
+
}
|
|
856
|
+
strainPeaks = [];
|
|
857
|
+
strainPeakTimes = [];
|
|
858
|
+
get peaks() {
|
|
859
|
+
return this.strainPeaks.map((value, i) => ({
|
|
860
|
+
time: this.strainPeakTimes[i],
|
|
861
|
+
value
|
|
862
|
+
})).concat({
|
|
863
|
+
time: this.currentSectionEnd,
|
|
864
|
+
value: this.currentSectionPeak
|
|
865
|
+
});
|
|
866
|
+
}
|
|
867
|
+
sectionLength = 400;
|
|
868
|
+
currentStrain = 0;
|
|
869
|
+
currentSectionPeak = 0;
|
|
870
|
+
currentSectionEnd = 0;
|
|
871
|
+
/**
|
|
872
|
+
* Converts a difficulty value to a performance value.
|
|
873
|
+
*
|
|
874
|
+
* @param difficulty The difficulty value to convert.
|
|
875
|
+
* @returns The performance value.
|
|
876
|
+
*/
|
|
877
|
+
static difficultyToPerformance(difficulty) {
|
|
878
|
+
return Math.pow(5 * Math.max(1, difficulty / .0675) - 4, 3) / 1e5;
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* Obtains the live strain peaks for each {@link sectionLength} of the beatmap, including the peak of the current section.
|
|
882
|
+
*/
|
|
883
|
+
get currentStrainPeaks() {
|
|
884
|
+
return this.strainPeaks.concat(this.currentSectionPeak);
|
|
885
|
+
}
|
|
886
|
+
/**
|
|
887
|
+
* Returns the number of strains weighed against the top strain.
|
|
888
|
+
*
|
|
889
|
+
* The result is scaled by clock rate as it affects the total number of strains.
|
|
890
|
+
*
|
|
891
|
+
* @param difficultyValue The final difficulty value.
|
|
892
|
+
*/
|
|
893
|
+
countTopWeightedStrains(difficultyValue) {
|
|
894
|
+
if (difficultyValue === 0) return 0;
|
|
895
|
+
const consistentTopStrain = difficultyValue / 10;
|
|
896
|
+
if (consistentTopStrain === 0) return this._objectStrains.length;
|
|
897
|
+
return this._objectStrains.reduce((total, next) => total + 1.1 / (1 + Math.exp(-10 * (next / consistentTopStrain - .88))), 0);
|
|
898
|
+
}
|
|
899
|
+
processInternal(current) {
|
|
900
|
+
if (current.index === 0) this.currentSectionEnd = this.calculateCurrentSectionStart(current);
|
|
901
|
+
while (current.startTime > this.currentSectionEnd) {
|
|
902
|
+
this.saveCurrentPeak();
|
|
903
|
+
this.startNewSectionFrom(this.currentSectionEnd, current);
|
|
904
|
+
this.currentSectionEnd += this.sectionLength;
|
|
905
|
+
}
|
|
906
|
+
this.currentStrain = this.strainValueAt(current);
|
|
907
|
+
this.currentSectionPeak = Math.max(this.currentStrain, this.currentSectionPeak);
|
|
908
|
+
return this.currentStrain;
|
|
909
|
+
}
|
|
910
|
+
/**
|
|
911
|
+
* Calculates the starting time of a strain section at an object.
|
|
912
|
+
*
|
|
913
|
+
* @param current The object at which the strain section starts.
|
|
914
|
+
* @returns The start time of the strain section.
|
|
915
|
+
*/
|
|
916
|
+
calculateCurrentSectionStart(current) {
|
|
917
|
+
return Math.ceil(current.startTime / this.sectionLength) * this.sectionLength;
|
|
918
|
+
}
|
|
919
|
+
/**
|
|
920
|
+
* Saves the current peak strain level to the list of strain peaks, which will be used to calculate an overall difficulty.
|
|
921
|
+
*/
|
|
922
|
+
saveCurrentPeak() {
|
|
923
|
+
this.strainPeaks.push(this.currentSectionPeak);
|
|
924
|
+
this.strainPeakTimes.push(this.currentSectionEnd);
|
|
925
|
+
}
|
|
926
|
+
/**
|
|
927
|
+
* Sets the initial strain level for a new section.
|
|
928
|
+
*
|
|
929
|
+
* @param time The beginning of the new section in milliseconds.
|
|
930
|
+
* @param current The current hitobject.
|
|
931
|
+
*/
|
|
932
|
+
startNewSectionFrom(time, current) {
|
|
933
|
+
this.currentSectionPeak = this.calculateInitialStrain(time, current);
|
|
934
|
+
}
|
|
935
|
+
};
|
|
936
|
+
// src/skills/droid/DroidSkill.ts
|
|
937
|
+
/**
|
|
938
|
+
* Used to processes strain values of difficulty hitobjects, keep track of strain levels caused by the processed objects
|
|
939
|
+
* and to calculate a final difficulty value representing the difficulty of hitting all the processed objects.
|
|
940
|
+
*/
|
|
941
|
+
var DroidSkill = class extends StrainSkill {
|
|
942
|
+
difficulty = 0;
|
|
943
|
+
process(current) {
|
|
944
|
+
if (current.index < 0) return;
|
|
945
|
+
super.process(current);
|
|
946
|
+
this._objectStrains.push(this.getObjectStrain(current));
|
|
947
|
+
}
|
|
948
|
+
difficultyValue() {
|
|
949
|
+
const strains = this.strainPeaks.slice();
|
|
950
|
+
if (this.reducedSectionCount > 0) {
|
|
951
|
+
strains.sort((a, b) => b - a);
|
|
952
|
+
for (let i = 0; i < Math.min(strains.length, this.reducedSectionCount); ++i) {
|
|
953
|
+
const scale = Math.log10(_rian8337_osu_base.Interpolation.lerp(1, 10, _rian8337_osu_base.MathUtils.clamp(i / this.reducedSectionCount, 0, 1)));
|
|
954
|
+
strains[i] *= _rian8337_osu_base.Interpolation.lerp(this.reducedSectionBaseline, 1, scale);
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
this.difficulty = 0;
|
|
958
|
+
for (const strain of strains) this.difficulty += Math.pow(strain, 1 / Math.log2(this.starsPerDouble));
|
|
959
|
+
this.difficulty = Math.pow(this.difficulty, Math.log2(this.starsPerDouble));
|
|
960
|
+
return this.difficulty;
|
|
961
|
+
}
|
|
962
|
+
calculateCurrentSectionStart(current) {
|
|
963
|
+
return current.startTime;
|
|
964
|
+
}
|
|
965
|
+
};
|
|
966
|
+
// src/skills/droid/DroidFlashlight.ts
|
|
967
|
+
/**
|
|
968
|
+
* Represents the skill required to memorize and hit every object in a beatmap with the Flashlight mod enabled.
|
|
969
|
+
*/
|
|
970
|
+
var DroidFlashlight = class extends DroidSkill {
|
|
971
|
+
totalObjects;
|
|
972
|
+
reducedSectionCount = 0;
|
|
973
|
+
reducedSectionBaseline = 1;
|
|
974
|
+
starsPerDouble = 1;
|
|
975
|
+
skillMultiplier = .058;
|
|
976
|
+
currentFlashlightStrain = 0;
|
|
977
|
+
static difficultyToPerformance(difficulty) {
|
|
978
|
+
return Math.pow(difficulty, 2) * 25;
|
|
979
|
+
}
|
|
980
|
+
constructor(mods, totalObjects) {
|
|
981
|
+
super(mods);
|
|
982
|
+
this.totalObjects = totalObjects;
|
|
983
|
+
}
|
|
984
|
+
strainValueAt(current) {
|
|
985
|
+
if (!this.mods.has(_rian8337_osu_base.ModFlashlight)) return 0;
|
|
986
|
+
this.currentFlashlightStrain *= this.strainDecay(current.deltaTime);
|
|
987
|
+
this.currentFlashlightStrain += this.calculateAdjustedDifficulty(current) * this.skillMultiplier;
|
|
988
|
+
return this.currentFlashlightStrain;
|
|
989
|
+
}
|
|
990
|
+
calculateInitialStrain(time, current) {
|
|
991
|
+
return this.currentFlashlightStrain * this.strainDecay(time - (current.previous(0)?.startTime ?? 0));
|
|
992
|
+
}
|
|
993
|
+
getObjectStrain() {
|
|
994
|
+
return this.currentFlashlightStrain;
|
|
995
|
+
}
|
|
996
|
+
saveToHitObject(current) {
|
|
997
|
+
current.flashlightStrain = this.currentFlashlightStrain;
|
|
998
|
+
}
|
|
999
|
+
difficultyValue() {
|
|
1000
|
+
let sum = this.currentStrainPeaks.reduce((a, v) => a + v, 0) * this.starsPerDouble;
|
|
1001
|
+
sum *= .7 + .1 * Math.min(1, this.totalObjects / 200) + (this.totalObjects > 200 ? .2 * Math.min(1, (this.totalObjects - 200) / 200) : 0);
|
|
1002
|
+
return sum;
|
|
1003
|
+
}
|
|
1004
|
+
calculateAdjustedDifficulty(current) {
|
|
1005
|
+
let difficulty = Math.pow(DroidFlashlightEvaluator.evaluateDifficultyOf(current, this.mods), .9);
|
|
1006
|
+
if (this.mods.has(_rian8337_osu_base.ModRelax)) difficulty *= .7;
|
|
1007
|
+
else if (this.mods.has(_rian8337_osu_base.ModAutopilot)) difficulty *= .4;
|
|
1008
|
+
return difficulty;
|
|
1009
|
+
}
|
|
1010
|
+
strainDecay(ms) {
|
|
1011
|
+
return Math.pow(.15, ms / 1e3);
|
|
1012
|
+
}
|
|
1013
|
+
};
|
|
1014
|
+
// src/base/HarmonicSkill.ts
|
|
1015
|
+
/**
|
|
1016
|
+
* A skill that calculates the difficulty of {@link DifficultyHitObject}s using harmonic summation.
|
|
1017
|
+
*/
|
|
1018
|
+
var HarmonicSkill = class extends Skill {
|
|
1019
|
+
_noteWeightSum = 0;
|
|
1020
|
+
_objectTimes = [];
|
|
1021
|
+
/**
|
|
1022
|
+
* The sum of note weights, calculated during summation.
|
|
1023
|
+
*
|
|
1024
|
+
* Required for any calculations that normalizes the difficulty value.
|
|
1025
|
+
*/
|
|
1026
|
+
get noteWeightSum() {
|
|
1027
|
+
return this._noteWeightSum;
|
|
1028
|
+
}
|
|
1029
|
+
/**
|
|
1030
|
+
* The start times of {@link DifficultyHitObject}s, populated by {@link HarmonicSkill.process}.
|
|
1031
|
+
*
|
|
1032
|
+
* Indices correspond to {@link objectDifficulties}.
|
|
1033
|
+
*/
|
|
1034
|
+
get objectTimes() {
|
|
1035
|
+
return this._objectTimes;
|
|
1036
|
+
}
|
|
1037
|
+
/**
|
|
1038
|
+
* Scaling factor applied as `x / (i + 1)`, where `x` is the skill's {@link harmonicScale} and `i`
|
|
1039
|
+
* is the index of the {@link DifficultyHitObject} being processed.
|
|
1040
|
+
*
|
|
1041
|
+
* A higher value increases the influence of the hardest {@link DifficultyHitObject}s during summation.
|
|
1042
|
+
*/
|
|
1043
|
+
harmonicScale = 1;
|
|
1044
|
+
/**
|
|
1045
|
+
* An exponent that controls the rate of which decay increases as the index increases.
|
|
1046
|
+
*
|
|
1047
|
+
* Values closer to 1 decay faster, whilst lower values give more weight to easier {@link DifficultyHitObject}s.
|
|
1048
|
+
*/
|
|
1049
|
+
decayExponent = .9;
|
|
1050
|
+
get peaks() {
|
|
1051
|
+
return this.objectDifficulties.map((value, i) => ({
|
|
1052
|
+
time: this.objectTimes[i],
|
|
1053
|
+
value
|
|
1054
|
+
}));
|
|
1055
|
+
}
|
|
1056
|
+
static difficultyToPerformance(difficulty) {
|
|
1057
|
+
return 4 * Math.pow(difficulty, 3);
|
|
1058
|
+
}
|
|
1059
|
+
difficultyValue() {
|
|
1060
|
+
if (this.objectDifficulties.length === 0) return 0;
|
|
1061
|
+
const difficulties = this.objectDifficulties.filter((d) => d > 0);
|
|
1062
|
+
if (difficulties.length === 0) return 0;
|
|
1063
|
+
this.applyDifficultyTransformation(difficulties);
|
|
1064
|
+
let difficulty = 0;
|
|
1065
|
+
let index = 0;
|
|
1066
|
+
this._noteWeightSum = 0;
|
|
1067
|
+
for (const objectDifficulty of difficulties.sort((a, b) => b - a)) {
|
|
1068
|
+
const weight = (1 + this.harmonicScale / (1 + index)) / (Math.pow(index, this.decayExponent) + 1 + this.harmonicScale / (1 + index));
|
|
1069
|
+
this._noteWeightSum += weight;
|
|
1070
|
+
difficulty += objectDifficulty * weight;
|
|
1071
|
+
++index;
|
|
1072
|
+
}
|
|
1073
|
+
return difficulty;
|
|
1074
|
+
}
|
|
1075
|
+
/**
|
|
1076
|
+
* Calculates the amount of object difficulties weighed against the top object difficulty.
|
|
1077
|
+
*
|
|
1078
|
+
* @param difficultyValue The final difficulty value.
|
|
1079
|
+
*/
|
|
1080
|
+
countTopWeightedObjectDifficulties(difficultyValue) {
|
|
1081
|
+
if (difficultyValue === 0) return 0;
|
|
1082
|
+
if (this._noteWeightSum === 0) return 0;
|
|
1083
|
+
const consistentTopNote = difficultyValue / this._noteWeightSum;
|
|
1084
|
+
if (consistentTopNote === 0) return 0;
|
|
1085
|
+
return this.objectDifficulties.reduce((total, next) => total + _rian8337_osu_base.MathUtils.offsetLogistic(next / consistentTopNote, .88, 10, 1.1), 0);
|
|
1086
|
+
}
|
|
1087
|
+
/**
|
|
1088
|
+
* Transforms the difficulties of {@link DifficultyHitObject}s before they are summed together.
|
|
1089
|
+
*
|
|
1090
|
+
* This can be used to decrease weight of certain {@link DifficultyHitObject}s based on a skill-specific criteria.
|
|
1091
|
+
*
|
|
1092
|
+
* @param difficulties The difficulties of {@link DifficultyHitObject}s to transform.
|
|
1093
|
+
*/
|
|
1094
|
+
applyDifficultyTransformation(difficulties) {}
|
|
1095
|
+
process(current) {
|
|
1096
|
+
const previousLength = this.objectDifficulties.length;
|
|
1097
|
+
super.process(current);
|
|
1098
|
+
if (this.objectDifficulties.length > previousLength) this._objectTimes.push(current.startTime);
|
|
1099
|
+
}
|
|
1100
|
+
processInternal(current) {
|
|
1101
|
+
return this.objectDifficultyOf(current);
|
|
1102
|
+
}
|
|
1103
|
+
};
|
|
1104
|
+
// src/evaluators/droid/DroidReadingEvaluator.ts
|
|
1105
|
+
/**
|
|
1106
|
+
* Evaluator for reading difficulty in osu!droid.
|
|
1107
|
+
*/
|
|
1108
|
+
var DroidReadingEvaluator = class {
|
|
1109
|
+
static readingWindowSize = 3e3;
|
|
1110
|
+
static hiddenMultiplier = .28;
|
|
1111
|
+
static traceableMultiplier = .26;
|
|
1112
|
+
static densityMultiplier = 2.4;
|
|
1113
|
+
static densityDifficultyBase = 2.5;
|
|
1114
|
+
static preemptBalancingFactor = 15e4;
|
|
1115
|
+
static preemptStartingPoint = 500;
|
|
1116
|
+
static minimumAngleRelevancyTime = 2e3;
|
|
1117
|
+
static maximumAngleRelevancyTime = 200;
|
|
1118
|
+
/**
|
|
1119
|
+
* Evaluates the difficulty of reading the object.
|
|
1120
|
+
*/
|
|
1121
|
+
static evaluateDifficultyOf(current, mods) {
|
|
1122
|
+
if (current.object instanceof _rian8337_osu_base.Spinner || current.index === 0) return 0;
|
|
1123
|
+
const distanceInfluenceThreshold = current.normalizedDiameter * 1.25;
|
|
1124
|
+
const next = current.next(0);
|
|
1125
|
+
const velocity = Math.max(1, current.lazyJumpDistance / current.strainTime);
|
|
1126
|
+
const currentVisibleObjectDensity = this.retrieveCurrentVisibleObjectDensity(current);
|
|
1127
|
+
const pastObjectDifficultyInfluence = this.getPastObjectDifficultyInfluence(current, distanceInfluenceThreshold);
|
|
1128
|
+
const constantAngleNerfFactor = this.getConstantAngleNerfFactor(current);
|
|
1129
|
+
const noteDensityDifficulty = this.calculateDensityDifficulty(next, distanceInfluenceThreshold, velocity, constantAngleNerfFactor, pastObjectDifficultyInfluence, currentVisibleObjectDensity);
|
|
1130
|
+
const hiddenDifficulty = this.calculateHiddenDifficulty(current, mods, pastObjectDifficultyInfluence, currentVisibleObjectDensity, velocity, constantAngleNerfFactor);
|
|
1131
|
+
const traceableDifficulty = this.calculateTraceableDifficulty(current, mods, distanceInfluenceThreshold, pastObjectDifficultyInfluence, currentVisibleObjectDensity, velocity, constantAngleNerfFactor);
|
|
1132
|
+
const preemptDifficulty = this.calculatePreemptDifficulty(velocity, constantAngleNerfFactor, current.timePreempt);
|
|
1133
|
+
let difficulty = _rian8337_osu_base.MathUtils.norm(1.5, preemptDifficulty, hiddenDifficulty, traceableDifficulty, noteDensityDifficulty);
|
|
1134
|
+
difficulty *= this.highBpmBonus(current.strainTime);
|
|
1135
|
+
return difficulty;
|
|
1136
|
+
}
|
|
1137
|
+
/**
|
|
1138
|
+
* Calculates the density difficulty of the current object and how hard it is to aim it because of it based on:
|
|
1139
|
+
*
|
|
1140
|
+
* - cursor velocity to the current object,
|
|
1141
|
+
* - how many times the current object's angle was repeated,
|
|
1142
|
+
* - density of objects visible when the current object appears, and
|
|
1143
|
+
* - density of objects visible when the current object needs to be clicked.
|
|
1144
|
+
*/
|
|
1145
|
+
static calculateDensityDifficulty(next, distanceInfluenceThreshold, velocity, constantAngleNerfFactor, pastObjectDifficultyInfluence, currentVisibleObjectDensity) {
|
|
1146
|
+
let futureObjectDifficultyInfluence = Math.sqrt(currentVisibleObjectDensity);
|
|
1147
|
+
if (next !== null) futureObjectDifficultyInfluence *= _rian8337_osu_base.MathUtils.smootherstep(next.lazyJumpDistance, 15, distanceInfluenceThreshold);
|
|
1148
|
+
let noteDensityDifficulty = Math.pow(pastObjectDifficultyInfluence + futureObjectDifficultyInfluence, 1.7) * .4 * constantAngleNerfFactor * velocity;
|
|
1149
|
+
noteDensityDifficulty = Math.max(0, noteDensityDifficulty - this.densityDifficultyBase);
|
|
1150
|
+
noteDensityDifficulty = Math.pow(noteDensityDifficulty, .45) * this.densityMultiplier;
|
|
1151
|
+
return noteDensityDifficulty;
|
|
1152
|
+
}
|
|
1153
|
+
/**
|
|
1154
|
+
* Calculates the difficulty of aiming the current object when the approach rate is very high based on:
|
|
1155
|
+
*
|
|
1156
|
+
* - cursor velocity to the current object,
|
|
1157
|
+
* - how many times the current object's angle was repeated, and
|
|
1158
|
+
* - how many milliseconds elapse between the approach circle appearing and touching the inner circle.
|
|
1159
|
+
*/
|
|
1160
|
+
static calculatePreemptDifficulty(velocity, constantAngleNerfFactor, preempt) {
|
|
1161
|
+
let preemptDifficulty = Math.pow((this.preemptStartingPoint - preempt + Math.abs(preempt - this.preemptStartingPoint)) / 2, 2.5) / this.preemptBalancingFactor;
|
|
1162
|
+
preemptDifficulty *= constantAngleNerfFactor * velocity;
|
|
1163
|
+
return preemptDifficulty;
|
|
1164
|
+
}
|
|
1165
|
+
/**
|
|
1166
|
+
* Calculates the difficulty of aiming the current object when the Hidden mod is active based on:
|
|
1167
|
+
*
|
|
1168
|
+
* - cursor velocity to the current object,
|
|
1169
|
+
* - time the current object spends invisible,
|
|
1170
|
+
* - density of objects visible when the current object appears,
|
|
1171
|
+
* - density of objects visible when the current object needs to be clicked,
|
|
1172
|
+
* - how many times the current object's angle was repeated, and
|
|
1173
|
+
* - if the current object is perfectly stacked to the previous one.
|
|
1174
|
+
*/
|
|
1175
|
+
static calculateHiddenDifficulty(current, mods, pastObjectDifficultyInfluence, currentVisibleObjectDensity, velocity, constantAngleNerfFactor) {
|
|
1176
|
+
if (!mods.has(_rian8337_osu_base.ModHidden) || mods.get(_rian8337_osu_base.ModHidden)?.onlyFadeApproachCircles.value) return 0;
|
|
1177
|
+
let hiddenDifficulty = (Math.pow(current.timePreempt, 2.2) * .01 + Math.pow(currentVisibleObjectDensity + pastObjectDifficultyInfluence, 3.3) * 3) * constantAngleNerfFactor * velocity * .01;
|
|
1178
|
+
hiddenDifficulty = Math.pow(hiddenDifficulty, .4) * this.hiddenMultiplier;
|
|
1179
|
+
const prev = current.previous(0);
|
|
1180
|
+
if (current.lazyJumpDistance === 0 && current.opacityAt(prev.object.startTime, mods) === 0 && prev.startTime > current.startTime - current.timePreempt) hiddenDifficulty += this.hiddenMultiplier * 2500 / Math.pow(current.strainTime, 1.5);
|
|
1181
|
+
return hiddenDifficulty;
|
|
1182
|
+
}
|
|
1183
|
+
static calculateTraceableDifficulty(current, mods, distanceInfluenceThreshold, pastObjectDifficultyInfluence, currentVisibleObjectDensity, velocity, constantAngleNerfFactor) {
|
|
1184
|
+
if (!mods.has(_rian8337_osu_base.ModTraceable)) return 0;
|
|
1185
|
+
const approachRate = _rian8337_osu_base.BeatmapDifficulty.difficultyRange(current.timePreempt, _rian8337_osu_base.HitObject.preemptMax, _rian8337_osu_base.HitObject.preemptMid, _rian8337_osu_base.HitObject.preemptMin);
|
|
1186
|
+
let lowApproachRateSliderVisibilityFactor = 1;
|
|
1187
|
+
let highApproachRateSliderVisibilityFactor = 1;
|
|
1188
|
+
if (current.object instanceof _rian8337_osu_base.Slider) {
|
|
1189
|
+
const distanceFactor = _rian8337_osu_base.MathUtils.smootherstep(current.travelDistance, distanceInfluenceThreshold, 15);
|
|
1190
|
+
highApproachRateSliderVisibilityFactor = .5 + distanceFactor / 2;
|
|
1191
|
+
lowApproachRateSliderVisibilityFactor = distanceFactor;
|
|
1192
|
+
}
|
|
1193
|
+
let preemptFactor = .1 + .05 * (12 - Math.max(approachRate, 7)) * highApproachRateSliderVisibilityFactor;
|
|
1194
|
+
if (approachRate < 7) preemptFactor += .05 * (7 - Math.max(approachRate, 0)) * lowApproachRateSliderVisibilityFactor;
|
|
1195
|
+
if (approachRate < 0) preemptFactor += .05 * (1 - Math.pow(1.5, approachRate)) * lowApproachRateSliderVisibilityFactor;
|
|
1196
|
+
const densityFactor = Math.pow(currentVisibleObjectDensity + pastObjectDifficultyInfluence, 2);
|
|
1197
|
+
let traceableDifficulty = (preemptFactor + densityFactor) * constantAngleNerfFactor * velocity;
|
|
1198
|
+
traceableDifficulty = Math.pow(traceableDifficulty, .45) * this.traceableMultiplier;
|
|
1199
|
+
return traceableDifficulty;
|
|
1200
|
+
}
|
|
1201
|
+
static getPastObjectDifficultyInfluence(current, distanceInfluenceThreshold) {
|
|
1202
|
+
let pastObjectDifficultyInfluence = 0;
|
|
1203
|
+
for (const loopObj of this.retrievePastVisibleObjects(current)) {
|
|
1204
|
+
let loopDifficulty = current.opacityAt(loopObj.object.startTime);
|
|
1205
|
+
loopDifficulty *= _rian8337_osu_base.MathUtils.smootherstep(loopObj.lazyJumpDistance, 15, distanceInfluenceThreshold);
|
|
1206
|
+
const timeBetweenCurrAndLoopObj = current.startTime - loopObj.startTime;
|
|
1207
|
+
const timeNerfFactor = this.getTimeNerfFactor(timeBetweenCurrAndLoopObj);
|
|
1208
|
+
loopDifficulty *= timeNerfFactor;
|
|
1209
|
+
pastObjectDifficultyInfluence += loopDifficulty;
|
|
1210
|
+
}
|
|
1211
|
+
return pastObjectDifficultyInfluence;
|
|
1212
|
+
}
|
|
1213
|
+
/**
|
|
1214
|
+
* Returns a list of objects that are visible on screen at the point in time the current object becomes visible.
|
|
1215
|
+
*/
|
|
1216
|
+
static *retrievePastVisibleObjects(current) {
|
|
1217
|
+
for (let i = 0; i < current.index; ++i) {
|
|
1218
|
+
const hitObject = current.previous(i);
|
|
1219
|
+
if (!hitObject || current.startTime - hitObject.startTime > this.readingWindowSize || hitObject.startTime < current.startTime - current.timePreempt) break;
|
|
1220
|
+
if (hitObject.isOverlapping(true)) continue;
|
|
1221
|
+
yield hitObject;
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
/**
|
|
1225
|
+
* Returns the density of objects visible at the point in time the current object needs to be clicked capped by the reading window.
|
|
1226
|
+
*/
|
|
1227
|
+
static retrieveCurrentVisibleObjectDensity(current) {
|
|
1228
|
+
let visibleObjectCount = 0;
|
|
1229
|
+
let hitObject = current.next(0);
|
|
1230
|
+
while (hitObject !== null) {
|
|
1231
|
+
if (hitObject.startTime - current.startTime > this.readingWindowSize || current.startTime + hitObject.timePreempt < hitObject.startTime) break;
|
|
1232
|
+
if (hitObject.isOverlapping(true)) {
|
|
1233
|
+
hitObject = hitObject.next(0);
|
|
1234
|
+
continue;
|
|
1235
|
+
}
|
|
1236
|
+
const timeBetweenCurrAndLoopObj = hitObject.startTime - current.startTime;
|
|
1237
|
+
const timeNerfFactor = this.getTimeNerfFactor(timeBetweenCurrAndLoopObj);
|
|
1238
|
+
visibleObjectCount += hitObject.opacityAt(current.object.startTime) * timeNerfFactor;
|
|
1239
|
+
hitObject = hitObject.next(0);
|
|
1240
|
+
}
|
|
1241
|
+
return visibleObjectCount;
|
|
1242
|
+
}
|
|
1243
|
+
/**
|
|
1244
|
+
* Returns a factor of how often the current object's angle has been repeated in a certain time frame.
|
|
1245
|
+
* It does this by checking the difference in angle between current and past objects and sums them based on a range of similarity.
|
|
1246
|
+
* https://www.desmos.com/calculator/eb057a4822
|
|
1247
|
+
*/
|
|
1248
|
+
static getConstantAngleNerfFactor(current) {
|
|
1249
|
+
let constantAngleCount = 0;
|
|
1250
|
+
let index = 0;
|
|
1251
|
+
let currentTimeGap = 0;
|
|
1252
|
+
let loopObjPrev0 = current;
|
|
1253
|
+
let loopObjPrev1 = null;
|
|
1254
|
+
let loopObjPrev2 = null;
|
|
1255
|
+
while (currentTimeGap < this.minimumAngleRelevancyTime) {
|
|
1256
|
+
const loopObj = current.previous(index);
|
|
1257
|
+
if (!loopObj) break;
|
|
1258
|
+
const longIntervalFactor = 1 - _rian8337_osu_base.Interpolation.reverseLerp(loopObj.strainTime, this.maximumAngleRelevancyTime, this.minimumAngleRelevancyTime);
|
|
1259
|
+
if (loopObj.angle !== null && current.angle !== null) {
|
|
1260
|
+
const angleDifference = Math.abs(current.angle - loopObj.angle);
|
|
1261
|
+
let angleDifferenceAlternating = Math.PI;
|
|
1262
|
+
if (loopObjPrev0.angle !== null && typeof loopObjPrev1?.angle === "number" && typeof loopObjPrev2?.angle === "number") {
|
|
1263
|
+
angleDifferenceAlternating = Math.abs(loopObjPrev1.angle - loopObj.angle);
|
|
1264
|
+
angleDifferenceAlternating += Math.abs(loopObjPrev2.angle - loopObjPrev0.angle);
|
|
1265
|
+
let weight = 1;
|
|
1266
|
+
weight *= _rian8337_osu_base.Interpolation.reverseLerp(_rian8337_osu_base.MathUtils.radiansToDegrees(Math.min(loopObj.angle, loopObjPrev0.angle)), 20, 5);
|
|
1267
|
+
weight *= _rian8337_osu_base.Interpolation.reverseLerp(_rian8337_osu_base.MathUtils.radiansToDegrees(Math.max(loopObj.angle, loopObjPrev0.angle)), 60, 120);
|
|
1268
|
+
angleDifferenceAlternating = _rian8337_osu_base.Interpolation.lerp(Math.PI, .1 * angleDifferenceAlternating, weight);
|
|
1269
|
+
}
|
|
1270
|
+
const stackFactor = _rian8337_osu_base.MathUtils.smootherstep(loopObj.lazyJumpDistance, 0, current.normalizedRadius);
|
|
1271
|
+
constantAngleCount += Math.cos(3 * Math.min(_rian8337_osu_base.MathUtils.degreesToRadians(30), Math.min(angleDifference, angleDifferenceAlternating) * stackFactor)) * longIntervalFactor;
|
|
1272
|
+
}
|
|
1273
|
+
currentTimeGap = current.startTime - loopObj.startTime;
|
|
1274
|
+
index++;
|
|
1275
|
+
loopObjPrev2 = loopObjPrev1;
|
|
1276
|
+
loopObjPrev1 = loopObjPrev0;
|
|
1277
|
+
loopObjPrev0 = loopObj;
|
|
1278
|
+
}
|
|
1279
|
+
return _rian8337_osu_base.MathUtils.clamp(2 / constantAngleCount, .2, 1);
|
|
1280
|
+
}
|
|
1281
|
+
/**
|
|
1282
|
+
* Returns a nerfing factor for when objects are very distant in time, affecting reading less.
|
|
1283
|
+
*/
|
|
1284
|
+
static getTimeNerfFactor(deltaTime) {
|
|
1285
|
+
return _rian8337_osu_base.MathUtils.clamp(2 - deltaTime / (this.readingWindowSize / 2), 0, 1);
|
|
1286
|
+
}
|
|
1287
|
+
static highBpmBonus(ms) {
|
|
1288
|
+
return 1 / (1 - Math.pow(.8, ms / 1e3));
|
|
1289
|
+
}
|
|
1290
|
+
};
|
|
1291
|
+
// src/skills/droid/DroidReading.ts
|
|
1292
|
+
/**
|
|
1293
|
+
* Represents the skill required to read every object in the beatmap.
|
|
1294
|
+
*/
|
|
1295
|
+
var DroidReading = class extends HarmonicSkill {
|
|
1296
|
+
clockRate;
|
|
1297
|
+
hitObjects;
|
|
1298
|
+
currentDifficulty = 0;
|
|
1299
|
+
skillMultiplier = 2.5;
|
|
1300
|
+
difficultyDecayBase = .8;
|
|
1301
|
+
constructor(mods, clockRate, hitObjects) {
|
|
1302
|
+
super(mods);
|
|
1303
|
+
this.clockRate = clockRate;
|
|
1304
|
+
this.hitObjects = hitObjects;
|
|
1305
|
+
}
|
|
1306
|
+
countTopWeightedObjectDifficulties(difficultyValue) {
|
|
1307
|
+
if (difficultyValue === 0) return 0;
|
|
1308
|
+
if (this.noteWeightSum === 0) return 0;
|
|
1309
|
+
const consistentTopNote = difficultyValue / this.noteWeightSum;
|
|
1310
|
+
if (consistentTopNote === 0) return 0;
|
|
1311
|
+
return this.objectDifficulties.reduce((total, next) => total + _rian8337_osu_base.MathUtils.offsetLogistic(next / consistentTopNote, 1.15, 5, 1.1), 0);
|
|
1312
|
+
}
|
|
1313
|
+
objectDifficultyOf(current) {
|
|
1314
|
+
const decay = this.difficultyDecay(current.deltaTime);
|
|
1315
|
+
this.currentDifficulty *= decay;
|
|
1316
|
+
this.currentDifficulty += this.calculateAdjustedDifficulty(current) * (1 - decay) * this.skillMultiplier;
|
|
1317
|
+
return this.currentDifficulty;
|
|
1318
|
+
}
|
|
1319
|
+
applyDifficultyTransformation(difficulties) {
|
|
1320
|
+
const reducedNoteCount = this.calculateReducedNoteCount();
|
|
1321
|
+
for (let i = 0; i < Math.min(difficulties.length, reducedNoteCount); ++i) difficulties[i] *= Math.log10(_rian8337_osu_base.Interpolation.lerp(1, 10, _rian8337_osu_base.MathUtils.clamp(i / reducedNoteCount, 0, 1)));
|
|
1322
|
+
}
|
|
1323
|
+
saveToHitObject(current, difficulty) {
|
|
1324
|
+
current.readingDifficulty = difficulty;
|
|
1325
|
+
}
|
|
1326
|
+
calculateAdjustedDifficulty(current) {
|
|
1327
|
+
let difficulty = DroidReadingEvaluator.evaluateDifficultyOf(current, this.mods);
|
|
1328
|
+
if (this.mods.has(_rian8337_osu_base.ModRelax)) difficulty *= .4;
|
|
1329
|
+
else if (this.mods.has(_rian8337_osu_base.ModAutopilot)) difficulty *= .1;
|
|
1330
|
+
return difficulty;
|
|
1331
|
+
}
|
|
1332
|
+
calculateReducedNoteCount() {
|
|
1333
|
+
if (this.hitObjects.length < 2) return 0;
|
|
1334
|
+
const reducedDuration = this.hitObjects[1].startTime / this.clockRate + 6e4;
|
|
1335
|
+
let reducedNoteCount = 0;
|
|
1336
|
+
for (let i = 1; i < this.hitObjects.length; ++i) {
|
|
1337
|
+
if (this.hitObjects[i].startTime / this.clockRate > reducedDuration) break;
|
|
1338
|
+
++reducedNoteCount;
|
|
1339
|
+
}
|
|
1340
|
+
return reducedNoteCount;
|
|
1341
|
+
}
|
|
1342
|
+
difficultyDecay(ms) {
|
|
1343
|
+
return Math.pow(this.difficultyDecayBase, ms / 1e3);
|
|
1344
|
+
}
|
|
1345
|
+
};
|
|
1346
|
+
// src/evaluators/droid/DroidTapEvaluator.ts
|
|
1347
|
+
/**
|
|
1348
|
+
* An evaluator for calculating osu!droid tap skill.
|
|
1349
|
+
*/
|
|
1350
|
+
var DroidTapEvaluator = class {
|
|
1351
|
+
static minSpeedBonus = 200;
|
|
1352
|
+
/**
|
|
1353
|
+
* Evaluates the difficulty of tapping the current object, based on:
|
|
1354
|
+
*
|
|
1355
|
+
* - time between pressing the previous and current object,
|
|
1356
|
+
* - distance between those objects,
|
|
1357
|
+
* - how easily they can be cheesed,
|
|
1358
|
+
* - and the strain time cap.
|
|
1359
|
+
*
|
|
1360
|
+
* @param current The current object.
|
|
1361
|
+
* @param considerCheesability Whether to consider cheesability.
|
|
1362
|
+
*/
|
|
1363
|
+
static evaluateDifficultyOf(current, considerCheesability) {
|
|
1364
|
+
if (current.index < 0 || current.object instanceof _rian8337_osu_base.Spinner || current.isOverlapping(false)) return 0;
|
|
1365
|
+
const doubletapness = considerCheesability ? 1 - current.getDoubletapness(current.next(0)) : 1;
|
|
1366
|
+
let speedBonus = 1;
|
|
1367
|
+
if (_rian8337_osu_base.MathUtils.millisecondsToBPM(current.strainTime) > this.minSpeedBonus) speedBonus += .75 * Math.pow(_rian8337_osu_base.ErrorFunction.erf((_rian8337_osu_base.MathUtils.bpmToMilliseconds(this.minSpeedBonus) - current.strainTime) / 40), 2);
|
|
1368
|
+
let strain = speedBonus * 1e3 / current.strainTime;
|
|
1369
|
+
strain *= this.highBpmBonus(current.strainTime);
|
|
1370
|
+
return strain * Math.pow(doubletapness, 1.5);
|
|
1371
|
+
}
|
|
1372
|
+
static highBpmBonus(ms) {
|
|
1373
|
+
return 1 / (1 - Math.pow(.3, ms / 1e3));
|
|
1374
|
+
}
|
|
1375
|
+
};
|
|
1376
|
+
// src/skills/droid/DroidTap.ts
|
|
1377
|
+
/**
|
|
1378
|
+
* Represents the skill required to press keys or tap with regards to keeping up with the speed at which objects need to be hit.
|
|
1379
|
+
*/
|
|
1380
|
+
var DroidTap = class extends HarmonicSkill {
|
|
1381
|
+
harmonicScale = 20;
|
|
1382
|
+
skillMultiplier = 1.16;
|
|
1383
|
+
strainDecayBase = .3;
|
|
1384
|
+
currentTapDifficulty = 0;
|
|
1385
|
+
currentRhythmMultiplier = 0;
|
|
1386
|
+
sliderDifficulties = [];
|
|
1387
|
+
maxDifficulty = 0;
|
|
1388
|
+
considerCheesability;
|
|
1389
|
+
constructor(mods, considerCheesability) {
|
|
1390
|
+
super(mods);
|
|
1391
|
+
this.considerCheesability = considerCheesability;
|
|
1392
|
+
}
|
|
1393
|
+
/**
|
|
1394
|
+
* The amount of notes that are relevant to the difficulty.
|
|
1395
|
+
*/
|
|
1396
|
+
relevantNoteCount() {
|
|
1397
|
+
if (this.objectDifficulties.length === 0 || this.maxDifficulty === 0) return 0;
|
|
1398
|
+
return this.objectDifficulties.reduce((total, next) => total + 1 / (1 + Math.exp(-(next / this.maxDifficulty * 12 - 6))), 0);
|
|
1399
|
+
}
|
|
1400
|
+
/**
|
|
1401
|
+
* Obtains the amount of sliders that are considered difficult in terms of relative difficulty, weighted by consistency.
|
|
1402
|
+
*
|
|
1403
|
+
* @param difficultyValue The final difficulty value.
|
|
1404
|
+
*/
|
|
1405
|
+
countTopWeightedSliders(difficultyValue) {
|
|
1406
|
+
if (this.sliderDifficulties.length === 0) return 0;
|
|
1407
|
+
if (this.noteWeightSum === 0) return 0;
|
|
1408
|
+
const consistentTopNote = difficultyValue / this.noteWeightSum;
|
|
1409
|
+
if (consistentTopNote === 0) return 0;
|
|
1410
|
+
return this.sliderDifficulties.reduce((total, next) => total + _rian8337_osu_base.MathUtils.offsetLogistic(next / consistentTopNote, .88, 10, 1.1), 0);
|
|
1411
|
+
}
|
|
1412
|
+
objectDifficultyOf(current) {
|
|
1413
|
+
if (this.mods.has(_rian8337_osu_base.ModRelax)) return 0;
|
|
1414
|
+
const decay = this.strainDecay(current.strainTime);
|
|
1415
|
+
this.currentTapDifficulty *= decay;
|
|
1416
|
+
this.currentTapDifficulty += DroidTapEvaluator.evaluateDifficultyOf(current, this.considerCheesability) * (1 - decay) * this.skillMultiplier;
|
|
1417
|
+
this.currentRhythmMultiplier = current.rhythmMultiplier;
|
|
1418
|
+
const difficulty = this.currentTapDifficulty * this.currentRhythmMultiplier;
|
|
1419
|
+
this.maxDifficulty = Math.max(this.maxDifficulty, difficulty);
|
|
1420
|
+
if (current.object instanceof _rian8337_osu_base.Slider) this.sliderDifficulties.push(difficulty);
|
|
1421
|
+
return difficulty;
|
|
1422
|
+
}
|
|
1423
|
+
saveToHitObject(current) {
|
|
1424
|
+
const difficulty = this.currentTapDifficulty * this.currentRhythmMultiplier;
|
|
1425
|
+
if (this.considerCheesability) current.tapDifficulty = difficulty;
|
|
1426
|
+
else current.originalTapDifficulty = difficulty;
|
|
1427
|
+
}
|
|
1428
|
+
strainDecay(ms) {
|
|
1429
|
+
return Math.pow(this.strainDecayBase, ms / 1e3);
|
|
1430
|
+
}
|
|
1431
|
+
};
|
|
1432
|
+
// src/DroidPerformanceCalculator.ts
|
|
1433
|
+
/**
|
|
1434
|
+
* A performance points calculator that calculates performance points for osu!droid gamemode.
|
|
1435
|
+
*/
|
|
1436
|
+
var DroidPerformanceCalculator = class DroidPerformanceCalculator extends PerformanceCalculator {
|
|
1437
|
+
/**
|
|
1438
|
+
* The total score achieved in the score.
|
|
1439
|
+
*/
|
|
1440
|
+
get totalScore() {
|
|
1441
|
+
return this._totalScore;
|
|
1442
|
+
}
|
|
1443
|
+
static finalMultiplier = 1.24;
|
|
1444
|
+
static normExponent = 1.1;
|
|
1445
|
+
_sliderCheesePenalty = 1;
|
|
1446
|
+
_tapPenalty = 1;
|
|
1447
|
+
_effectiveMissCount = 0;
|
|
1448
|
+
_deviation = 0;
|
|
1449
|
+
_tapDeviation = 0;
|
|
1450
|
+
_totalScore = null;
|
|
1451
|
+
createPerformanceAttributes() {
|
|
1452
|
+
if (this.usingClassicSliderAccuracy && this.totalScore !== null) {
|
|
1453
|
+
const remainingScore = this.difficultyAttributes.maximumScore - this.totalScore;
|
|
1454
|
+
const scoreBasedMissCount = Math.max(1, (this.totalScore - remainingScore) / this.totalScore);
|
|
1455
|
+
this._effectiveMissCount = Math.min(scoreBasedMissCount, this.calculateMaximumComboBasedMissCount());
|
|
1456
|
+
} else this._effectiveMissCount = this.calculateComboBasedEstimatedMissCount();
|
|
1457
|
+
this._effectiveMissCount = _rian8337_osu_base.MathUtils.clamp(this._effectiveMissCount, this.computedAccuracy.nmiss, this.totalHits);
|
|
1458
|
+
let { finalMultiplier } = DroidPerformanceCalculator;
|
|
1459
|
+
if (this.mods.has(_rian8337_osu_base.ModNoFail)) finalMultiplier *= Math.max(.9, 1 - .02 * this._effectiveMissCount);
|
|
1460
|
+
if (this.mods.has(_rian8337_osu_base.ModRelax)) {
|
|
1461
|
+
const od = (79.5 - this.getHitWindow().greatWindow / this.difficultyAttributes.clockRate) / 6;
|
|
1462
|
+
const n100Multiplier = .75 * Math.max(0, od > 0 ? 1 - od / 13.33 : 1);
|
|
1463
|
+
const n50Multiplier = Math.max(0, od > 0 ? 1 - Math.pow(od / 13.33, 5) : 1);
|
|
1464
|
+
this._effectiveMissCount = Math.min(this._effectiveMissCount + this.computedAccuracy.n100 * n100Multiplier + this.computedAccuracy.n50 * n50Multiplier, this.totalHits);
|
|
1465
|
+
}
|
|
1466
|
+
this._deviation = this.calculateAimDeviation();
|
|
1467
|
+
this._tapDeviation = this.calculateTapDeviation();
|
|
1468
|
+
const aim = this.calculateAimValue();
|
|
1469
|
+
const tap = this.calculateTapValue();
|
|
1470
|
+
const accuracy = this.calculateAccuracyValue();
|
|
1471
|
+
const flashlight = this.calculateFlashlightValue();
|
|
1472
|
+
const reading = this.calculateReadingValue();
|
|
1473
|
+
const cognitionValue = DroidDifficultyCalculator.sumCognitionDifficulty(reading, flashlight);
|
|
1474
|
+
return {
|
|
1475
|
+
total: _rian8337_osu_base.MathUtils.norm(DroidPerformanceCalculator.normExponent, aim, tap, accuracy, cognitionValue) * finalMultiplier,
|
|
1476
|
+
aim,
|
|
1477
|
+
tap,
|
|
1478
|
+
accuracy,
|
|
1479
|
+
flashlight,
|
|
1480
|
+
reading,
|
|
1481
|
+
effectiveMissCount: this._effectiveMissCount,
|
|
1482
|
+
tapPenalty: this._tapPenalty,
|
|
1483
|
+
deviation: this._deviation,
|
|
1484
|
+
tapDeviation: this._tapDeviation,
|
|
1485
|
+
sliderCheesePenalty: this._sliderCheesePenalty
|
|
1486
|
+
};
|
|
1487
|
+
}
|
|
1488
|
+
handleOptions(options) {
|
|
1489
|
+
this._tapPenalty = Math.max(options?.tapPenalty ?? 1, 1);
|
|
1490
|
+
this._sliderCheesePenalty = _rian8337_osu_base.MathUtils.clamp(options?.sliderCheesePenalty ?? 1, 0, 1);
|
|
1491
|
+
this._totalScore = options?.totalScore !== void 0 ? _rian8337_osu_base.MathUtils.clamp(options.totalScore, 0, this.difficultyAttributes.maximumScore) : null;
|
|
1492
|
+
super.handleOptions(options);
|
|
1493
|
+
}
|
|
1494
|
+
/**
|
|
1495
|
+
* Calculates the aim performance value of the beatmap.
|
|
1496
|
+
*/
|
|
1497
|
+
calculateAimValue() {
|
|
1498
|
+
let { aimDifficulty } = this.difficultyAttributes;
|
|
1499
|
+
const { aimDifficultSliderCount, sliderFactor } = this.difficultyAttributes;
|
|
1500
|
+
if (aimDifficultSliderCount > 0) {
|
|
1501
|
+
let estimateImproperlyFollowedDifficultSliders;
|
|
1502
|
+
if (this.usingClassicSliderAccuracy) estimateImproperlyFollowedDifficultSliders = _rian8337_osu_base.MathUtils.clamp(Math.min(this.totalImperfectHits, this.difficultyAttributes.maxCombo - this.combo), 0, aimDifficultSliderCount);
|
|
1503
|
+
else estimateImproperlyFollowedDifficultSliders = _rian8337_osu_base.MathUtils.clamp(this.sliderEndsDropped + this.sliderTicksMissed, 0, aimDifficultSliderCount);
|
|
1504
|
+
aimDifficulty *= (1 - sliderFactor) * Math.pow(1 - estimateImproperlyFollowedDifficultSliders / aimDifficultSliderCount, 3) + sliderFactor;
|
|
1505
|
+
}
|
|
1506
|
+
let aimValue = DroidAim.difficultyToPerformance(aimDifficulty);
|
|
1507
|
+
if (this._effectiveMissCount > 0) {
|
|
1508
|
+
const aimEstimatedSliderBreaks = this.calculateEstimatedSliderBreaks(this.difficultyAttributes.aimTopWeightedSliderFactor);
|
|
1509
|
+
const relevantMissCount = Math.min(this._effectiveMissCount + aimEstimatedSliderBreaks, this.totalImperfectHits + this.sliderTicksMissed);
|
|
1510
|
+
aimValue *= Math.min(this.calculateStrainBasedMissPenalty(relevantMissCount, this.difficultyAttributes.aimDifficultStrainCount), this.proportionalMissPenalty);
|
|
1511
|
+
}
|
|
1512
|
+
aimValue *= this.calculateDeviationBasedLengthScaling();
|
|
1513
|
+
aimValue *= this._sliderCheesePenalty;
|
|
1514
|
+
aimValue *= 1.025 * Math.pow(_rian8337_osu_base.ErrorFunction.erf(25 / (Math.SQRT2 * this._deviation)), .475);
|
|
1515
|
+
return aimValue;
|
|
1516
|
+
}
|
|
1517
|
+
/**
|
|
1518
|
+
* Calculates the tap performance value of the beatmap.
|
|
1519
|
+
*/
|
|
1520
|
+
calculateTapValue() {
|
|
1521
|
+
if (this.totalSuccessfulHits === 0) return 0;
|
|
1522
|
+
let tapValue = DroidTap.difficultyToPerformance(this.difficultyAttributes.tapDifficulty);
|
|
1523
|
+
if (this._effectiveMissCount > 0) {
|
|
1524
|
+
const tapEstimatedSliderBreaks = this.calculateEstimatedSliderBreaks(this.difficultyAttributes.tapTopWeightedSliderFactor);
|
|
1525
|
+
const relevantMissCount = Math.min(this._effectiveMissCount + tapEstimatedSliderBreaks, this.totalImperfectHits + this.sliderTicksMissed);
|
|
1526
|
+
tapValue *= this.calculateStrainBasedMissPenalty(relevantMissCount, this.difficultyAttributes.tapDifficultStrainCount);
|
|
1527
|
+
}
|
|
1528
|
+
tapValue *= Math.min(1, this.calculateDeviationBasedLengthScaling(Math.min(this.difficultyAttributes.speedNoteCount, this.totalHits / 1.45)));
|
|
1529
|
+
const effectiveHitWindow = 35 * Math.pow(4 / this.difficultyAttributes.tapDifficulty, 1.8);
|
|
1530
|
+
const effectiveAccuracy = _rian8337_osu_base.ErrorFunction.erf(effectiveHitWindow / this._tapDeviation);
|
|
1531
|
+
tapValue *= Math.pow(effectiveAccuracy, 2);
|
|
1532
|
+
tapValue *= this.calculateTapHighDeviationNerf();
|
|
1533
|
+
tapValue /= this._tapPenalty;
|
|
1534
|
+
return tapValue;
|
|
1535
|
+
}
|
|
1536
|
+
/**
|
|
1537
|
+
* Calculates the accuracy performance value of the beatmap.
|
|
1538
|
+
*/
|
|
1539
|
+
calculateAccuracyValue() {
|
|
1540
|
+
if (this.mods.has(_rian8337_osu_base.ModRelax) || this.totalSuccessfulHits === 0) return 0;
|
|
1541
|
+
let accuracyValue = 650 * Math.exp(-.1 * this._deviation);
|
|
1542
|
+
const ncircles = this.mods.has(_rian8337_osu_base.ModScoreV2) ? this.totalHits - this.difficultyAttributes.spinnerCount : this.difficultyAttributes.hitCircleCount;
|
|
1543
|
+
accuracyValue *= Math.pow(Math.log(1 + (Math.E - 1) * ncircles / 1e3), ncircles < 1e3 ? .5 : .25);
|
|
1544
|
+
accuracyValue *= _rian8337_osu_base.MathUtils.offsetLogistic(this.difficultyAttributes.rhythmDifficulty, 1, .5, 1.8);
|
|
1545
|
+
accuracyValue *= Math.pow(.97, Math.max(0, this._effectiveMissCount - 1));
|
|
1546
|
+
return accuracyValue;
|
|
1547
|
+
}
|
|
1548
|
+
/**
|
|
1549
|
+
* Calculates the flashlight performance value of the beatmap.
|
|
1550
|
+
*/
|
|
1551
|
+
calculateFlashlightValue() {
|
|
1552
|
+
if (!this.mods.has(_rian8337_osu_base.ModFlashlight)) return 0;
|
|
1553
|
+
let flashlightValue = DroidFlashlight.difficultyToPerformance(this.difficultyAttributes.flashlightDifficulty);
|
|
1554
|
+
if (this._effectiveMissCount > 0) flashlightValue *= .97 * Math.pow(1 - Math.pow(this._effectiveMissCount / this.totalHits, .775), Math.pow(this._effectiveMissCount, .875));
|
|
1555
|
+
flashlightValue *= _rian8337_osu_base.ErrorFunction.erf(50 / (Math.SQRT2 * this._deviation));
|
|
1556
|
+
return flashlightValue;
|
|
1557
|
+
}
|
|
1558
|
+
/**
|
|
1559
|
+
* Calculates the reading performance value of the beatmap.
|
|
1560
|
+
*/
|
|
1561
|
+
calculateReadingValue() {
|
|
1562
|
+
let readingValue = DroidReading.difficultyToPerformance(this.difficultyAttributes.readingDifficulty);
|
|
1563
|
+
if (this._effectiveMissCount > 0) {
|
|
1564
|
+
const aimEstimatedSliderBreaks = this.calculateEstimatedSliderBreaks(this.difficultyAttributes.aimTopWeightedSliderFactor);
|
|
1565
|
+
readingValue *= Math.min(this.calculateStrainBasedMissPenalty(this._effectiveMissCount + aimEstimatedSliderBreaks, this.difficultyAttributes.readingDifficultNoteCount), this.proportionalMissPenalty);
|
|
1566
|
+
}
|
|
1567
|
+
readingValue *= Math.min(1, this.calculateDeviationBasedLengthScaling(void 0, true));
|
|
1568
|
+
readingValue *= 1.025 * Math.pow(_rian8337_osu_base.ErrorFunction.erf(25 / (Math.SQRT2 * this._deviation)), 1.25);
|
|
1569
|
+
return readingValue;
|
|
1570
|
+
}
|
|
1571
|
+
/**
|
|
1572
|
+
* Calculates a strain-based miss penalty.
|
|
1573
|
+
*
|
|
1574
|
+
* Strain-based miss penalty assumes that a player will miss on the hardest parts of a map,
|
|
1575
|
+
* so we use the amount of relatively difficult sections to adjust miss penalty
|
|
1576
|
+
* to make it more punishing on maps with lower amount of hard sections.
|
|
1577
|
+
*/
|
|
1578
|
+
calculateStrainBasedMissPenalty(missCount, difficultStrainCount) {
|
|
1579
|
+
if (missCount === 0) return 1;
|
|
1580
|
+
return .93 / (missCount / (4 * Math.log(difficultStrainCount)) + 1);
|
|
1581
|
+
}
|
|
1582
|
+
/**
|
|
1583
|
+
* The object-based proportional miss penalty.
|
|
1584
|
+
*/
|
|
1585
|
+
get proportionalMissPenalty() {
|
|
1586
|
+
if (this._effectiveMissCount === 0) return 1;
|
|
1587
|
+
const aimEstimatedSliderBreaks = this.calculateEstimatedSliderBreaks(this.difficultyAttributes.aimTopWeightedSliderFactor);
|
|
1588
|
+
const relevantMissCount = Math.min(this._effectiveMissCount + aimEstimatedSliderBreaks, this.totalImperfectHits + this.sliderTicksMissed);
|
|
1589
|
+
if (relevantMissCount === 0) return 1;
|
|
1590
|
+
const missProportion = (this.totalHits - relevantMissCount) / (this.totalHits + 1);
|
|
1591
|
+
const noMissProportion = this.totalHits / (this.totalHits + 1);
|
|
1592
|
+
return _rian8337_osu_base.ErrorFunction.erfInv(missProportion) / _rian8337_osu_base.ErrorFunction.erfInv(noMissProportion) * Math.pow(missProportion, 8);
|
|
1593
|
+
}
|
|
1594
|
+
/**
|
|
1595
|
+
* Calculates the object-based length scaling based on the deviation of a player for a full
|
|
1596
|
+
* combo in this beatmap, taking retries into account.
|
|
1597
|
+
*
|
|
1598
|
+
* @param objectCount The amount of objects to be considered. Defaults to the amount of
|
|
1599
|
+
* objects in this beatmap.
|
|
1600
|
+
* @param punishForMemorization Whether to punish the deviation for memorization. Defaults to `false`.
|
|
1601
|
+
*/
|
|
1602
|
+
calculateDeviationBasedLengthScaling(objectCount = this.totalHits, punishForMemorization = false) {
|
|
1603
|
+
const calculateProportion = (notes) => (notes - .5) / notes;
|
|
1604
|
+
const benchmarkNotes = 700;
|
|
1605
|
+
const retryProportion = (proportion, notes, tries) => proportion + Math.sqrt(2 * proportion * (1 - proportion) / notes) * _rian8337_osu_base.ErrorFunction.erfInv(1 / tries - 1);
|
|
1606
|
+
let multiplier = Math.max(0, _rian8337_osu_base.ErrorFunction.erfInv(retryProportion(calculateProportion(objectCount), objectCount, Math.max(1, benchmarkNotes / objectCount))) / _rian8337_osu_base.ErrorFunction.erfInv(calculateProportion(benchmarkNotes)) || 0);
|
|
1607
|
+
if (punishForMemorization) multiplier *= Math.min(1, Math.sqrt(objectCount / benchmarkNotes));
|
|
1608
|
+
return multiplier;
|
|
1609
|
+
}
|
|
1610
|
+
/**
|
|
1611
|
+
* Estimates the player's deviation based on the OD, number of circles and sliders,
|
|
1612
|
+
* and number of 300s, 100s, 50s, and misses, assuming the player's mean hit error is 0.
|
|
1613
|
+
*
|
|
1614
|
+
* The estimation is consistent in that two SS scores on the same map
|
|
1615
|
+
* with the same settings will always return the same deviation.
|
|
1616
|
+
*
|
|
1617
|
+
* Sliders are treated as circles with a 50 hit window.
|
|
1618
|
+
*
|
|
1619
|
+
* Misses are ignored because they are usually due to misaiming, and 50s
|
|
1620
|
+
* are grouped with 100s since they are usually due to misreading.
|
|
1621
|
+
*
|
|
1622
|
+
* Inaccuracies are capped to the number of circles in the map.
|
|
1623
|
+
*/
|
|
1624
|
+
calculateAimDeviation() {
|
|
1625
|
+
return this.calculateDeviation(this.computedAccuracy.n300, this.computedAccuracy.n100, this.computedAccuracy.n50);
|
|
1626
|
+
}
|
|
1627
|
+
/**
|
|
1628
|
+
* Does the same as {@link calculateAimDeviation}, but only for notes and inaccuracies that are relevant to tap difficulty.
|
|
1629
|
+
*
|
|
1630
|
+
* Treats all difficult speed notes as circles, so this method can sometimes return a lower deviation than {@link calculateAimDeviation}.
|
|
1631
|
+
* This is fine though, since this method is only used to scale tap pp.
|
|
1632
|
+
*/
|
|
1633
|
+
calculateTapDeviation() {
|
|
1634
|
+
if (this.totalSuccessfulHits === 0) return Number.POSITIVE_INFINITY;
|
|
1635
|
+
const speedNoteCount = this.difficultyAttributes.speedNoteCount + (this.totalHits - this.difficultyAttributes.speedNoteCount) * .1;
|
|
1636
|
+
const relevantCountMiss = Math.min(this.computedAccuracy.nmiss, speedNoteCount);
|
|
1637
|
+
const relevantCountMeh = Math.min(this.computedAccuracy.n50, speedNoteCount - relevantCountMiss);
|
|
1638
|
+
const relevantCountOk = Math.min(this.computedAccuracy.n100, speedNoteCount - relevantCountMiss - relevantCountMeh);
|
|
1639
|
+
const relevantCountGreat = Math.max(0, speedNoteCount - relevantCountMiss - relevantCountMeh - relevantCountOk);
|
|
1640
|
+
return this.calculateDeviation(relevantCountGreat, relevantCountOk, relevantCountMeh);
|
|
1641
|
+
}
|
|
1642
|
+
/**
|
|
1643
|
+
* Estimates the player's tap deviation based on the OD, given number of greats, oks, mehs and misses,
|
|
1644
|
+
* assuming the player's mean hit error is 0. The estimation is consistent in that two SS scores on the
|
|
1645
|
+
* same map with the same settings will always return the same deviation.
|
|
1646
|
+
*
|
|
1647
|
+
* Misses are ignored because they are usually due to misaiming.
|
|
1648
|
+
*
|
|
1649
|
+
* Greats and oks are assumed to follow a normal distribution, whereas mehs are assumed to follow a uniform distribution.
|
|
1650
|
+
*/
|
|
1651
|
+
calculateDeviation(relevantCountGreat, relevantCountOk, relevantCountMeh) {
|
|
1652
|
+
if (relevantCountGreat + relevantCountOk + relevantCountMeh <= 0) return Number.POSITIVE_INFINITY;
|
|
1653
|
+
const { clockRate } = this.difficultyAttributes;
|
|
1654
|
+
const hitWindow = this.getHitWindow();
|
|
1655
|
+
const greatWindow = hitWindow.greatWindow / clockRate;
|
|
1656
|
+
const okWindow = hitWindow.okWindow / clockRate;
|
|
1657
|
+
const mehWindow = hitWindow.mehWindow / clockRate;
|
|
1658
|
+
const n = Math.max(1, relevantCountGreat + relevantCountOk);
|
|
1659
|
+
const p = relevantCountGreat / n;
|
|
1660
|
+
const z = 2.32634787404;
|
|
1661
|
+
const pLowerBound = Math.min(p, (n * p + Math.pow(z, 2) / 2) / (n + Math.pow(z, 2)) - z / (n + Math.pow(z, 2)) * Math.sqrt(n * p * (1 - p) + Math.pow(z, 2) / 4));
|
|
1662
|
+
let deviation;
|
|
1663
|
+
if (pLowerBound > .01) {
|
|
1664
|
+
deviation = greatWindow / (Math.SQRT2 * _rian8337_osu_base.ErrorFunction.erfInv(pLowerBound));
|
|
1665
|
+
const okWindowTailAmount = Math.sqrt(2 / Math.PI) * okWindow * Math.exp(-.5 * Math.pow(okWindow / deviation, 2)) / (deviation * _rian8337_osu_base.ErrorFunction.erf(okWindow / (Math.SQRT2 * deviation)));
|
|
1666
|
+
deviation *= Math.sqrt(1 - okWindowTailAmount);
|
|
1667
|
+
} else deviation = okWindow / Math.sqrt(3);
|
|
1668
|
+
const mehVariance = (mehWindow * mehWindow + okWindow * mehWindow + okWindow * okWindow) / 3;
|
|
1669
|
+
deviation = Math.sqrt(((relevantCountGreat + relevantCountOk) * Math.pow(deviation, 2) + relevantCountMeh * mehVariance) / (relevantCountGreat + relevantCountOk + relevantCountMeh));
|
|
1670
|
+
return deviation;
|
|
1671
|
+
}
|
|
1672
|
+
/**
|
|
1673
|
+
* Calculates a multiplier for tap to account for improper tapping based on the deviation and tap difficulty.
|
|
1674
|
+
*
|
|
1675
|
+
* [Graph](https://www.desmos.com/calculator/z5l9ebrwpi)
|
|
1676
|
+
*/
|
|
1677
|
+
calculateTapHighDeviationNerf() {
|
|
1678
|
+
if (this._tapDeviation == Number.POSITIVE_INFINITY) return 0;
|
|
1679
|
+
const tapValue = DroidTap.difficultyToPerformance(this.difficultyAttributes.tapDifficulty);
|
|
1680
|
+
const excessTapDifficultyCutoff = 100 + 250 * Math.pow(25 / this._tapDeviation, 6.5);
|
|
1681
|
+
if (tapValue <= excessTapDifficultyCutoff) return 1;
|
|
1682
|
+
const scale = 50;
|
|
1683
|
+
const adjustedTapValue = scale * (Math.log((tapValue - excessTapDifficultyCutoff) / scale + 1) + excessTapDifficultyCutoff / scale);
|
|
1684
|
+
const t = 1 - _rian8337_osu_base.Interpolation.reverseLerp(this._tapDeviation, 25, 30);
|
|
1685
|
+
return _rian8337_osu_base.Interpolation.lerp(adjustedTapValue, tapValue, t) / tapValue;
|
|
1686
|
+
}
|
|
1687
|
+
getHitWindow() {
|
|
1688
|
+
const { overallDifficulty } = this.difficultyAttributes;
|
|
1689
|
+
return _rian8337_osu_base.HitWindowFactory.createDroid(overallDifficulty, this.mods.has(_rian8337_osu_base.ModPrecise));
|
|
1690
|
+
}
|
|
1691
|
+
calculateEstimatedSliderBreaks(topWeightedSliderFactor) {
|
|
1692
|
+
const nonMissMistakes = this.computedAccuracy.n100 + this.computedAccuracy.n50;
|
|
1693
|
+
if (!this.usingClassicSliderAccuracy || nonMissMistakes === 0) return 0;
|
|
1694
|
+
const missedComboPercent = 1 - this.combo / this.difficultyAttributes.maxCombo;
|
|
1695
|
+
let estimatedSliderBreaks = Math.min(nonMissMistakes, this._effectiveMissCount * topWeightedSliderFactor);
|
|
1696
|
+
const nonMissMistakeAdjustment = (nonMissMistakes - estimatedSliderBreaks + 4.5) / (nonMissMistakes + 4);
|
|
1697
|
+
estimatedSliderBreaks *= _rian8337_osu_base.MathUtils.smoothstep(this._effectiveMissCount, 1, 2);
|
|
1698
|
+
return estimatedSliderBreaks * nonMissMistakeAdjustment * _rian8337_osu_base.MathUtils.offsetLogistic(missedComboPercent, .33, 15);
|
|
1699
|
+
}
|
|
1700
|
+
calculateMaximumComboBasedMissCount() {
|
|
1701
|
+
let missCount = this.computedAccuracy.nmiss;
|
|
1702
|
+
const { combo } = this;
|
|
1703
|
+
const { aimTopWeightedSliderFactor, sliderCount, maxCombo } = this.difficultyAttributes;
|
|
1704
|
+
if (sliderCount <= 0) return missCount;
|
|
1705
|
+
const likelyMissedSliderendPortion = .04 + .06 * Math.pow(Math.min(aimTopWeightedSliderFactor, 1), 2);
|
|
1706
|
+
const fullComboThreshold = maxCombo - Math.min(4 + likelyMissedSliderendPortion * sliderCount, sliderCount);
|
|
1707
|
+
if (combo < fullComboThreshold) missCount = Math.pow(fullComboThreshold / Math.max(1, combo), 2.5);
|
|
1708
|
+
missCount = Math.min(missCount, this.totalImperfectHits);
|
|
1709
|
+
const maxPossibleSliderBreaks = Math.min(sliderCount, Math.trunc((maxCombo - combo) / 2));
|
|
1710
|
+
if (missCount - this.computedAccuracy.nmiss > maxPossibleSliderBreaks) missCount = this.computedAccuracy.nmiss + maxPossibleSliderBreaks;
|
|
1711
|
+
return missCount;
|
|
1712
|
+
}
|
|
1713
|
+
/**
|
|
1714
|
+
* Calculates the amount of misses + sliderbreaks from combo.
|
|
1715
|
+
*/
|
|
1716
|
+
calculateComboBasedEstimatedMissCount() {
|
|
1717
|
+
let missCount = this.computedAccuracy.nmiss;
|
|
1718
|
+
const { combo } = this;
|
|
1719
|
+
const { aimTopWeightedSliderFactor, sliderCount, maxCombo } = this.difficultyAttributes;
|
|
1720
|
+
if (sliderCount <= 0) return missCount;
|
|
1721
|
+
if (this.usingClassicSliderAccuracy) {
|
|
1722
|
+
const likelyMissedSliderendPortion = .04 + .06 * Math.pow(Math.min(aimTopWeightedSliderFactor, 1), 2);
|
|
1723
|
+
const fullComboThreshold = maxCombo - Math.min(4 + likelyMissedSliderendPortion * sliderCount, sliderCount);
|
|
1724
|
+
if (combo < fullComboThreshold) missCount = fullComboThreshold / Math.max(1, combo);
|
|
1725
|
+
missCount = Math.min(missCount, this.totalImperfectHits);
|
|
1726
|
+
const maxPossibleSliderBreaks = Math.min(sliderCount, Math.trunc((maxCombo - combo) / 2));
|
|
1727
|
+
if (missCount - this.computedAccuracy.nmiss > maxPossibleSliderBreaks) missCount = this.computedAccuracy.nmiss + maxPossibleSliderBreaks;
|
|
1728
|
+
} else {
|
|
1729
|
+
const fullComboThreshold = maxCombo - this.sliderEndsDropped;
|
|
1730
|
+
if (combo < fullComboThreshold) missCount = fullComboThreshold / Math.max(1, combo);
|
|
1731
|
+
missCount = Math.min(missCount, this.sliderTicksMissed + this.computedAccuracy.nmiss);
|
|
1732
|
+
}
|
|
1733
|
+
return missCount;
|
|
1734
|
+
}
|
|
1735
|
+
};
|
|
1736
|
+
// src/preprocessing/DifficultyHitObject.ts
|
|
1737
|
+
/**
|
|
1738
|
+
* Represents a hit object with difficulty calculation values.
|
|
1739
|
+
*/
|
|
1740
|
+
var DifficultyHitObject = class DifficultyHitObject {
|
|
1741
|
+
/**
|
|
1742
|
+
* The underlying hitobject.
|
|
1743
|
+
*/
|
|
1744
|
+
object;
|
|
1745
|
+
/**
|
|
1746
|
+
* The index of this hitobject in the list of all hitobjects.
|
|
1747
|
+
*
|
|
1748
|
+
* This is one less than the actual index of the hitobject in the beatmap.
|
|
1749
|
+
*/
|
|
1750
|
+
index;
|
|
1751
|
+
/**
|
|
1752
|
+
* The aim strain generated by the hitobject if sliders are considered.
|
|
1753
|
+
*/
|
|
1754
|
+
aimStrainWithSliders = 0;
|
|
1755
|
+
/**
|
|
1756
|
+
* The aim strain generated by the hitobject if sliders are not considered.
|
|
1757
|
+
*/
|
|
1758
|
+
aimStrainWithoutSliders = 0;
|
|
1759
|
+
/**
|
|
1760
|
+
* The flashlight strain generated by the hitobject.
|
|
1761
|
+
*/
|
|
1762
|
+
flashlightStrain = 0;
|
|
1763
|
+
/**
|
|
1764
|
+
* The reading difficulty generated by the hitobject.
|
|
1765
|
+
*/
|
|
1766
|
+
readingDifficulty = 0;
|
|
1767
|
+
/**
|
|
1768
|
+
* The rhythm multiplier generated by the hitobject. This is used to alter tap strain.
|
|
1769
|
+
*/
|
|
1770
|
+
rhythmMultiplier = 0;
|
|
1771
|
+
/**
|
|
1772
|
+
* The normalized distance from the start position of the previous hitobject to the start position of this hitobject.
|
|
1773
|
+
*/
|
|
1774
|
+
jumpDistance = 0;
|
|
1775
|
+
/**
|
|
1776
|
+
* The normalized distance from the "lazy" end position of the previous hitobject to the start position of this hitobject.
|
|
1777
|
+
*
|
|
1778
|
+
* The "lazy" end position is the position at which the cursor ends up if the previous hitobject is followed with as minimal movement as possible (i.e. on the edge of slider follow circles).
|
|
1779
|
+
*/
|
|
1780
|
+
lazyJumpDistance = 0;
|
|
1781
|
+
/**
|
|
1782
|
+
* The normalized shortest distance to consider for a jump between the previous hitobject and this hitobject.
|
|
1783
|
+
*
|
|
1784
|
+
* This is bounded from above by `lazyJumpDistance`, and is smaller than the former if a more natural path is able to be taken through the previous hitobject.
|
|
1785
|
+
*
|
|
1786
|
+
* Suppose a linear slider - circle pattern. Following the slider lazily (see: `lazyJumpDistance`) will result in underestimating the true end position of the slider as being closer towards the start position.
|
|
1787
|
+
* As a result, `lazyJumpDistance` overestimates the jump distance because the player is able to take a more natural path by following through the slider to its end,
|
|
1788
|
+
* such that the jump is felt as only starting from the slider's true end position.
|
|
1789
|
+
*
|
|
1790
|
+
* Now consider a slider - circle pattern where the circle is stacked along the path inside the slider.
|
|
1791
|
+
* In this case, the lazy end position correctly estimates the true end position of the slider and provides the more natural movement path.
|
|
1792
|
+
*/
|
|
1793
|
+
minimumJumpDistance = 0;
|
|
1794
|
+
/**
|
|
1795
|
+
* The time taken to travel through `minimumJumpDistance`, with a minimum value of 25ms.
|
|
1796
|
+
*/
|
|
1797
|
+
minimumJumpTime = 0;
|
|
1798
|
+
/**
|
|
1799
|
+
* The normalized distance between the start and end position of this hitobject.
|
|
1800
|
+
*/
|
|
1801
|
+
travelDistance = 0;
|
|
1802
|
+
/**
|
|
1803
|
+
* The time taken to travel through `travelDistance`, with a minimum value of 25ms for sliders.
|
|
1804
|
+
*/
|
|
1805
|
+
travelTime = 0;
|
|
1806
|
+
/**
|
|
1807
|
+
* The position of the cursor at the point of completion of this hitobject if it was hit
|
|
1808
|
+
* with as few movements as possible.
|
|
1809
|
+
*/
|
|
1810
|
+
lazyEndPosition;
|
|
1811
|
+
/**
|
|
1812
|
+
* The distance travelled by the cursor upon completion of this hitobject if it was hit
|
|
1813
|
+
* with as few movements as possible.
|
|
1814
|
+
*/
|
|
1815
|
+
lazyTravelDistance = 0;
|
|
1816
|
+
/**
|
|
1817
|
+
* The time taken by the cursor upon completion of this hitobject if it was hit with
|
|
1818
|
+
* as few movements as possible.
|
|
1819
|
+
*/
|
|
1820
|
+
lazyTravelTime = 0;
|
|
1821
|
+
/**
|
|
1822
|
+
* Angle the player has to take to hit this hitobject.
|
|
1823
|
+
*
|
|
1824
|
+
* Calculated as the angle between the circles (current-2, current-1, current).
|
|
1825
|
+
*/
|
|
1826
|
+
angleSigned = null;
|
|
1827
|
+
/**
|
|
1828
|
+
* Unsigned angle the player has to take to hit this hitobject.
|
|
1829
|
+
*
|
|
1830
|
+
* Calculated as the angle between the circles (current-2, current-1, current).
|
|
1831
|
+
*/
|
|
1832
|
+
get angle() {
|
|
1833
|
+
return this.angleSigned !== null ? Math.abs(this.angleSigned) : null;
|
|
1834
|
+
}
|
|
1835
|
+
/**
|
|
1836
|
+
* Angle of the vector created between current and current-1 normalized to consider
|
|
1837
|
+
* symmetrical vectors in any axis to be the same angle.
|
|
1838
|
+
*/
|
|
1839
|
+
normalizedVectorAngle = null;
|
|
1840
|
+
/**
|
|
1841
|
+
* The amount of milliseconds elapsed between this hitobject and the last hitobject.
|
|
1842
|
+
*/
|
|
1843
|
+
deltaTime;
|
|
1844
|
+
/**
|
|
1845
|
+
* The amount of milliseconds elapsed since the start time of the previous hitobject, with a minimum of 25ms.
|
|
1846
|
+
*/
|
|
1847
|
+
strainTime;
|
|
1848
|
+
/**
|
|
1849
|
+
* The amount of milliseconds elapsed between the last {@link DifficultyHitObject}'s {@link endTime} and
|
|
1850
|
+
* this {@link DifficultyHitObject}'s {@link startTime} capped to a minimum of {@link minDeltaTime}ms.
|
|
1851
|
+
*/
|
|
1852
|
+
lastObjectEndDeltaTime;
|
|
1853
|
+
/**
|
|
1854
|
+
* Adjusted start time of the hitobject, taking speed multiplier into account.
|
|
1855
|
+
*/
|
|
1856
|
+
startTime;
|
|
1857
|
+
/**
|
|
1858
|
+
* Adjusted end time of the hitobject, taking speed multiplier into account.
|
|
1859
|
+
*/
|
|
1860
|
+
endTime;
|
|
1861
|
+
/**
|
|
1862
|
+
* Adjusted preempt time of the hitobject, taking speed multiplier into account.
|
|
1863
|
+
*/
|
|
1864
|
+
timePreempt;
|
|
1865
|
+
/**
|
|
1866
|
+
* The beatmap clock rate.
|
|
1867
|
+
*/
|
|
1868
|
+
clockRate;
|
|
1869
|
+
/**
|
|
1870
|
+
* This {@link DifficultyHitObject}'s immediate overall difficulty value calculated from the raw hitwindow.
|
|
1871
|
+
*/
|
|
1872
|
+
get overallDifficulty() {
|
|
1873
|
+
return this.rawHitWindow.overallDifficulty;
|
|
1874
|
+
}
|
|
1875
|
+
/**
|
|
1876
|
+
* Other hitobjects in the beatmap, including this hitobject.
|
|
1877
|
+
*/
|
|
1878
|
+
hitObjects;
|
|
1879
|
+
/**
|
|
1880
|
+
* The normalized diameter of the hitobject.
|
|
1881
|
+
*/
|
|
1882
|
+
get normalizedDiameter() {
|
|
1883
|
+
return this.normalizedRadius * 2;
|
|
1884
|
+
}
|
|
1885
|
+
get maximumSliderRadius() {
|
|
1886
|
+
return this.normalizedRadius * 2.4;
|
|
1887
|
+
}
|
|
1888
|
+
get assumedSliderRadius() {
|
|
1889
|
+
return this.normalizedRadius * 1.8;
|
|
1890
|
+
}
|
|
1891
|
+
/**
|
|
1892
|
+
* The lowest possible delta time value.
|
|
1893
|
+
*/
|
|
1894
|
+
static minDeltaTime = 25;
|
|
1895
|
+
lastObject;
|
|
1896
|
+
lastDifficultyObject;
|
|
1897
|
+
lastLastDifficultyObject;
|
|
1898
|
+
/**
|
|
1899
|
+
* Note: You **must** call `computeProperties` at some point due to how TypeScript handles
|
|
1900
|
+
* overridden properties (see [this](https://github.com/microsoft/TypeScript/issues/1617) GitHub issue).
|
|
1901
|
+
*
|
|
1902
|
+
* @param object The underlying hitobject.
|
|
1903
|
+
* @param lastObject The hitobject before this hitobject.
|
|
1904
|
+
* @param difficultyHitObjects All difficulty hitobjects in the processed beatmap.
|
|
1905
|
+
* @param clockRate The clock rate of the beatmap.
|
|
1906
|
+
* @param index The index of this hitobject in the list of all hitobjects.
|
|
1907
|
+
*/
|
|
1908
|
+
constructor(object, lastObject, difficultyHitObjects, clockRate, index) {
|
|
1909
|
+
this.object = object;
|
|
1910
|
+
this.lastObject = lastObject;
|
|
1911
|
+
this.hitObjects = difficultyHitObjects;
|
|
1912
|
+
this.clockRate = clockRate;
|
|
1913
|
+
this.index = index;
|
|
1914
|
+
this.startTime = object.startTime / clockRate;
|
|
1915
|
+
this.endTime = object.endTime / clockRate;
|
|
1916
|
+
this.timePreempt = object.timePreempt / clockRate;
|
|
1917
|
+
if (lastObject) {
|
|
1918
|
+
this.deltaTime = this.startTime - lastObject.startTime / clockRate;
|
|
1919
|
+
this.strainTime = Math.max(this.deltaTime, DifficultyHitObject.minDeltaTime);
|
|
1920
|
+
this.lastObjectEndDeltaTime = Math.max(this.startTime - lastObject.endTime / clockRate, DifficultyHitObject.minDeltaTime);
|
|
1921
|
+
} else {
|
|
1922
|
+
this.deltaTime = 0;
|
|
1923
|
+
this.strainTime = 0;
|
|
1924
|
+
this.lastObjectEndDeltaTime = 0;
|
|
1925
|
+
}
|
|
1926
|
+
this.lastDifficultyObject = this.previous(0);
|
|
1927
|
+
this.lastLastDifficultyObject = this.previous(1);
|
|
1928
|
+
}
|
|
1929
|
+
/**
|
|
1930
|
+
* Computes the properties of this hitobject.
|
|
1931
|
+
*
|
|
1932
|
+
* @param clockRate The clock rate of the beatmap.
|
|
1933
|
+
*/
|
|
1934
|
+
computeProperties(clockRate) {
|
|
1935
|
+
this.calculateSliderCursorPosition();
|
|
1936
|
+
this.setDistances(clockRate);
|
|
1937
|
+
}
|
|
1938
|
+
/**
|
|
1939
|
+
* Gets the difficulty hitobject at a specific index with respect to the current
|
|
1940
|
+
* difficulty hitobject's index.
|
|
1941
|
+
*
|
|
1942
|
+
* Will return `null` if the index is out of range.
|
|
1943
|
+
*
|
|
1944
|
+
* @param backwardsIndex The index to move backwards for.
|
|
1945
|
+
* @returns The difficulty hitobject at the index with respect to the current
|
|
1946
|
+
* difficulty hitobject's index, `null` if the index is out of range.
|
|
1947
|
+
*/
|
|
1948
|
+
previous(backwardsIndex) {
|
|
1949
|
+
return this.hitObjects[this.index - backwardsIndex - 1] ?? null;
|
|
1950
|
+
}
|
|
1951
|
+
/**
|
|
1952
|
+
* Gets the difficulty hitobject at a specific index with respect to the current
|
|
1953
|
+
* difficulty hitobject's index.
|
|
1954
|
+
*
|
|
1955
|
+
* Will return `null` if the index is out of range.
|
|
1956
|
+
*
|
|
1957
|
+
* @param forwardsIndex The index to move forwards for.
|
|
1958
|
+
* @returns The difficulty hitobject at the index with respect to the current
|
|
1959
|
+
* difficulty hitobject's index, `null` if the index is out of range.
|
|
1960
|
+
*/
|
|
1961
|
+
next(forwardsIndex) {
|
|
1962
|
+
return this.hitObjects[this.index + forwardsIndex + 1] ?? null;
|
|
1963
|
+
}
|
|
1964
|
+
/**
|
|
1965
|
+
* Calculates the opacity of the hitobject at a given time.
|
|
1966
|
+
*
|
|
1967
|
+
* @param time The time to calculate the hitobject's opacity at.
|
|
1968
|
+
* @param mods The mods used. Defaults to No Mod.
|
|
1969
|
+
* @returns The opacity of the hitobject at the given time.
|
|
1970
|
+
*/
|
|
1971
|
+
opacityAt(time, mods) {
|
|
1972
|
+
if (time > this.object.startTime) return 0;
|
|
1973
|
+
const fadeInStartTime = this.object.startTime - this.object.timePreempt;
|
|
1974
|
+
const fadeInDuration = 400 * Math.min(1, this.object.timePreempt / _rian8337_osu_base.HitObject.preemptMin);
|
|
1975
|
+
if (mods?.has(_rian8337_osu_base.ModHidden)) {
|
|
1976
|
+
const fadeOutStartTime = fadeInStartTime + fadeInDuration;
|
|
1977
|
+
const fadeOutDuration = this.object.timePreempt * _rian8337_osu_base.ModHidden.fadeOutDurationMultiplier;
|
|
1978
|
+
return Math.min(_rian8337_osu_base.MathUtils.clamp((time - fadeInStartTime) / fadeInDuration, 0, 1), 1 - _rian8337_osu_base.MathUtils.clamp((time - fadeOutStartTime) / fadeOutDuration, 0, 1));
|
|
1979
|
+
}
|
|
1980
|
+
return _rian8337_osu_base.MathUtils.clamp((time - fadeInStartTime) / fadeInDuration, 0, 1);
|
|
1981
|
+
}
|
|
1982
|
+
/**
|
|
1983
|
+
* How possible is it to doubletap this object together with the next one and get perfect
|
|
1984
|
+
* judgement in range from 0 to 1.
|
|
1985
|
+
*
|
|
1986
|
+
* A value closer to 1 indicates a higher possibility.
|
|
1987
|
+
*/
|
|
1988
|
+
getDoubletapness(nextObj) {
|
|
1989
|
+
if (!nextObj) return 0;
|
|
1990
|
+
const currentDeltaTime = Math.max(1, this.deltaTime);
|
|
1991
|
+
const nextDeltaTime = Math.max(1, nextObj.deltaTime);
|
|
1992
|
+
const deltaDifference = Math.abs(nextDeltaTime - currentDeltaTime);
|
|
1993
|
+
const speedRatio = currentDeltaTime / Math.max(currentDeltaTime, deltaDifference);
|
|
1994
|
+
const windowRatio = Math.pow(Math.min(1, currentDeltaTime / this.hitWindowFor(_rian8337_osu_base.HitResult.Great)), 5);
|
|
1995
|
+
const distanceFactor = Math.pow(_rian8337_osu_base.Interpolation.reverseLerp(this.lazyJumpDistance, this.normalizedDiameter, this.normalizedRadius), 2);
|
|
1996
|
+
return 1 - Math.pow(speedRatio, distanceFactor * (1 - windowRatio));
|
|
1997
|
+
}
|
|
1998
|
+
/**
|
|
1999
|
+
* Retrieves the full rate-adjusted hit window for a {@link HitResult}.
|
|
2000
|
+
*/
|
|
2001
|
+
hitWindowFor(result) {
|
|
2002
|
+
return 2 * this.rawHitWindow.hitWindowFor(result) / this.clockRate;
|
|
2003
|
+
}
|
|
2004
|
+
/**
|
|
2005
|
+
* The {@link HitWindow} for this {@link DifficultyHitObject}.
|
|
2006
|
+
*/
|
|
2007
|
+
get rawHitWindow() {
|
|
2008
|
+
if (this.object instanceof _rian8337_osu_base.Slider) return this.object.head.hitWindow;
|
|
2009
|
+
return this.object.hitWindow;
|
|
2010
|
+
}
|
|
2011
|
+
setDistances(clockRate) {
|
|
2012
|
+
if (this.object instanceof _rian8337_osu_base.Slider) {
|
|
2013
|
+
this.travelDistance = this.lazyTravelDistance * Math.max(1, Math.pow(this.object.repeatCount, .3));
|
|
2014
|
+
this.travelTime = Math.max(this.lazyTravelTime / clockRate, DifficultyHitObject.minDeltaTime);
|
|
2015
|
+
}
|
|
2016
|
+
this.minimumJumpTime = this.strainTime;
|
|
2017
|
+
if (!this.lastObject || this.object instanceof _rian8337_osu_base.Spinner || this.lastObject instanceof _rian8337_osu_base.Spinner) return;
|
|
2018
|
+
const scalingFactor = this.normalizedRadius / this.object.radius;
|
|
2019
|
+
let lastCursorPosition = this.lastDifficultyObject !== null ? this.getEndCursorPosition(this.lastDifficultyObject) : this.lastObject.stackedPosition;
|
|
2020
|
+
this.jumpDistance = this.lastObject.stackedPosition.getDistance(this.object.stackedPosition) * scalingFactor;
|
|
2021
|
+
this.lazyJumpDistance = this.object.stackedPosition.getDistance(lastCursorPosition) * scalingFactor;
|
|
2022
|
+
this.minimumJumpDistance = this.lazyJumpDistance;
|
|
2023
|
+
if (this.lastObject instanceof _rian8337_osu_base.Slider && this.lastDifficultyObject !== null) {
|
|
2024
|
+
const lastTravelTime = Math.max(this.lastDifficultyObject.lazyTravelTime / clockRate, DifficultyHitObject.minDeltaTime);
|
|
2025
|
+
this.minimumJumpTime = Math.max(this.strainTime - lastTravelTime, DifficultyHitObject.minDeltaTime);
|
|
2026
|
+
const tailJumpDistance = this.lastObject.tail.stackedPosition.subtract(this.object.stackedPosition).length * scalingFactor;
|
|
2027
|
+
this.minimumJumpDistance = Math.max(0, Math.min(this.lazyJumpDistance - (this.maximumSliderRadius - this.assumedSliderRadius), tailJumpDistance - this.maximumSliderRadius));
|
|
2028
|
+
}
|
|
2029
|
+
if (this.lastLastDifficultyObject && !(this.lastLastDifficultyObject.object instanceof _rian8337_osu_base.Spinner)) {
|
|
2030
|
+
const lastLastCursorPosition = this.getEndCursorPosition(this.lastLastDifficultyObject);
|
|
2031
|
+
if (this.lastDifficultyObject?.object instanceof _rian8337_osu_base.Slider && this.lastDifficultyObject.travelDistance > 0) lastCursorPosition = this.lastDifficultyObject.object.stackedPosition;
|
|
2032
|
+
const angle = this.calculateAngle(this.object.stackedPosition, lastCursorPosition, lastLastCursorPosition);
|
|
2033
|
+
const sliderAngle = this.calculateSliderAngle(this.lastDifficultyObject, lastLastCursorPosition);
|
|
2034
|
+
const v = this.object.stackedPosition.subtract(lastCursorPosition);
|
|
2035
|
+
this.normalizedVectorAngle = Math.atan2(Math.abs(v.y), Math.abs(v.x));
|
|
2036
|
+
this.angleSigned = Math.abs(angle) <= Math.abs(sliderAngle) ? angle : sliderAngle;
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
calculateAngle(currentPosition, lastPosition, lastLastPosition) {
|
|
2040
|
+
const v1 = lastLastPosition.subtract(lastPosition);
|
|
2041
|
+
const v2 = currentPosition.subtract(lastPosition);
|
|
2042
|
+
const dot = v1.dot(v2);
|
|
2043
|
+
const det = v1.x * v2.y - v1.y * v2.x;
|
|
2044
|
+
return Math.atan2(det, dot);
|
|
2045
|
+
}
|
|
2046
|
+
calculateSliderAngle(lastDifficultyObject, lastLastCursorPosition) {
|
|
2047
|
+
const lastCursorPosition = this.getEndCursorPosition(lastDifficultyObject);
|
|
2048
|
+
if (lastDifficultyObject.object instanceof _rian8337_osu_base.Slider && lastDifficultyObject.travelDistance > 0) lastLastCursorPosition = lastDifficultyObject.object.nestedHitObjects.at(-2).stackedPosition;
|
|
2049
|
+
return this.calculateAngle(this.object.stackedPosition, lastCursorPosition, lastLastCursorPosition);
|
|
2050
|
+
}
|
|
2051
|
+
calculateSliderCursorPosition() {
|
|
2052
|
+
if (!(this.object instanceof _rian8337_osu_base.Slider) || this.lazyEndPosition) return;
|
|
2053
|
+
let trackingEndTime = this.object.endTime;
|
|
2054
|
+
let { nestedHitObjects: nestedObjects } = this.object;
|
|
2055
|
+
if (this.mode === _rian8337_osu_base.Modes.Osu) {
|
|
2056
|
+
trackingEndTime = Math.max(this.object.endTime - _rian8337_osu_base.Slider.legacyLastTickOffset, this.object.startTime + this.object.duration / 2);
|
|
2057
|
+
let lastRealTick = null;
|
|
2058
|
+
for (const object of nestedObjects) if (object instanceof _rian8337_osu_base.SliderTick) lastRealTick = object;
|
|
2059
|
+
if (lastRealTick && lastRealTick.startTime > trackingEndTime) {
|
|
2060
|
+
trackingEndTime = lastRealTick.startTime;
|
|
2061
|
+
const reordered = nestedObjects.slice();
|
|
2062
|
+
reordered.splice(reordered.indexOf(lastRealTick), 1);
|
|
2063
|
+
reordered.push(lastRealTick);
|
|
2064
|
+
nestedObjects = reordered;
|
|
2065
|
+
}
|
|
2066
|
+
} else {
|
|
2067
|
+
this.lazyEndPosition = this.object.stackedPosition;
|
|
2068
|
+
if (_rian8337_osu_base.Precision.almostEquals(this.object.startTime, this.object.endTime)) return;
|
|
2069
|
+
}
|
|
2070
|
+
this.lazyTravelTime = trackingEndTime - this.object.startTime;
|
|
2071
|
+
let endTimeMin = this.lazyTravelTime / this.object.spanDuration;
|
|
2072
|
+
if (endTimeMin % 2 >= 1) endTimeMin = 1 - endTimeMin % 1;
|
|
2073
|
+
else endTimeMin %= 1;
|
|
2074
|
+
this.lazyEndPosition = this.object.stackedPosition.add(this.object.path.positionAt(endTimeMin));
|
|
2075
|
+
let currentCursorPosition = this.object.stackedPosition;
|
|
2076
|
+
const scalingFactor = this.normalizedRadius / this.object.radius;
|
|
2077
|
+
for (let i = 1; i < nestedObjects.length; ++i) {
|
|
2078
|
+
const currentMovementObject = nestedObjects[i];
|
|
2079
|
+
let currentMovement = currentMovementObject.stackedPosition.subtract(currentCursorPosition);
|
|
2080
|
+
let currentMovementLength = scalingFactor * currentMovement.length;
|
|
2081
|
+
let requiredMovement = this.assumedSliderRadius;
|
|
2082
|
+
if (i === nestedObjects.length - 1) {
|
|
2083
|
+
const lazyMovement = this.lazyEndPosition.subtract(currentCursorPosition);
|
|
2084
|
+
if (lazyMovement.length < currentMovement.length) currentMovement = lazyMovement;
|
|
2085
|
+
currentMovementLength = scalingFactor * currentMovement.length;
|
|
2086
|
+
} else if (currentMovementObject instanceof _rian8337_osu_base.SliderRepeat) requiredMovement = this.normalizedRadius;
|
|
2087
|
+
if (currentMovementLength > requiredMovement) {
|
|
2088
|
+
currentCursorPosition = currentCursorPosition.add(currentMovement.scale((currentMovementLength - requiredMovement) / currentMovementLength));
|
|
2089
|
+
currentMovementLength *= (currentMovementLength - requiredMovement) / currentMovementLength;
|
|
2090
|
+
this.lazyTravelDistance += currentMovementLength;
|
|
2091
|
+
}
|
|
2092
|
+
if (i === nestedObjects.length - 1) this.lazyEndPosition = currentCursorPosition;
|
|
2093
|
+
}
|
|
2094
|
+
}
|
|
2095
|
+
getEndCursorPosition(object) {
|
|
2096
|
+
return object.lazyEndPosition ?? object.object.stackedPosition;
|
|
2097
|
+
}
|
|
2098
|
+
};
|
|
2099
|
+
// src/preprocessing/DroidDifficultyHitObject.ts
|
|
2100
|
+
/**
|
|
2101
|
+
* Represents an osu!droid hit object with difficulty calculation values.
|
|
2102
|
+
*/
|
|
2103
|
+
var DroidDifficultyHitObject = class extends DifficultyHitObject {
|
|
2104
|
+
/**
|
|
2105
|
+
* The tap difficulty generated by the hitobject.
|
|
2106
|
+
*/
|
|
2107
|
+
tapDifficulty = 0;
|
|
2108
|
+
/**
|
|
2109
|
+
* The tap difficulty generated by the hitobject if `strainTime` isn't modified by
|
|
2110
|
+
* OD. This is used in three-finger detection.
|
|
2111
|
+
*/
|
|
2112
|
+
originalTapDifficulty = 0;
|
|
2113
|
+
/**
|
|
2114
|
+
* The rhythm difficulty generated by the hitobject.
|
|
2115
|
+
*/
|
|
2116
|
+
rhythmDifficulty = 0;
|
|
2117
|
+
normalizedRadius = 50;
|
|
2118
|
+
mode = _rian8337_osu_base.Modes.Droid;
|
|
2119
|
+
get maximumSliderRadius() {
|
|
2120
|
+
return this.normalizedRadius * 2;
|
|
2121
|
+
}
|
|
2122
|
+
get smallCircleBonus() {
|
|
2123
|
+
return 1 + Math.pow(Math.max(0, 65 - this.object.radius) / 40, 2);
|
|
2124
|
+
}
|
|
2125
|
+
opacityAt(time, mods) {
|
|
2126
|
+
if (this.object instanceof _rian8337_osu_base.Circle && mods?.has(_rian8337_osu_base.ModTraceable)) return 0;
|
|
2127
|
+
return super.opacityAt(time, mods);
|
|
2128
|
+
}
|
|
2129
|
+
previous(backwardsIndex) {
|
|
2130
|
+
return this.hitObjects[this.index - backwardsIndex] ?? null;
|
|
2131
|
+
}
|
|
2132
|
+
next(forwardsIndex) {
|
|
2133
|
+
return this.hitObjects[this.index + forwardsIndex + 2] ?? null;
|
|
2134
|
+
}
|
|
2135
|
+
/**
|
|
2136
|
+
* Determines whether this hitobject is considered overlapping with the hitobject before it.
|
|
2137
|
+
*
|
|
2138
|
+
* Keep in mind that "overlapping" in this case is overlapping to the point where both hitobjects
|
|
2139
|
+
* can be hit with just a single tap in osu!droid.
|
|
2140
|
+
*
|
|
2141
|
+
* In the case of sliders, it is considered overlapping if all nested hitobjects can be hit with
|
|
2142
|
+
* one aim motion.
|
|
2143
|
+
*
|
|
2144
|
+
* @param considerDistance Whether to consider the distance between both hitobjects.
|
|
2145
|
+
* @returns Whether the hitobject is considered overlapping.
|
|
2146
|
+
*/
|
|
2147
|
+
isOverlapping(considerDistance) {
|
|
2148
|
+
if (this.object instanceof _rian8337_osu_base.Spinner) return false;
|
|
2149
|
+
const prev = this.previous(0);
|
|
2150
|
+
if (!prev || prev.object instanceof _rian8337_osu_base.Spinner) return false;
|
|
2151
|
+
if (this.object.startTime !== prev.object.startTime) return false;
|
|
2152
|
+
if (!considerDistance) return true;
|
|
2153
|
+
const distanceThreshold = 2 * this.object.radius;
|
|
2154
|
+
const startPosition = this.object.stackedPosition;
|
|
2155
|
+
const prevStartPosition = prev.object.stackedPosition;
|
|
2156
|
+
if (startPosition.getDistance(prevStartPosition) > distanceThreshold) return false;
|
|
2157
|
+
if (this.object instanceof _rian8337_osu_base.Circle || prev.object instanceof _rian8337_osu_base.Circle) return true;
|
|
2158
|
+
for (let i = 1; i < this.object.nestedHitObjects.length; ++i) {
|
|
2159
|
+
const position = this.object.nestedHitObjects[i].stackedPosition;
|
|
2160
|
+
const prevPosition = prevStartPosition.add(prev.object.curvePositionAt(i / (this.object.nestedHitObjects.length - 1)));
|
|
2161
|
+
if (position.getDistance(prevPosition) > distanceThreshold) return false;
|
|
2162
|
+
}
|
|
2163
|
+
for (let i = 1; i < prev.object.nestedHitObjects.length; ++i) {
|
|
2164
|
+
const prevPosition = prev.object.nestedHitObjects[i].stackedPosition;
|
|
2165
|
+
const position = startPosition.add(this.object.curvePositionAt(i / (prev.object.nestedHitObjects.length - 1)));
|
|
2166
|
+
if (prevPosition.getDistance(position) > distanceThreshold) return false;
|
|
2167
|
+
}
|
|
2168
|
+
return true;
|
|
2169
|
+
}
|
|
2170
|
+
};
|
|
2171
|
+
// src/evaluators/base/Island.ts
|
|
2172
|
+
/**
|
|
2173
|
+
* Represents a group of consecutive objects with the same delta time.
|
|
2174
|
+
*/
|
|
2175
|
+
var Island = class {
|
|
2176
|
+
/**
|
|
2177
|
+
* Delta time of every object in this island.
|
|
2178
|
+
*/
|
|
2179
|
+
delta = Number.MAX_SAFE_INTEGER;
|
|
2180
|
+
/**
|
|
2181
|
+
* How long the island is.
|
|
2182
|
+
*/
|
|
2183
|
+
deltaCount = 1;
|
|
2184
|
+
/**
|
|
2185
|
+
* How many times the island already occured.
|
|
2186
|
+
*/
|
|
2187
|
+
occurrences = 1;
|
|
2188
|
+
constructor(delta) {
|
|
2189
|
+
this.delta = Math.max(Math.trunc(delta), DifficultyHitObject.minDeltaTime);
|
|
2190
|
+
}
|
|
2191
|
+
addDelta(delta) {
|
|
2192
|
+
if (this.delta === Number.MAX_SAFE_INTEGER) this.delta = Math.max(Math.trunc(delta), DifficultyHitObject.minDeltaTime);
|
|
2193
|
+
++this.deltaCount;
|
|
2194
|
+
}
|
|
2195
|
+
isSimilarPolarity(other, epsilon) {
|
|
2196
|
+
if (this.deltaCount <= 1 || other.deltaCount <= 1) return false;
|
|
2197
|
+
return Math.abs(this.delta - other.delta) < epsilon && this.deltaCount % 2 === other.deltaCount % 2;
|
|
2198
|
+
}
|
|
2199
|
+
almostEquals(other, epsilon) {
|
|
2200
|
+
return Math.abs(this.delta - other.delta) < epsilon && this.deltaCount === other.deltaCount;
|
|
2201
|
+
}
|
|
2202
|
+
};
|
|
2203
|
+
// src/evaluators/droid/DroidRhythmEvaluator.ts
|
|
2204
|
+
/**
|
|
2205
|
+
* An evaluator for calculating osu!droid Rhythm skill.
|
|
2206
|
+
*/
|
|
2207
|
+
var DroidRhythmEvaluator = class {
|
|
2208
|
+
static historyTimeMax = 5e3;
|
|
2209
|
+
static historyObjectsMax = 32;
|
|
2210
|
+
static rhythmOverallMultiplier = .95;
|
|
2211
|
+
static rhythmRatioMultiplier = 26;
|
|
2212
|
+
/**
|
|
2213
|
+
* Calculates a rhythm multiplier for the difficulty of the tap associated
|
|
2214
|
+
* with historic data of the current object.
|
|
2215
|
+
*
|
|
2216
|
+
* @param current The current object.
|
|
2217
|
+
* @param useSliderAccuracy Whether to use slider accuracy.
|
|
2218
|
+
*/
|
|
2219
|
+
static evaluateDifficultyOf(current, useSliderAccuracy) {
|
|
2220
|
+
if (current.object instanceof _rian8337_osu_base.Spinner) return 1;
|
|
2221
|
+
const deltaDifferenceEpsilon = current.hitWindowFor(_rian8337_osu_base.HitResult.Great) * .3;
|
|
2222
|
+
let rhythmComplexitySum = 0;
|
|
2223
|
+
let island = new Island(Number.MAX_SAFE_INTEGER);
|
|
2224
|
+
let previousIsland = new Island(Number.MAX_SAFE_INTEGER);
|
|
2225
|
+
const islands = [];
|
|
2226
|
+
let startRatio = 0;
|
|
2227
|
+
let firstDeltaSwitch = false;
|
|
2228
|
+
let rhythmStart = 0;
|
|
2229
|
+
const historicalNoteCount = Math.min(current.index, this.historyObjectsMax);
|
|
2230
|
+
const validPrevious = [];
|
|
2231
|
+
for (let i = 0; i < historicalNoteCount; ++i) {
|
|
2232
|
+
const object = current.previous(i);
|
|
2233
|
+
if (!object) break;
|
|
2234
|
+
if (!object.isOverlapping(false)) validPrevious.push(object);
|
|
2235
|
+
}
|
|
2236
|
+
while (rhythmStart < validPrevious.length - 2 && current.startTime - validPrevious[rhythmStart].startTime < this.historyTimeMax) ++rhythmStart;
|
|
2237
|
+
let prevObject = validPrevious[rhythmStart];
|
|
2238
|
+
let lastObject = validPrevious[rhythmStart + 1];
|
|
2239
|
+
for (let i = rhythmStart; i > 0; --i) {
|
|
2240
|
+
const currentObject = validPrevious[i - 1];
|
|
2241
|
+
if (currentObject.object instanceof _rian8337_osu_base.Spinner) continue;
|
|
2242
|
+
const timeDecay = (this.historyTimeMax - (current.startTime - currentObject.startTime)) / this.historyTimeMax;
|
|
2243
|
+
const noteDecay = (validPrevious.length - i) / validPrevious.length;
|
|
2244
|
+
const currentHistoricalDecay = Math.min(timeDecay, noteDecay);
|
|
2245
|
+
const currentDelta = Math.max(currentObject.deltaTime, 1e-7);
|
|
2246
|
+
const prevDelta = Math.max(prevObject.deltaTime, 1e-7);
|
|
2247
|
+
const lastDelta = Math.max(lastObject.deltaTime, 1e-7);
|
|
2248
|
+
if (island.delta == Number.MAX_SAFE_INTEGER) island = new Island(currentDelta);
|
|
2249
|
+
const deltaDifference = Math.max(prevDelta, currentDelta) / Math.min(prevDelta, currentDelta);
|
|
2250
|
+
const differenceMultiplier = _rian8337_osu_base.MathUtils.clamp(2 - deltaDifference / 8, 0, 1);
|
|
2251
|
+
let effectiveRatio = Math.min(1, Math.max(0, Math.abs(prevDelta - currentDelta) - deltaDifferenceEpsilon) / deltaDifferenceEpsilon) * this.getEffectiveRatio(deltaDifference) * differenceMultiplier;
|
|
2252
|
+
if (prevObject.object instanceof _rian8337_osu_base.Slider) {
|
|
2253
|
+
const sliderLazyEndDelta = currentObject.minimumJumpTime;
|
|
2254
|
+
const sliderLazyEndDeltaDifference = Math.max(sliderLazyEndDelta, currentDelta) / Math.min(sliderLazyEndDelta, currentDelta);
|
|
2255
|
+
const sliderRealEndDelta = currentObject.lastObjectEndDeltaTime;
|
|
2256
|
+
const sliderRealEndDeltaDifference = Math.max(sliderRealEndDelta, currentDelta) / Math.min(sliderRealEndDelta, currentDelta);
|
|
2257
|
+
const sliderEffectiveRatio = Math.min(this.getEffectiveRatio(sliderLazyEndDeltaDifference), this.getEffectiveRatio(sliderRealEndDeltaDifference));
|
|
2258
|
+
effectiveRatio = Math.min(sliderEffectiveRatio, effectiveRatio);
|
|
2259
|
+
}
|
|
2260
|
+
const isSpeedingUp = prevDelta > currentDelta + deltaDifferenceEpsilon;
|
|
2261
|
+
if (Math.abs(prevDelta - currentDelta) < deltaDifferenceEpsilon) island.addDelta(currentDelta);
|
|
2262
|
+
if (firstDeltaSwitch) {
|
|
2263
|
+
if (Math.abs(prevDelta - currentDelta) > deltaDifferenceEpsilon) {
|
|
2264
|
+
if (!useSliderAccuracy && currentObject.object instanceof _rian8337_osu_base.Slider) effectiveRatio /= 2;
|
|
2265
|
+
if (island.isSimilarPolarity(previousIsland, deltaDifferenceEpsilon)) effectiveRatio /= 2;
|
|
2266
|
+
if (lastDelta > prevDelta + deltaDifferenceEpsilon && prevDelta > currentDelta + deltaDifferenceEpsilon) effectiveRatio /= 8;
|
|
2267
|
+
if (previousIsland.deltaCount == island.deltaCount) effectiveRatio /= 2;
|
|
2268
|
+
if (isSpeedingUp) effectiveRatio *= .65;
|
|
2269
|
+
let found = false;
|
|
2270
|
+
for (const existingIsland of islands) {
|
|
2271
|
+
if (!existingIsland.almostEquals(island, deltaDifferenceEpsilon)) continue;
|
|
2272
|
+
if (previousIsland.almostEquals(island, deltaDifferenceEpsilon)) ++existingIsland.occurrences;
|
|
2273
|
+
const power = _rian8337_osu_base.MathUtils.offsetLogistic(island.delta, 58.33, .24, 2.75);
|
|
2274
|
+
effectiveRatio *= Math.min(3 / existingIsland.occurrences, Math.pow(1 / existingIsland.occurrences, power));
|
|
2275
|
+
found = true;
|
|
2276
|
+
break;
|
|
2277
|
+
}
|
|
2278
|
+
if (!found && island.deltaCount > 0) islands.push(island);
|
|
2279
|
+
effectiveRatio *= 1 - prevObject.getDoubletapness(currentObject) * .75;
|
|
2280
|
+
if (island.deltaCount > 1) rhythmComplexitySum += Math.sqrt(effectiveRatio * startRatio) * currentHistoricalDecay;
|
|
2281
|
+
else rhythmComplexitySum += .7 * currentHistoricalDecay;
|
|
2282
|
+
startRatio = effectiveRatio;
|
|
2283
|
+
previousIsland = island;
|
|
2284
|
+
if (prevDelta + deltaDifferenceEpsilon < currentDelta) firstDeltaSwitch = false;
|
|
2285
|
+
island = new Island(currentDelta);
|
|
2286
|
+
}
|
|
2287
|
+
} else if (prevDelta > currentDelta + deltaDifferenceEpsilon) {
|
|
2288
|
+
firstDeltaSwitch = true;
|
|
2289
|
+
if (currentObject.object instanceof _rian8337_osu_base.Slider) effectiveRatio *= .6;
|
|
2290
|
+
if (prevObject.object instanceof _rian8337_osu_base.Slider) effectiveRatio *= .6;
|
|
2291
|
+
startRatio = effectiveRatio;
|
|
2292
|
+
island = new Island(currentDelta);
|
|
2293
|
+
}
|
|
2294
|
+
lastObject = prevObject;
|
|
2295
|
+
prevObject = currentObject;
|
|
2296
|
+
}
|
|
2297
|
+
rhythmComplexitySum *= _rian8337_osu_base.Interpolation.reverseLerp(island.deltaCount, 22, 3);
|
|
2298
|
+
return Math.sqrt(4 + rhythmComplexitySum * this.rhythmOverallMultiplier) / 2;
|
|
2299
|
+
}
|
|
2300
|
+
static getEffectiveRatio(deltaDifference) {
|
|
2301
|
+
const deltaDifferenceFraction = deltaDifference - Math.trunc(deltaDifference);
|
|
2302
|
+
return 1 + this.rhythmRatioMultiplier * Math.min(.5, _rian8337_osu_base.MathUtils.smoothstepBellCurve(deltaDifferenceFraction));
|
|
2303
|
+
}
|
|
2304
|
+
};
|
|
2305
|
+
// src/skills/droid/DroidRhythm.ts
|
|
2306
|
+
/**
|
|
2307
|
+
* Represents the skill required to properly follow a beatmap's rhythm.
|
|
2308
|
+
*/
|
|
2309
|
+
var DroidRhythm = class extends HarmonicSkill {
|
|
2310
|
+
harmonicScale = 25;
|
|
2311
|
+
decayExponent = .8;
|
|
2312
|
+
skillMultiplier = 7.5;
|
|
2313
|
+
strainDecayBase = .3;
|
|
2314
|
+
currentRhythmDifficulty = 0;
|
|
2315
|
+
currentRhythmMultiplier = 0;
|
|
2316
|
+
useSliderAccuracy;
|
|
2317
|
+
constructor(mods) {
|
|
2318
|
+
super(mods);
|
|
2319
|
+
this.useSliderAccuracy = mods.has(_rian8337_osu_base.ModScoreV2);
|
|
2320
|
+
}
|
|
2321
|
+
objectDifficultyOf(current) {
|
|
2322
|
+
const rhythmMultiplier = DroidRhythmEvaluator.evaluateDifficultyOf(current, this.useSliderAccuracy);
|
|
2323
|
+
this.currentRhythmDifficulty *= this.strainDecay(current.strainTime);
|
|
2324
|
+
this.currentRhythmDifficulty += (rhythmMultiplier - 1) * this.skillMultiplier;
|
|
2325
|
+
this.currentRhythmMultiplier = rhythmMultiplier;
|
|
2326
|
+
return this.currentRhythmDifficulty;
|
|
2327
|
+
}
|
|
2328
|
+
saveToHitObject(current) {
|
|
2329
|
+
current.rhythmDifficulty = this.currentRhythmDifficulty;
|
|
2330
|
+
current.rhythmMultiplier = this.currentRhythmMultiplier;
|
|
2331
|
+
}
|
|
2332
|
+
strainDecay(ms) {
|
|
2333
|
+
return Math.pow(this.strainDecayBase, ms / 1e3);
|
|
2334
|
+
}
|
|
2335
|
+
};
|
|
2336
|
+
// src/structures/DifficultyAttributes.ts
|
|
2337
|
+
/**
|
|
2338
|
+
* Holds data that can be used to calculate performance points.
|
|
2339
|
+
*/
|
|
2340
|
+
var DifficultyAttributes = class {
|
|
2341
|
+
mods = new _rian8337_osu_base.ModMap();
|
|
2342
|
+
starRating = 0;
|
|
2343
|
+
maxCombo = 0;
|
|
2344
|
+
aimDifficulty = 0;
|
|
2345
|
+
flashlightDifficulty = 0;
|
|
2346
|
+
readingDifficulty = 0;
|
|
2347
|
+
speedNoteCount = 0;
|
|
2348
|
+
sliderFactor = 1;
|
|
2349
|
+
clockRate = 1;
|
|
2350
|
+
overallDifficulty = 0;
|
|
2351
|
+
hitCircleCount = 0;
|
|
2352
|
+
sliderCount = 0;
|
|
2353
|
+
spinnerCount = 0;
|
|
2354
|
+
aimDifficultSliderCount = 0;
|
|
2355
|
+
aimDifficultStrainCount = 0;
|
|
2356
|
+
aimTopWeightedSliderFactor = 0;
|
|
2357
|
+
readingDifficultNoteCount = 0;
|
|
2358
|
+
constructor(cacheableAttributes) {
|
|
2359
|
+
if (!cacheableAttributes) return;
|
|
2360
|
+
this.mods = _rian8337_osu_base.ModUtil.deserializeMods(cacheableAttributes.mods);
|
|
2361
|
+
this.starRating = cacheableAttributes.starRating;
|
|
2362
|
+
this.maxCombo = cacheableAttributes.maxCombo;
|
|
2363
|
+
this.aimDifficulty = cacheableAttributes.aimDifficulty;
|
|
2364
|
+
this.flashlightDifficulty = cacheableAttributes.flashlightDifficulty;
|
|
2365
|
+
this.readingDifficulty = cacheableAttributes.readingDifficulty;
|
|
2366
|
+
this.speedNoteCount = cacheableAttributes.speedNoteCount;
|
|
2367
|
+
this.sliderFactor = cacheableAttributes.sliderFactor;
|
|
2368
|
+
this.clockRate = cacheableAttributes.clockRate;
|
|
2369
|
+
this.overallDifficulty = cacheableAttributes.overallDifficulty;
|
|
2370
|
+
this.hitCircleCount = cacheableAttributes.hitCircleCount;
|
|
2371
|
+
this.sliderCount = cacheableAttributes.sliderCount;
|
|
2372
|
+
this.spinnerCount = cacheableAttributes.spinnerCount;
|
|
2373
|
+
this.aimDifficultSliderCount = cacheableAttributes.aimDifficultSliderCount;
|
|
2374
|
+
this.aimDifficultStrainCount = cacheableAttributes.aimDifficultStrainCount;
|
|
2375
|
+
this.aimTopWeightedSliderFactor = cacheableAttributes.aimTopWeightedSliderFactor;
|
|
2376
|
+
this.readingDifficultNoteCount = cacheableAttributes.readingDifficultNoteCount;
|
|
2377
|
+
}
|
|
2378
|
+
/**
|
|
2379
|
+
* Converts this `DifficultyAttributes` instance to an attribute structure that can be cached.
|
|
2380
|
+
*
|
|
2381
|
+
* @returns The cacheable attributes.
|
|
2382
|
+
*/
|
|
2383
|
+
toCacheableAttributes() {
|
|
2384
|
+
return {
|
|
2385
|
+
...this,
|
|
2386
|
+
mods: this.mods.serializeMods()
|
|
2387
|
+
};
|
|
2388
|
+
}
|
|
2389
|
+
/**
|
|
2390
|
+
* Returns a string representation of the difficulty attributes.
|
|
2391
|
+
*/
|
|
2392
|
+
toString() {
|
|
2393
|
+
return `${this.starRating.toFixed(2)} stars`;
|
|
2394
|
+
}
|
|
2395
|
+
};
|
|
2396
|
+
// src/structures/DroidDifficultyAttributes.ts
|
|
2397
|
+
/**
|
|
2398
|
+
* Holds data that can be used to calculate osu!droid performance points.
|
|
2399
|
+
*/
|
|
2400
|
+
var DroidDifficultyAttributes = class extends DifficultyAttributes {
|
|
2401
|
+
tapDifficulty = 0;
|
|
2402
|
+
tapTopWeightedSliderFactor = 0;
|
|
2403
|
+
rhythmDifficulty = 0;
|
|
2404
|
+
tapDifficultStrainCount = 0;
|
|
2405
|
+
maximumScore = 0;
|
|
2406
|
+
constructor(cacheableAttributes) {
|
|
2407
|
+
super(cacheableAttributes);
|
|
2408
|
+
if (!cacheableAttributes) return;
|
|
2409
|
+
this.tapDifficulty = cacheableAttributes.tapDifficulty;
|
|
2410
|
+
this.rhythmDifficulty = cacheableAttributes.rhythmDifficulty;
|
|
2411
|
+
this.readingDifficulty = cacheableAttributes.readingDifficulty;
|
|
2412
|
+
this.tapDifficultStrainCount = cacheableAttributes.tapDifficultStrainCount;
|
|
2413
|
+
this.tapTopWeightedSliderFactor = cacheableAttributes.tapTopWeightedSliderFactor;
|
|
2414
|
+
this.maximumScore = cacheableAttributes.maximumScore;
|
|
2415
|
+
}
|
|
2416
|
+
toString() {
|
|
2417
|
+
return super.toString() + ` (${this.aimDifficulty.toFixed(2)} aim, ${this.tapDifficulty.toFixed(2)} tap, ${this.rhythmDifficulty.toFixed(2)} rhythm, ${this.flashlightDifficulty.toFixed(2)} flashlight, ${this.readingDifficulty.toFixed(2)} reading)`;
|
|
2418
|
+
}
|
|
2419
|
+
};
|
|
2420
|
+
// src/structures/ExtendedDroidDifficultyAttributes.ts
|
|
2421
|
+
/**
|
|
2422
|
+
* Holds data that can be used to calculate osu!droid performance points as well
|
|
2423
|
+
* as doing some analysis using the replay of a score.
|
|
2424
|
+
*/
|
|
2425
|
+
var ExtendedDroidDifficultyAttributes = class extends DroidDifficultyAttributes {
|
|
2426
|
+
mode = "live";
|
|
2427
|
+
possibleThreeFingeredSections = [];
|
|
2428
|
+
difficultSliders = [];
|
|
2429
|
+
constructor(cacheableAttributes) {
|
|
2430
|
+
super(cacheableAttributes);
|
|
2431
|
+
if (!cacheableAttributes) return;
|
|
2432
|
+
this.possibleThreeFingeredSections = cacheableAttributes.possibleThreeFingeredSections;
|
|
2433
|
+
this.difficultSliders = cacheableAttributes.difficultSliders;
|
|
2434
|
+
}
|
|
2435
|
+
};
|
|
2436
|
+
// src/utils/DroidScoreUtils.ts
|
|
2437
|
+
var DroidScoreUtils = class {
|
|
2438
|
+
/**
|
|
2439
|
+
* Calculates the maximum possible spinner bonus for a given beatmap.
|
|
2440
|
+
*
|
|
2441
|
+
* @param beatmap The `Beatmap` to calculate the maximum spinner bonus for.
|
|
2442
|
+
* @param playableBeatmap The `PlayableBeatmap` to calculate the maximum spinner bonus for.
|
|
2443
|
+
* Only base `PlayableBeatmap` members are used, so a progressive (as-of-a-point-in-time)
|
|
2444
|
+
* beatmap can be passed here too - see `DifficultyCalculator.calculateTimed`.
|
|
2445
|
+
* @returns The maximum spinner bonus.
|
|
2446
|
+
*/
|
|
2447
|
+
static calculateMaximumSpinnerBonus(beatmap, playableBeatmap) {
|
|
2448
|
+
const { hitObjects } = playableBeatmap;
|
|
2449
|
+
if (hitObjects.spinners === 0) return 0;
|
|
2450
|
+
const scoreMultiplier = new _rian8337_osu_base.DroidScoreMultiplierCalculator(beatmap.difficulty).calculateFor(playableBeatmap.mods.values());
|
|
2451
|
+
let bonus = 0;
|
|
2452
|
+
const maximumRotationsPerSecond = 30;
|
|
2453
|
+
for (const obj of hitObjects.objects) {
|
|
2454
|
+
if (!(obj instanceof _rian8337_osu_base.Spinner)) continue;
|
|
2455
|
+
const secondsDuration = obj.duration / 1e3;
|
|
2456
|
+
const spinsRequiredBeforeBonus = obj.spinsRequired;
|
|
2457
|
+
const totalPossibleSpins = secondsDuration * maximumRotationsPerSecond;
|
|
2458
|
+
const maximumPossibleBonusSpins = Math.max(0, Math.floor(totalPossibleSpins) - Math.ceil(spinsRequiredBeforeBonus) + 1);
|
|
2459
|
+
bonus += maximumPossibleBonusSpins * 1e3;
|
|
2460
|
+
}
|
|
2461
|
+
return Math.floor(Math.fround(bonus * scoreMultiplier));
|
|
2462
|
+
}
|
|
2463
|
+
};
|
|
2464
|
+
// src/DroidDifficultyCalculator.ts
|
|
2465
|
+
/**
|
|
2466
|
+
* A difficulty calculator for osu!droid gamemode.
|
|
2467
|
+
*/
|
|
2468
|
+
var DroidDifficultyCalculator = class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
2469
|
+
constructor() {
|
|
2470
|
+
super();
|
|
2471
|
+
this.difficultyAdjustmentMods.push(_rian8337_osu_base.ModPrecise, _rian8337_osu_base.ModScoreV2, _rian8337_osu_base.ModReplayV6, _rian8337_osu_base.ModTraceable);
|
|
2472
|
+
}
|
|
2473
|
+
retainDifficultyAdjustmentMods(mods) {
|
|
2474
|
+
return mods.filter((mod) => mod.isApplicableToDroid() && mod.isDroidRelevant && this.difficultyAdjustmentMods.some((m) => mod instanceof m));
|
|
2475
|
+
}
|
|
2476
|
+
createDifficultyAttributes(beatmap, playableBeatmap, skills, objects) {
|
|
2477
|
+
const attributes = new ExtendedDroidDifficultyAttributes();
|
|
2478
|
+
attributes.mods = playableBeatmap.mods;
|
|
2479
|
+
attributes.maxCombo = playableBeatmap.maxCombo;
|
|
2480
|
+
attributes.clockRate = playableBeatmap.speedMultiplier;
|
|
2481
|
+
attributes.hitCircleCount = playableBeatmap.hitObjects.circles;
|
|
2482
|
+
attributes.sliderCount = playableBeatmap.hitObjects.sliders;
|
|
2483
|
+
attributes.spinnerCount = playableBeatmap.hitObjects.spinners;
|
|
2484
|
+
attributes.overallDifficulty = playableBeatmap.difficulty.od;
|
|
2485
|
+
attributes.maximumScore = beatmap.maxDroidScore(playableBeatmap.mods) + DroidScoreUtils.calculateMaximumSpinnerBonus(beatmap, playableBeatmap);
|
|
2486
|
+
this.populateAimAttributes(attributes, skills, objects);
|
|
2487
|
+
this.populateTapAttributes(attributes, skills, objects);
|
|
2488
|
+
this.populateRhythmAttributes(attributes, skills);
|
|
2489
|
+
this.populateFlashlightAttributes(attributes, skills);
|
|
2490
|
+
this.populateReadingAttributes(attributes, skills);
|
|
2491
|
+
const baseAimPerformance = DroidAim.difficultyToPerformance(attributes.aimDifficulty);
|
|
2492
|
+
const baseTapPerformance = DroidTap.difficultyToPerformance(attributes.tapDifficulty);
|
|
2493
|
+
const baseFlashlightPerformance = DroidFlashlight.difficultyToPerformance(attributes.flashlightDifficulty);
|
|
2494
|
+
const baseReadingPerformance = DroidReading.difficultyToPerformance(attributes.readingDifficulty);
|
|
2495
|
+
const baseCognitionPerformance = DroidDifficultyCalculator.sumCognitionDifficulty(baseReadingPerformance, baseFlashlightPerformance);
|
|
2496
|
+
const basePerformance = _rian8337_osu_base.MathUtils.norm(DroidPerformanceCalculator.normExponent, baseAimPerformance, baseTapPerformance, baseCognitionPerformance);
|
|
2497
|
+
attributes.starRating = Math.cbrt(basePerformance * DroidPerformanceCalculator.finalMultiplier);
|
|
2498
|
+
return attributes;
|
|
2499
|
+
}
|
|
2500
|
+
createPlayableBeatmap(beatmap, mods) {
|
|
2501
|
+
return beatmap.createDroidPlayableBeatmap(mods);
|
|
2502
|
+
}
|
|
2503
|
+
createDifficultyHitObjects(beatmap) {
|
|
2504
|
+
const clockRate = beatmap.speedMultiplier;
|
|
2505
|
+
const difficultyObjects = [];
|
|
2506
|
+
const { objects } = beatmap.hitObjects;
|
|
2507
|
+
for (let i = 0; i < objects.length; ++i) {
|
|
2508
|
+
const difficultyObject = new DroidDifficultyHitObject(objects[i], objects[i - 1] ?? null, difficultyObjects, clockRate, i - 1);
|
|
2509
|
+
difficultyObject.computeProperties(clockRate);
|
|
2510
|
+
difficultyObjects.push(difficultyObject);
|
|
2511
|
+
}
|
|
2512
|
+
return difficultyObjects;
|
|
2513
|
+
}
|
|
2514
|
+
createSkills(beatmap) {
|
|
2515
|
+
const { mods } = beatmap;
|
|
2516
|
+
const skills = [];
|
|
2517
|
+
if (!mods.has(_rian8337_osu_base.ModAutopilot)) {
|
|
2518
|
+
skills.push(new DroidAim(mods, true));
|
|
2519
|
+
skills.push(new DroidAim(mods, false));
|
|
2520
|
+
}
|
|
2521
|
+
if (!mods.has(_rian8337_osu_base.ModRelax)) {
|
|
2522
|
+
skills.push(new DroidRhythm(mods));
|
|
2523
|
+
skills.push(new DroidTap(mods, true));
|
|
2524
|
+
skills.push(new DroidTap(mods, false));
|
|
2525
|
+
}
|
|
2526
|
+
skills.push(new DroidReading(mods, beatmap.speedMultiplier, beatmap.hitObjects.objects));
|
|
2527
|
+
if (mods.has(_rian8337_osu_base.ModFlashlight)) skills.push(new DroidFlashlight(mods, beatmap.hitObjects.objects.length));
|
|
2528
|
+
return skills;
|
|
2529
|
+
}
|
|
2530
|
+
createStrainPeakSkills(beatmap) {
|
|
2531
|
+
const { mods } = beatmap;
|
|
2532
|
+
return [
|
|
2533
|
+
new DroidAim(mods, true),
|
|
2534
|
+
new DroidAim(mods, false),
|
|
2535
|
+
new DroidTap(mods, true),
|
|
2536
|
+
new DroidFlashlight(mods, beatmap.hitObjects.objects.length)
|
|
2537
|
+
];
|
|
2538
|
+
}
|
|
2539
|
+
populateAimAttributes(attributes, skills, objects) {
|
|
2540
|
+
const aim = skills.find((s) => s instanceof DroidAim && s.withSliders);
|
|
2541
|
+
const aimNoSlider = skills.find((s) => s instanceof DroidAim && !s.withSliders);
|
|
2542
|
+
if (!aim || !aimNoSlider || attributes.mods.has(_rian8337_osu_base.ModAutopilot)) {
|
|
2543
|
+
attributes.aimDifficulty = 0;
|
|
2544
|
+
attributes.aimDifficultSliderCount = 0;
|
|
2545
|
+
attributes.aimDifficultStrainCount = 0;
|
|
2546
|
+
return;
|
|
2547
|
+
}
|
|
2548
|
+
const aimDifficultyValue = aim.difficultyValue();
|
|
2549
|
+
attributes.aimDifficulty = this.calculateAimDifficultyRating(aimDifficultyValue);
|
|
2550
|
+
attributes.aimDifficultSliderCount = aim.countDifficultSliders();
|
|
2551
|
+
attributes.aimDifficultStrainCount = aim.countTopWeightedStrains(aimDifficultyValue);
|
|
2552
|
+
const aimNoSliderDifficultyValue = aimNoSlider.difficultyValue();
|
|
2553
|
+
const aimNoSliderTopWeightedSliderCount = aimNoSlider.countTopWeightedSliders(aimNoSliderDifficultyValue);
|
|
2554
|
+
const aimNoSliderDifficultStrainCount = aimNoSlider.countTopWeightedStrains(aimNoSliderDifficultyValue);
|
|
2555
|
+
attributes.aimTopWeightedSliderFactor = aimNoSliderTopWeightedSliderCount / Math.max(1, aimNoSliderDifficultStrainCount - aimNoSliderTopWeightedSliderCount);
|
|
2556
|
+
const topDifficultSliders = [];
|
|
2557
|
+
for (let i = 0; i < objects.length; ++i) {
|
|
2558
|
+
const object = objects[i];
|
|
2559
|
+
const velocity = object.travelDistance / object.travelTime;
|
|
2560
|
+
if (velocity > 0) topDifficultSliders.push({
|
|
2561
|
+
index: i,
|
|
2562
|
+
velocity
|
|
2563
|
+
});
|
|
2564
|
+
}
|
|
2565
|
+
const velocitySum = topDifficultSliders.reduce((a, v) => a + v.velocity, 0);
|
|
2566
|
+
for (const slider of topDifficultSliders) if (slider.velocity / velocitySum > .02) attributes.difficultSliders.push({
|
|
2567
|
+
index: slider.index,
|
|
2568
|
+
difficultyRating: slider.velocity / velocitySum
|
|
2569
|
+
});
|
|
2570
|
+
attributes.difficultSliders.sort((a, b) => b.difficultyRating - a.difficultyRating);
|
|
2571
|
+
while (attributes.difficultSliders.length > Math.ceil(.15 * attributes.sliderCount)) attributes.difficultSliders.pop();
|
|
2572
|
+
if (attributes.aimDifficulty > 0) attributes.sliderFactor = this.calculateAimDifficultyRating(aimNoSliderDifficultyValue) / this.calculateAimDifficultyRating(aimDifficultyValue);
|
|
2573
|
+
else attributes.sliderFactor = 1;
|
|
2574
|
+
}
|
|
2575
|
+
populateTapAttributes(attributes, skills, objects) {
|
|
2576
|
+
const tap = skills.find((s) => s instanceof DroidTap && s.considerCheesability);
|
|
2577
|
+
if (!tap || attributes.mods.has(_rian8337_osu_base.ModRelax)) {
|
|
2578
|
+
attributes.tapDifficulty = 0;
|
|
2579
|
+
attributes.tapDifficultStrainCount = 0;
|
|
2580
|
+
attributes.speedNoteCount = 0;
|
|
2581
|
+
return;
|
|
2582
|
+
}
|
|
2583
|
+
const tapDifficultyValue = tap.difficultyValue();
|
|
2584
|
+
attributes.tapDifficulty = this.calculateDifficultyRating(tapDifficultyValue);
|
|
2585
|
+
attributes.tapDifficultStrainCount = tap.countTopWeightedObjectDifficulties(tapDifficultyValue);
|
|
2586
|
+
attributes.speedNoteCount = tap.relevantNoteCount();
|
|
2587
|
+
const tapTopWeightedSliderCount = tap.countTopWeightedSliders(tapDifficultyValue);
|
|
2588
|
+
attributes.tapTopWeightedSliderFactor = tapTopWeightedSliderCount / Math.max(1, attributes.tapDifficultStrainCount - tapTopWeightedSliderCount);
|
|
2589
|
+
const threeFingerStrainThreshold = 175;
|
|
2590
|
+
const minSectionObjectCount = 5;
|
|
2591
|
+
let inSpeedSection = false;
|
|
2592
|
+
let firstSpeedObjectIndex = 0;
|
|
2593
|
+
for (let i = 2; i < objects.length; ++i) {
|
|
2594
|
+
const current = objects[i];
|
|
2595
|
+
const prev = objects[i - 1];
|
|
2596
|
+
if (!inSpeedSection && current.originalTapDifficulty >= threeFingerStrainThreshold) {
|
|
2597
|
+
inSpeedSection = true;
|
|
2598
|
+
firstSpeedObjectIndex = i;
|
|
2599
|
+
continue;
|
|
2600
|
+
}
|
|
2601
|
+
const currentDelta = current.deltaTime;
|
|
2602
|
+
const prevDelta = prev.deltaTime;
|
|
2603
|
+
const deltaRatio = Math.min(prevDelta, currentDelta) / Math.max(prevDelta, currentDelta);
|
|
2604
|
+
if (inSpeedSection && (current.originalTapDifficulty < threeFingerStrainThreshold || prevDelta < currentDelta && deltaRatio <= .5 || i === objects.length - 1)) {
|
|
2605
|
+
const lastSpeedObjectIndex = i - (i === objects.length - 1 ? 0 : 1);
|
|
2606
|
+
inSpeedSection = false;
|
|
2607
|
+
if (i - firstSpeedObjectIndex < minSectionObjectCount) continue;
|
|
2608
|
+
attributes.possibleThreeFingeredSections.push({
|
|
2609
|
+
firstObjectIndex: firstSpeedObjectIndex,
|
|
2610
|
+
lastObjectIndex: lastSpeedObjectIndex,
|
|
2611
|
+
sumStrain: Math.pow(objects.slice(firstSpeedObjectIndex, lastSpeedObjectIndex + 1).reduce((a, v) => a + v.originalTapDifficulty / threeFingerStrainThreshold, 0), .75)
|
|
2612
|
+
});
|
|
2613
|
+
}
|
|
2614
|
+
}
|
|
2615
|
+
}
|
|
2616
|
+
populateRhythmAttributes(attributes, skills) {
|
|
2617
|
+
const rhythm = skills.find((s) => s instanceof DroidRhythm);
|
|
2618
|
+
attributes.rhythmDifficulty = this.calculateDifficultyRating(rhythm?.difficultyValue() ?? 0);
|
|
2619
|
+
}
|
|
2620
|
+
populateFlashlightAttributes(attributes, skills) {
|
|
2621
|
+
const flashlight = skills.find((s) => s instanceof DroidFlashlight);
|
|
2622
|
+
attributes.flashlightDifficulty = this.calculateDifficultyRating(flashlight?.difficultyValue() ?? 0);
|
|
2623
|
+
}
|
|
2624
|
+
populateReadingAttributes(attributes, skills) {
|
|
2625
|
+
const reading = skills.find((s) => s instanceof DroidReading);
|
|
2626
|
+
if (!reading) {
|
|
2627
|
+
attributes.readingDifficulty = 0;
|
|
2628
|
+
attributes.readingDifficultNoteCount = 0;
|
|
2629
|
+
return;
|
|
2630
|
+
}
|
|
2631
|
+
const readingDifficultyValue = reading.difficultyValue();
|
|
2632
|
+
attributes.readingDifficulty = this.calculateDifficultyRating(readingDifficultyValue);
|
|
2633
|
+
attributes.readingDifficultNoteCount = reading.countTopWeightedObjectDifficulties(readingDifficultyValue);
|
|
2634
|
+
}
|
|
2635
|
+
calculateAimDifficultyRating(difficultyValue) {
|
|
2636
|
+
return Math.pow(difficultyValue, .63) * .02275;
|
|
2637
|
+
}
|
|
2638
|
+
calculateDifficultyRating(difficultyValue) {
|
|
2639
|
+
return Math.sqrt(difficultyValue) * .0675;
|
|
2640
|
+
}
|
|
2641
|
+
static sumCognitionDifficulty(reading, flashlight) {
|
|
2642
|
+
if (reading <= 0) return flashlight;
|
|
2643
|
+
if (flashlight <= 0) return reading;
|
|
2644
|
+
return _rian8337_osu_base.MathUtils.norm(DroidPerformanceCalculator.normExponent, reading, flashlight * _rian8337_osu_base.MathUtils.clamp(flashlight / reading, .25, 1));
|
|
2645
|
+
}
|
|
2646
|
+
};
|
|
2647
|
+
// src/evaluators/osu/OsuAgilityEvaluator.ts
|
|
2648
|
+
/**
|
|
2649
|
+
* An evaluator for calculating osu!standard agility aim difficulty.
|
|
2650
|
+
*/
|
|
2651
|
+
var OsuAgilityEvaluator = class {
|
|
2652
|
+
/**
|
|
2653
|
+
* Evaluates the difficulty of fast aiming the current object.
|
|
2654
|
+
*
|
|
2655
|
+
* @param current The current object.
|
|
2656
|
+
*/
|
|
2657
|
+
static evaluateDifficultyOf(current) {
|
|
2658
|
+
if (current.object instanceof _rian8337_osu_base.Spinner) return 0;
|
|
2659
|
+
const distance = (current.previous(0)?.lazyTravelDistance ?? 0) + current.lazyJumpDistance;
|
|
2660
|
+
const distanceCap = current.normalizedDiameter * 1.2;
|
|
2661
|
+
let strain = Math.min(distance, distanceCap) / distanceCap * 1e3 / current.strainTime;
|
|
2662
|
+
strain *= Math.pow(current.smallCircleBonus, 1.5);
|
|
2663
|
+
strain *= this.highBpmBonus(current.strainTime);
|
|
2664
|
+
return strain;
|
|
2665
|
+
}
|
|
2666
|
+
static highBpmBonus(ms) {
|
|
2667
|
+
return 1 / (1 - Math.pow(.2, ms / 1e3));
|
|
2668
|
+
}
|
|
2669
|
+
};
|
|
2670
|
+
// src/evaluators/osu/OsuFlashlightEvaluator.ts
|
|
2671
|
+
/**
|
|
2672
|
+
* An evaluator for calculating osu!standard Flashlight skill.
|
|
2673
|
+
*/
|
|
2674
|
+
var OsuFlashlightEvaluator = class {
|
|
2675
|
+
static maxOpacityBonus = .4;
|
|
2676
|
+
static hiddenBonus = .2;
|
|
2677
|
+
static minVelocity = .5;
|
|
2678
|
+
static sliderMultiplier = 1.3;
|
|
2679
|
+
static minAngleMultiplier = .2;
|
|
2680
|
+
/**
|
|
2681
|
+
* Evaluates the difficulty of memorizing and hitting the current object, based on:
|
|
2682
|
+
*
|
|
2683
|
+
* - distance between a number of previous objects and the current object,
|
|
2684
|
+
* - the visual opacity of the current object,
|
|
2685
|
+
* - the angle made by the current object,
|
|
2686
|
+
* - length and speed of the current object (for sliders),
|
|
2687
|
+
* - and whether Hidden mod is enabled.
|
|
2688
|
+
*
|
|
2689
|
+
* @param current The current object.
|
|
2690
|
+
* @param mods The mods used.
|
|
2691
|
+
*/
|
|
2692
|
+
static evaluateDifficultyOf(current, mods) {
|
|
2693
|
+
if (current.object instanceof _rian8337_osu_base.Spinner) return 0;
|
|
2694
|
+
const scalingFactor = 52 / current.object.radius;
|
|
2695
|
+
let smallDistNerf = 1;
|
|
2696
|
+
let cumulativeStrainTime = 0;
|
|
2697
|
+
let result = 0;
|
|
2698
|
+
let last = current;
|
|
2699
|
+
let angleRepeatCount = 0;
|
|
2700
|
+
const opacityMods = mods.get(_rian8337_osu_base.ModHidden)?.onlyFadeApproachCircles.value ? void 0 : mods;
|
|
2701
|
+
for (let i = 0; i < Math.min(current.index, 10); ++i) {
|
|
2702
|
+
const currentObject = current.previous(i);
|
|
2703
|
+
cumulativeStrainTime += last.strainTime;
|
|
2704
|
+
if (!(currentObject.object instanceof _rian8337_osu_base.Spinner)) {
|
|
2705
|
+
const jumpDistance = current.object.stackedPosition.subtract(currentObject.object.stackedEndPosition).length;
|
|
2706
|
+
if (i === 0) smallDistNerf = Math.min(1, jumpDistance / 75);
|
|
2707
|
+
const stackNerf = Math.min(1, currentObject.lazyJumpDistance / scalingFactor / 25);
|
|
2708
|
+
const opacityBonus = 1 + this.maxOpacityBonus * (1 - current.opacityAt(currentObject.object.startTime, opacityMods));
|
|
2709
|
+
result += stackNerf * opacityBonus * scalingFactor * jumpDistance / cumulativeStrainTime;
|
|
2710
|
+
if (currentObject.angle !== null && current.angle !== null) {
|
|
2711
|
+
if (Math.abs(currentObject.angle - current.angle) < .02) angleRepeatCount += Math.max(0, 1 - .1 * i);
|
|
2712
|
+
}
|
|
2713
|
+
}
|
|
2714
|
+
last = currentObject;
|
|
2715
|
+
}
|
|
2716
|
+
result = Math.pow(smallDistNerf * result, 2);
|
|
2717
|
+
if (mods.has(_rian8337_osu_base.ModHidden)) result *= 1 + this.hiddenBonus;
|
|
2718
|
+
result *= this.minAngleMultiplier + (1 - this.minAngleMultiplier) / (angleRepeatCount + 1);
|
|
2719
|
+
let sliderBonus = 0;
|
|
2720
|
+
if (current.object instanceof _rian8337_osu_base.Slider) {
|
|
2721
|
+
const pixelTravelDistance = current.lazyTravelDistance / scalingFactor;
|
|
2722
|
+
sliderBonus = Math.pow(Math.max(0, pixelTravelDistance / current.travelTime - this.minVelocity), .5);
|
|
2723
|
+
sliderBonus *= pixelTravelDistance;
|
|
2724
|
+
if (current.object.repeatCount > 0) sliderBonus /= current.object.repeatCount + 1;
|
|
2725
|
+
}
|
|
2726
|
+
result += sliderBonus * this.sliderMultiplier;
|
|
2727
|
+
return result;
|
|
2728
|
+
}
|
|
2729
|
+
};
|
|
2730
|
+
// src/evaluators/osu/OsuSnapAimEvaluator.ts
|
|
2731
|
+
/**
|
|
2732
|
+
* An evaluator for calculating osu!standard snap aim difficulty.
|
|
2733
|
+
*/
|
|
2734
|
+
var OsuSnapAimEvaluator = class {
|
|
2735
|
+
static wideAngleMultiplier = 9.67;
|
|
2736
|
+
static acuteAngleMultiplier = 2.41;
|
|
2737
|
+
static sliderMultiplier = 1.5;
|
|
2738
|
+
static velocityChangeMultiplier = .9;
|
|
2739
|
+
static wiggleMultiplier = 1.02;
|
|
2740
|
+
static angleRepetitionNoteLimit = 6;
|
|
2741
|
+
static maximumRepetitionNerf = .15;
|
|
2742
|
+
static maximumVectorInfluence = .5;
|
|
2743
|
+
/**
|
|
2744
|
+
* Evaluates the difficulty of aiming the current object, based on:
|
|
2745
|
+
*
|
|
2746
|
+
* - cursor velocity to the current object,
|
|
2747
|
+
* - angle difficulty,
|
|
2748
|
+
* - sharp velocity increases,
|
|
2749
|
+
* - and slider difficulty.
|
|
2750
|
+
*
|
|
2751
|
+
* @param current The current object.
|
|
2752
|
+
* @param withSliders Whether to take slider difficulty into account.
|
|
2753
|
+
*/
|
|
2754
|
+
static evaluateDifficultyOf(current, withSliders) {
|
|
2755
|
+
const last = current.previous(0);
|
|
2756
|
+
if (current.object instanceof _rian8337_osu_base.Spinner || current.index <= 1 || last.object instanceof _rian8337_osu_base.Spinner) return 0;
|
|
2757
|
+
const last2 = current.previous(2);
|
|
2758
|
+
const radius = current.normalizedRadius;
|
|
2759
|
+
const diameter = current.normalizedDiameter;
|
|
2760
|
+
const currentDistance = withSliders ? current.lazyJumpDistance : current.jumpDistance;
|
|
2761
|
+
let currentVelocity = currentDistance / current.strainTime;
|
|
2762
|
+
if (last.object instanceof _rian8337_osu_base.Slider && withSliders) {
|
|
2763
|
+
const sliderDistance = last.lazyTravelDistance + current.lazyJumpDistance;
|
|
2764
|
+
currentVelocity = Math.max(currentVelocity, sliderDistance / current.strainTime);
|
|
2765
|
+
}
|
|
2766
|
+
const prevDistance = withSliders ? last.lazyJumpDistance : last.jumpDistance;
|
|
2767
|
+
const prevVelocity = prevDistance / last.strainTime;
|
|
2768
|
+
let strain = currentVelocity;
|
|
2769
|
+
strain *= this.calculateVectorAngleRepetition(current, last);
|
|
2770
|
+
if (current.angle !== null && last.angle !== null) {
|
|
2771
|
+
const currentAngle = current.angle;
|
|
2772
|
+
const lastAngle = last.angle;
|
|
2773
|
+
const velocityInfluence = Math.min(currentVelocity, prevVelocity);
|
|
2774
|
+
let acuteAngleBonus = 0;
|
|
2775
|
+
if (Math.max(current.strainTime, last.strainTime) < 1.25 * Math.min(current.strainTime, last.strainTime)) {
|
|
2776
|
+
acuteAngleBonus = this.calculateAcuteAngleAcuteness(currentAngle);
|
|
2777
|
+
acuteAngleBonus *= .08 + .92 * (1 - Math.min(acuteAngleBonus, Math.pow(this.calculateAcuteAngleAcuteness(lastAngle), 3)));
|
|
2778
|
+
acuteAngleBonus *= velocityInfluence * _rian8337_osu_base.MathUtils.smootherstep(_rian8337_osu_base.MathUtils.millisecondsToBPM(current.strainTime, 2), 300, 400) * _rian8337_osu_base.MathUtils.smootherstep(currentDistance, 0, diameter * 2);
|
|
2779
|
+
}
|
|
2780
|
+
let wideAngleBonus = this.calculateWideAngleAcuteness(currentAngle);
|
|
2781
|
+
wideAngleBonus *= .25 + .75 * (1 - Math.min(wideAngleBonus, Math.pow(this.calculateWideAngleAcuteness(lastAngle), 3)));
|
|
2782
|
+
const wideAngleTimeScale = 1.45;
|
|
2783
|
+
let wideAngleCurrentVelocity = currentDistance / Math.pow(current.strainTime, wideAngleTimeScale);
|
|
2784
|
+
const wideAnglePrevVelocity = prevDistance / Math.pow(last.strainTime, wideAngleTimeScale);
|
|
2785
|
+
if (last.object instanceof _rian8337_osu_base.Slider && withSliders) {
|
|
2786
|
+
const sliderDistance = last.lazyTravelDistance + current.lazyJumpDistance;
|
|
2787
|
+
wideAngleCurrentVelocity = Math.max(wideAngleCurrentVelocity, sliderDistance / Math.pow(current.strainTime, wideAngleTimeScale));
|
|
2788
|
+
}
|
|
2789
|
+
wideAngleBonus *= Math.min(wideAngleCurrentVelocity, wideAnglePrevVelocity);
|
|
2790
|
+
if (last2 !== null) {
|
|
2791
|
+
const distance = last2.object.stackedPosition.getDistance(last.object.stackedPosition);
|
|
2792
|
+
if (distance < 1) wideAngleBonus *= 1 - .55 * (1 - distance);
|
|
2793
|
+
}
|
|
2794
|
+
strain += Math.max(acuteAngleBonus * this.acuteAngleMultiplier, wideAngleBonus * this.wideAngleMultiplier);
|
|
2795
|
+
strain += velocityInfluence * _rian8337_osu_base.MathUtils.smootherstep(currentDistance, radius, diameter) * Math.pow(_rian8337_osu_base.MathUtils.reverseLerp(currentDistance, diameter * 3, diameter), 1.8) * _rian8337_osu_base.MathUtils.smootherstep(currentAngle, _rian8337_osu_base.MathUtils.degreesToRadians(110), _rian8337_osu_base.MathUtils.degreesToRadians(60)) * _rian8337_osu_base.MathUtils.smootherstep(prevDistance, radius, diameter) * Math.pow(_rian8337_osu_base.MathUtils.reverseLerp(prevDistance, diameter * 3, diameter), 1.8) * _rian8337_osu_base.MathUtils.smootherstep(lastAngle, _rian8337_osu_base.MathUtils.degreesToRadians(110), _rian8337_osu_base.MathUtils.degreesToRadians(60)) * this.wiggleMultiplier;
|
|
2796
|
+
}
|
|
2797
|
+
if (Math.max(prevVelocity, currentVelocity)) {
|
|
2798
|
+
if (withSliders) currentVelocity = currentDistance / current.strainTime;
|
|
2799
|
+
const distanceRatio = _rian8337_osu_base.MathUtils.smoothstep(Math.abs(prevVelocity - currentVelocity) / Math.max(prevVelocity, currentVelocity), 0, 1);
|
|
2800
|
+
let velocityChangeBonus = Math.min(diameter * 1.25 / Math.min(current.strainTime, last.strainTime), Math.abs(prevVelocity - currentVelocity)) * distanceRatio;
|
|
2801
|
+
velocityChangeBonus *= Math.pow(Math.min(current.strainTime, last.strainTime) / Math.max(current.strainTime, last.strainTime), 2);
|
|
2802
|
+
strain += velocityChangeBonus * this.velocityChangeMultiplier;
|
|
2803
|
+
}
|
|
2804
|
+
if (current.object instanceof _rian8337_osu_base.Slider && withSliders) {
|
|
2805
|
+
const sliderBonus = current.travelDistance / current.travelTime;
|
|
2806
|
+
strain += (sliderBonus < 1 ? sliderBonus : Math.pow(sliderBonus, .75)) * this.sliderMultiplier;
|
|
2807
|
+
}
|
|
2808
|
+
strain *= current.smallCircleBonus;
|
|
2809
|
+
strain *= this.highBpmBonus(current.strainTime);
|
|
2810
|
+
return strain;
|
|
2811
|
+
}
|
|
2812
|
+
static calculateWideAngleAcuteness(angle) {
|
|
2813
|
+
return _rian8337_osu_base.MathUtils.smoothstep(angle, _rian8337_osu_base.MathUtils.degreesToRadians(40), _rian8337_osu_base.MathUtils.degreesToRadians(140));
|
|
2814
|
+
}
|
|
2815
|
+
static calculateAcuteAngleAcuteness(angle) {
|
|
2816
|
+
return _rian8337_osu_base.MathUtils.smoothstep(angle, _rian8337_osu_base.MathUtils.degreesToRadians(140), _rian8337_osu_base.MathUtils.degreesToRadians(40));
|
|
2817
|
+
}
|
|
2818
|
+
static highBpmBonus(ms) {
|
|
2819
|
+
return 1 / (1 - Math.pow(.03, Math.pow(ms / 1e3, .65)));
|
|
2820
|
+
}
|
|
2821
|
+
static calculateVectorAngleRepetition(current, prev) {
|
|
2822
|
+
if (current.angle === null || prev.angle === null) return 1;
|
|
2823
|
+
let constantAngleCount = 0;
|
|
2824
|
+
for (let i = 0; i < this.angleRepetitionNoteLimit; ++i) {
|
|
2825
|
+
const loopObj = current.previous(i);
|
|
2826
|
+
if (!loopObj) break;
|
|
2827
|
+
if (Math.max(current.strainTime, loopObj.strainTime) > 1.1 * Math.min(current.strainTime, loopObj.strainTime)) break;
|
|
2828
|
+
if (loopObj.normalizedVectorAngle !== null && current.normalizedVectorAngle !== null) {
|
|
2829
|
+
const angleDifference = Math.abs(current.normalizedVectorAngle - loopObj.normalizedVectorAngle);
|
|
2830
|
+
constantAngleCount += Math.cos(8 * Math.min(_rian8337_osu_base.MathUtils.degreesToRadians(11.25), angleDifference));
|
|
2831
|
+
}
|
|
2832
|
+
}
|
|
2833
|
+
const vectorRepetition = Math.pow(Math.min(.5 / constantAngleCount, 1), 2);
|
|
2834
|
+
const stackFactor = _rian8337_osu_base.MathUtils.smootherstep(current.lazyJumpDistance, 0, current.normalizedDiameter);
|
|
2835
|
+
const angleDifferenceAdjusted = Math.cos(2 * Math.min(_rian8337_osu_base.MathUtils.degreesToRadians(45), Math.abs(current.angle - prev.angle) * stackFactor));
|
|
2836
|
+
const baseNerf = 1 - this.maximumRepetitionNerf * this.calculateAcuteAngleAcuteness(prev.angle) * angleDifferenceAdjusted;
|
|
2837
|
+
return Math.pow(baseNerf + (1 - baseNerf) * vectorRepetition * this.maximumVectorInfluence * stackFactor, 2);
|
|
2838
|
+
}
|
|
2839
|
+
};
|
|
2840
|
+
// src/evaluators/osu/OsuFlowAimEvaluator.ts
|
|
2841
|
+
/**
|
|
2842
|
+
* An evaluator for calculating osu!standard flow aim difficulty.
|
|
2843
|
+
*/
|
|
2844
|
+
var OsuFlowAimEvaluator = class {
|
|
2845
|
+
static velocityChangeMultiplier = .52;
|
|
2846
|
+
static evaluateDifficultyOf(current, withSliders) {
|
|
2847
|
+
if (current.object instanceof _rian8337_osu_base.Spinner || current.index <= 1 || current.previous(0)?.object instanceof _rian8337_osu_base.Spinner) return 0;
|
|
2848
|
+
const last = current.previous(0);
|
|
2849
|
+
const lastLast = current.previous(1);
|
|
2850
|
+
const currentDistance = withSliders ? current.lazyJumpDistance : current.jumpDistance;
|
|
2851
|
+
const prevDistance = withSliders ? last.lazyJumpDistance : last.jumpDistance;
|
|
2852
|
+
let currentVelocity = currentDistance / current.strainTime;
|
|
2853
|
+
if (last.object instanceof _rian8337_osu_base.Slider && withSliders) {
|
|
2854
|
+
const sliderDistance = last.lazyTravelDistance + current.lazyJumpDistance;
|
|
2855
|
+
currentVelocity = Math.max(currentVelocity, sliderDistance / current.strainTime);
|
|
2856
|
+
}
|
|
2857
|
+
const prevVelocity = prevDistance / last.strainTime;
|
|
2858
|
+
let flowDifficulty = currentVelocity;
|
|
2859
|
+
flowDifficulty *= Math.sqrt(current.smallCircleBonus);
|
|
2860
|
+
flowDifficulty *= 1 + Math.min(.25, Math.pow((Math.max(current.strainTime, last.strainTime) - Math.min(current.strainTime, last.strainTime)) / 50, 4));
|
|
2861
|
+
if (current.angle !== null && last.angle !== null) {
|
|
2862
|
+
const angleDifference = Math.abs(current.angle - last.angle);
|
|
2863
|
+
const angularVelocity = Math.sin(angleDifference / 2) * 180 / (current.strainTime * .1);
|
|
2864
|
+
flowDifficulty *= .8 + Math.sqrt(angularVelocity / 270);
|
|
2865
|
+
}
|
|
2866
|
+
let overlappedNotesWeight = 1;
|
|
2867
|
+
if (current.index > 2) {
|
|
2868
|
+
const o1 = this.calculateOverlapFactor(current, last);
|
|
2869
|
+
const o2 = this.calculateOverlapFactor(current, lastLast);
|
|
2870
|
+
const o3 = this.calculateOverlapFactor(last, lastLast);
|
|
2871
|
+
overlappedNotesWeight = 1 - o1 * o2 * o3;
|
|
2872
|
+
}
|
|
2873
|
+
if (current.angle !== null) flowDifficulty += currentVelocity * OsuSnapAimEvaluator.calculateAcuteAngleAcuteness(current.angle) * overlappedNotesWeight;
|
|
2874
|
+
if (Math.max(prevVelocity, currentVelocity)) {
|
|
2875
|
+
if (withSliders) currentVelocity = currentDistance / current.strainTime;
|
|
2876
|
+
const distanceRatio = _rian8337_osu_base.MathUtils.smoothstep(Math.abs(prevVelocity - currentVelocity) / Math.max(prevVelocity, currentVelocity), 0, 1);
|
|
2877
|
+
const overlapVelocityBuff = Math.min(current.normalizedDiameter * 1.25 / Math.min(current.strainTime, last.strainTime), Math.abs(prevVelocity - currentVelocity));
|
|
2878
|
+
flowDifficulty += overlapVelocityBuff * distanceRatio * overlappedNotesWeight * this.velocityChangeMultiplier;
|
|
2879
|
+
}
|
|
2880
|
+
if (current.object instanceof _rian8337_osu_base.Slider && withSliders) flowDifficulty += current.travelDistance / current.travelTime;
|
|
2881
|
+
flowDifficulty = Math.pow(flowDifficulty, 1.45);
|
|
2882
|
+
return flowDifficulty * _rian8337_osu_base.MathUtils.smootherstep(currentDistance, 0, current.normalizedRadius);
|
|
2883
|
+
}
|
|
2884
|
+
static calculateOverlapFactor(o1, o2) {
|
|
2885
|
+
const distance = o1.object.stackedPosition.getDistance(o2.object.stackedPosition);
|
|
2886
|
+
const { radius } = o1.object;
|
|
2887
|
+
return _rian8337_osu_base.MathUtils.clamp(1 - Math.pow(Math.max(distance - radius, 0) / radius, 2), 0, 1);
|
|
2888
|
+
}
|
|
2889
|
+
};
|
|
2890
|
+
// src/evaluators/osu/OsuReadingEvaluator.ts
|
|
2891
|
+
/**
|
|
2892
|
+
* Evaluator for reading difficulty in osu!standard.
|
|
2893
|
+
*/
|
|
2894
|
+
var OsuReadingEvaluator = class {
|
|
2895
|
+
static readingWindowSize = 3e3;
|
|
2896
|
+
static hiddenMultiplier = .28;
|
|
2897
|
+
static densityMultiplier = 2.4;
|
|
2898
|
+
static densityDifficultyBase = 2.5;
|
|
2899
|
+
static preemptBalancingFactor = 14e4;
|
|
2900
|
+
static preemptStartingPoint = 500;
|
|
2901
|
+
static minimumAngleRelevancyTime = 2e3;
|
|
2902
|
+
static maximumAngleRelevancyTime = 200;
|
|
2903
|
+
/**
|
|
2904
|
+
* Evaluates the difficulty of reading the object.
|
|
2905
|
+
*/
|
|
2906
|
+
static evaluateDifficultyOf(current, mods) {
|
|
2907
|
+
if (current.object instanceof _rian8337_osu_base.Spinner || current.index === 0) return 0;
|
|
2908
|
+
const distanceInfluenceThreshold = current.normalizedDiameter * 1.5;
|
|
2909
|
+
const next = current.next(0);
|
|
2910
|
+
const velocity = Math.max(1, current.lazyJumpDistance / current.strainTime);
|
|
2911
|
+
const currentVisibleObjectDensity = this.retrieveCurrentVisibleObjectDensity(current);
|
|
2912
|
+
const pastObjectDifficultyInfluence = this.getPastObjectDifficultyInfluence(current, distanceInfluenceThreshold);
|
|
2913
|
+
const constantAngleNerfFactor = this.getConstantAngleNerfFactor(current);
|
|
2914
|
+
const noteDensityDifficulty = this.calculateDensityDifficulty(next, distanceInfluenceThreshold, velocity, constantAngleNerfFactor, pastObjectDifficultyInfluence, currentVisibleObjectDensity);
|
|
2915
|
+
const hiddenDifficulty = this.calculateHiddenDifficulty(current, mods, pastObjectDifficultyInfluence, currentVisibleObjectDensity, velocity, constantAngleNerfFactor);
|
|
2916
|
+
const preemptDifficulty = this.calculatePreemptDifficulty(velocity, constantAngleNerfFactor, current.timePreempt);
|
|
2917
|
+
let difficulty = _rian8337_osu_base.MathUtils.norm(1.5, preemptDifficulty, hiddenDifficulty, noteDensityDifficulty);
|
|
2918
|
+
difficulty *= this.highBpmBonus(current.strainTime);
|
|
2919
|
+
return difficulty;
|
|
2920
|
+
}
|
|
2921
|
+
/**
|
|
2922
|
+
* Calculates the density difficulty of the current object and how hard it is to aim it because of it based on:
|
|
2923
|
+
*
|
|
2924
|
+
* - cursor velocity to the current object,
|
|
2925
|
+
* - how many times the current object's angle was repeated,
|
|
2926
|
+
* - density of objects visible when the current object appears, and
|
|
2927
|
+
* - density of objects visible when the current object needs to be clicked.
|
|
2928
|
+
*/
|
|
2929
|
+
static calculateDensityDifficulty(next, distanceInfluenceThreshold, velocity, constantAngleNerfFactor, pastObjectDifficultyInfluence, currentVisibleObjectDensity) {
|
|
2930
|
+
let futureObjectDifficultyInfluence = Math.sqrt(currentVisibleObjectDensity);
|
|
2931
|
+
if (next !== null) futureObjectDifficultyInfluence *= _rian8337_osu_base.MathUtils.smootherstep(next.lazyJumpDistance, 15, distanceInfluenceThreshold);
|
|
2932
|
+
let noteDensityDifficulty = Math.pow(pastObjectDifficultyInfluence + futureObjectDifficultyInfluence, 1.7) * .4 * constantAngleNerfFactor * velocity;
|
|
2933
|
+
noteDensityDifficulty = Math.max(0, noteDensityDifficulty - this.densityDifficultyBase);
|
|
2934
|
+
noteDensityDifficulty = Math.pow(noteDensityDifficulty, .45) * this.densityMultiplier;
|
|
2935
|
+
return noteDensityDifficulty;
|
|
2936
|
+
}
|
|
2937
|
+
/**
|
|
2938
|
+
* Calculates the difficulty of aiming the current object when the approach rate is very high based on:
|
|
2939
|
+
*
|
|
2940
|
+
* - cursor velocity to the current object,
|
|
2941
|
+
* - how many times the current object's angle was repeated, and
|
|
2942
|
+
* - how many milliseconds elapse between the approach circle appearing and touching the inner circle.
|
|
2943
|
+
*/
|
|
2944
|
+
static calculatePreemptDifficulty(velocity, constantAngleNerfFactor, preempt) {
|
|
2945
|
+
let preemptDifficulty = Math.pow((this.preemptStartingPoint - preempt + Math.abs(preempt - this.preemptStartingPoint)) / 2, 2.5) / this.preemptBalancingFactor;
|
|
2946
|
+
preemptDifficulty *= constantAngleNerfFactor * velocity;
|
|
2947
|
+
return preemptDifficulty;
|
|
2948
|
+
}
|
|
2949
|
+
/**
|
|
2950
|
+
* Calculates the difficulty of aiming the current object when the Hidden mod is active based on:
|
|
2951
|
+
*
|
|
2952
|
+
* - cursor velocity to the current object,
|
|
2953
|
+
* - time the current object spends invisible,
|
|
2954
|
+
* - density of objects visible when the current object appears,
|
|
2955
|
+
* - density of objects visible when the current object needs to be clicked,
|
|
2956
|
+
* - how many times the current object's angle was repeated, and
|
|
2957
|
+
* - if the current object is perfectly stacked to the previous one.
|
|
2958
|
+
*/
|
|
2959
|
+
static calculateHiddenDifficulty(current, mods, pastObjectDifficultyInfluence, currentVisibleObjectDensity, velocity, constantAngleNerfFactor) {
|
|
2960
|
+
if (!mods.has(_rian8337_osu_base.ModHidden) || mods.get(_rian8337_osu_base.ModHidden)?.onlyFadeApproachCircles.value) return 0;
|
|
2961
|
+
let hiddenDifficulty = (Math.pow(current.timePreempt, 2.2) * .01 + Math.pow(currentVisibleObjectDensity + pastObjectDifficultyInfluence, 3.3) * 3) * constantAngleNerfFactor * velocity * .01;
|
|
2962
|
+
hiddenDifficulty = Math.pow(hiddenDifficulty, .4) * this.hiddenMultiplier;
|
|
2963
|
+
const prev = current.previous(0);
|
|
2964
|
+
if (current.lazyJumpDistance === 0 && current.opacityAt(prev.object.startTime, mods) === 0 && prev.startTime > current.startTime - current.timePreempt) hiddenDifficulty += this.hiddenMultiplier * 2500 / Math.pow(current.strainTime, 1.5);
|
|
2965
|
+
return hiddenDifficulty;
|
|
2966
|
+
}
|
|
2967
|
+
static getPastObjectDifficultyInfluence(current, distanceInfluenceThreshold) {
|
|
2968
|
+
let pastObjectDifficultyInfluence = 0;
|
|
2969
|
+
for (const loopObj of this.retrievePastVisibleObjects(current)) {
|
|
2970
|
+
let loopDifficulty = current.opacityAt(loopObj.object.startTime);
|
|
2971
|
+
loopDifficulty *= _rian8337_osu_base.MathUtils.smootherstep(loopObj.lazyJumpDistance, 15, distanceInfluenceThreshold);
|
|
2972
|
+
const timeBetweenCurrAndLoopObj = current.startTime - loopObj.startTime;
|
|
2973
|
+
const timeNerfFactor = this.getTimeNerfFactor(timeBetweenCurrAndLoopObj);
|
|
2974
|
+
loopDifficulty *= timeNerfFactor;
|
|
2975
|
+
pastObjectDifficultyInfluence += loopDifficulty;
|
|
2976
|
+
}
|
|
2977
|
+
return pastObjectDifficultyInfluence;
|
|
2978
|
+
}
|
|
2979
|
+
/**
|
|
2980
|
+
* Returns a list of objects that are visible on screen at the point in time the current object becomes visible.
|
|
2981
|
+
*/
|
|
2982
|
+
static *retrievePastVisibleObjects(current) {
|
|
2983
|
+
for (let i = 0; i < current.index; ++i) {
|
|
2984
|
+
const hitObject = current.previous(i);
|
|
2985
|
+
if (!hitObject || current.startTime - hitObject.startTime > this.readingWindowSize || hitObject.startTime < current.startTime - current.timePreempt) break;
|
|
2986
|
+
yield hitObject;
|
|
2987
|
+
}
|
|
2988
|
+
}
|
|
2989
|
+
/**
|
|
2990
|
+
* Returns the density of objects visible at the point in time the current object needs to be clicked capped by the reading window.
|
|
2991
|
+
*/
|
|
2992
|
+
static retrieveCurrentVisibleObjectDensity(current) {
|
|
2993
|
+
let visibleObjectCount = 0;
|
|
2994
|
+
let hitObject = current.next(0);
|
|
2995
|
+
while (hitObject !== null) {
|
|
2996
|
+
if (hitObject.startTime - current.startTime > this.readingWindowSize || current.startTime + hitObject.timePreempt < hitObject.startTime) break;
|
|
2997
|
+
const timeBetweenCurrAndLoopObj = hitObject.startTime - current.startTime;
|
|
2998
|
+
const timeNerfFactor = this.getTimeNerfFactor(timeBetweenCurrAndLoopObj);
|
|
2999
|
+
visibleObjectCount += hitObject.opacityAt(current.object.startTime) * timeNerfFactor;
|
|
3000
|
+
hitObject = hitObject.next(0);
|
|
3001
|
+
}
|
|
3002
|
+
return visibleObjectCount;
|
|
3003
|
+
}
|
|
3004
|
+
/**
|
|
3005
|
+
* Returns a factor of how often the current object's angle has been repeated in a certain time frame.
|
|
3006
|
+
* It does this by checking the difference in angle between current and past objects and sums them based on a range of similarity.
|
|
3007
|
+
* https://www.desmos.com/calculator/eb057a4822
|
|
3008
|
+
*/
|
|
3009
|
+
static getConstantAngleNerfFactor(current) {
|
|
3010
|
+
let constantAngleCount = 0;
|
|
3011
|
+
let index = 0;
|
|
3012
|
+
let currentTimeGap = 0;
|
|
3013
|
+
let loopObjPrev0 = current;
|
|
3014
|
+
let loopObjPrev1 = null;
|
|
3015
|
+
let loopObjPrev2 = null;
|
|
3016
|
+
while (currentTimeGap < this.minimumAngleRelevancyTime) {
|
|
3017
|
+
const loopObj = current.previous(index);
|
|
3018
|
+
if (!loopObj) break;
|
|
3019
|
+
const longIntervalFactor = 1 - _rian8337_osu_base.Interpolation.reverseLerp(loopObj.strainTime, this.maximumAngleRelevancyTime, this.minimumAngleRelevancyTime);
|
|
3020
|
+
if (loopObj.angle !== null && current.angle !== null) {
|
|
3021
|
+
const angleDifference = Math.abs(current.angle - loopObj.angle);
|
|
3022
|
+
let angleDifferenceAlternating = Math.PI;
|
|
3023
|
+
if (loopObjPrev0.angle !== null && typeof loopObjPrev1?.angle === "number" && typeof loopObjPrev2?.angle === "number") {
|
|
3024
|
+
angleDifferenceAlternating = Math.abs(loopObjPrev1.angle - loopObj.angle);
|
|
3025
|
+
angleDifferenceAlternating += Math.abs(loopObjPrev2.angle - loopObjPrev0.angle);
|
|
3026
|
+
let weight = 1;
|
|
3027
|
+
weight *= _rian8337_osu_base.Interpolation.reverseLerp(_rian8337_osu_base.MathUtils.radiansToDegrees(Math.min(loopObj.angle, loopObjPrev0.angle)), 20, 5);
|
|
3028
|
+
weight *= _rian8337_osu_base.Interpolation.reverseLerp(_rian8337_osu_base.MathUtils.radiansToDegrees(Math.max(loopObj.angle, loopObjPrev0.angle)), 60, 120);
|
|
3029
|
+
angleDifferenceAlternating = _rian8337_osu_base.Interpolation.lerp(Math.PI, .1 * angleDifferenceAlternating, weight);
|
|
3030
|
+
}
|
|
3031
|
+
const stackFactor = _rian8337_osu_base.MathUtils.smootherstep(loopObj.lazyJumpDistance, 0, current.normalizedRadius);
|
|
3032
|
+
constantAngleCount += Math.cos(3 * Math.min(_rian8337_osu_base.MathUtils.degreesToRadians(30), Math.min(angleDifference, angleDifferenceAlternating) * stackFactor)) * longIntervalFactor;
|
|
3033
|
+
}
|
|
3034
|
+
currentTimeGap = current.startTime - loopObj.startTime;
|
|
3035
|
+
index++;
|
|
3036
|
+
loopObjPrev2 = loopObjPrev1;
|
|
3037
|
+
loopObjPrev1 = loopObjPrev0;
|
|
3038
|
+
loopObjPrev0 = loopObj;
|
|
3039
|
+
}
|
|
3040
|
+
return _rian8337_osu_base.MathUtils.clamp(2 / constantAngleCount, .2, 1);
|
|
3041
|
+
}
|
|
3042
|
+
/**
|
|
3043
|
+
* Returns a nerfing factor for when objects are very distant in time, affecting reading less.
|
|
3044
|
+
*/
|
|
3045
|
+
static getTimeNerfFactor(deltaTime) {
|
|
3046
|
+
return _rian8337_osu_base.MathUtils.clamp(2 - deltaTime / (this.readingWindowSize / 2), 0, 1);
|
|
3047
|
+
}
|
|
3048
|
+
static highBpmBonus(ms) {
|
|
3049
|
+
return 1 / (1 - Math.pow(.8, ms / 1e3));
|
|
3050
|
+
}
|
|
3051
|
+
};
|
|
3052
|
+
// src/evaluators/osu/OsuRhythmEvaluator.ts
|
|
3053
|
+
/**
|
|
3054
|
+
* An evaluator for calculating osu!standard Rhythm skill.
|
|
3055
|
+
*/
|
|
3056
|
+
var OsuRhythmEvaluator = class {
|
|
3057
|
+
static historyTimeMax = 5e3;
|
|
3058
|
+
static historyObjectsMax = 32;
|
|
3059
|
+
static rhythmOverallMultiplier = .95;
|
|
3060
|
+
static rhythmRatioMultiplier = 26;
|
|
3061
|
+
/**
|
|
3062
|
+
* Calculates a rhythm multiplier for the difficulty of the tap associated
|
|
3063
|
+
* with historic data of the current object.
|
|
3064
|
+
*
|
|
3065
|
+
* @param current The current object.
|
|
3066
|
+
*/
|
|
3067
|
+
static evaluateDifficultyOf(current) {
|
|
3068
|
+
if (current.object instanceof _rian8337_osu_base.Spinner) return 0;
|
|
3069
|
+
const deltaDifferenceEpsilon = current.hitWindowFor(_rian8337_osu_base.HitResult.Great) * .3;
|
|
3070
|
+
let rhythmComplexitySum = 0;
|
|
3071
|
+
let island = new Island(Number.MAX_SAFE_INTEGER);
|
|
3072
|
+
let previousIsland = new Island(Number.MAX_SAFE_INTEGER);
|
|
3073
|
+
const islands = [];
|
|
3074
|
+
let startRatio = 0;
|
|
3075
|
+
let firstDeltaSwitch = false;
|
|
3076
|
+
let rhythmStart = 0;
|
|
3077
|
+
const historicalNoteCount = Math.min(current.index, this.historyObjectsMax);
|
|
3078
|
+
while (rhythmStart < historicalNoteCount - 2 && current.startTime - current.previous(rhythmStart).startTime < this.historyTimeMax) ++rhythmStart;
|
|
3079
|
+
let prevObject = current.previous(rhythmStart);
|
|
3080
|
+
let lastObject = current.previous(rhythmStart + 1);
|
|
3081
|
+
for (let i = rhythmStart; i > 0; --i) {
|
|
3082
|
+
const currentObject = current.previous(i - 1);
|
|
3083
|
+
if (currentObject.object instanceof _rian8337_osu_base.Spinner) continue;
|
|
3084
|
+
const timeDecay = (this.historyTimeMax - (current.startTime - currentObject.startTime)) / this.historyTimeMax;
|
|
3085
|
+
const noteDecay = (historicalNoteCount - i) / historicalNoteCount;
|
|
3086
|
+
const currentHistoricalDecay = Math.min(timeDecay, noteDecay);
|
|
3087
|
+
const currentDelta = Math.max(currentObject.deltaTime, 1e-7);
|
|
3088
|
+
const prevDelta = Math.max(prevObject.deltaTime, 1e-7);
|
|
3089
|
+
const lastDelta = Math.max(lastObject.deltaTime, 1e-7);
|
|
3090
|
+
if (island.delta == Number.MAX_SAFE_INTEGER) island = new Island(currentDelta);
|
|
3091
|
+
const deltaDifference = Math.max(prevDelta, currentDelta) / Math.min(prevDelta, currentDelta);
|
|
3092
|
+
const differenceMultiplier = _rian8337_osu_base.MathUtils.clamp(2 - deltaDifference / 8, 0, 1);
|
|
3093
|
+
let effectiveRatio = Math.min(1, Math.max(0, Math.abs(prevDelta - currentDelta) - deltaDifferenceEpsilon) / deltaDifferenceEpsilon) * this.getEffectiveRatio(deltaDifference) * differenceMultiplier;
|
|
3094
|
+
if (prevObject.object instanceof _rian8337_osu_base.Slider) {
|
|
3095
|
+
const sliderLazyEndDelta = currentObject.minimumJumpTime;
|
|
3096
|
+
const sliderLazyEndDeltaDifference = Math.max(sliderLazyEndDelta, currentDelta) / Math.min(sliderLazyEndDelta, currentDelta);
|
|
3097
|
+
const sliderRealEndDelta = currentObject.lastObjectEndDeltaTime;
|
|
3098
|
+
const sliderRealEndDeltaDifference = Math.max(sliderRealEndDelta, currentDelta) / Math.min(sliderRealEndDelta, currentDelta);
|
|
3099
|
+
const sliderEffectiveRatio = Math.min(this.getEffectiveRatio(sliderLazyEndDeltaDifference), this.getEffectiveRatio(sliderRealEndDeltaDifference));
|
|
3100
|
+
effectiveRatio = Math.min(sliderEffectiveRatio, effectiveRatio);
|
|
3101
|
+
}
|
|
3102
|
+
const isSpeedingUp = prevDelta > currentDelta + deltaDifferenceEpsilon;
|
|
3103
|
+
if (Math.abs(prevDelta - currentDelta) < deltaDifferenceEpsilon) island.addDelta(currentDelta);
|
|
3104
|
+
if (firstDeltaSwitch) {
|
|
3105
|
+
if (Math.abs(prevDelta - currentDelta) > deltaDifferenceEpsilon) {
|
|
3106
|
+
if (currentObject.object instanceof _rian8337_osu_base.Slider) effectiveRatio /= 2;
|
|
3107
|
+
if (island.isSimilarPolarity(previousIsland, deltaDifferenceEpsilon)) effectiveRatio /= 2;
|
|
3108
|
+
if (lastDelta > prevDelta + deltaDifferenceEpsilon && prevDelta > currentDelta + deltaDifferenceEpsilon) effectiveRatio /= 8;
|
|
3109
|
+
if (previousIsland.deltaCount == island.deltaCount) effectiveRatio /= 2;
|
|
3110
|
+
if (isSpeedingUp) effectiveRatio *= .65;
|
|
3111
|
+
let found = false;
|
|
3112
|
+
for (const existingIsland of islands) {
|
|
3113
|
+
if (!existingIsland.almostEquals(island, deltaDifferenceEpsilon)) continue;
|
|
3114
|
+
if (previousIsland.almostEquals(island, deltaDifferenceEpsilon)) ++existingIsland.occurrences;
|
|
3115
|
+
const power = _rian8337_osu_base.MathUtils.offsetLogistic(island.delta, 58.33, .24, 2.75);
|
|
3116
|
+
effectiveRatio *= Math.min(3 / existingIsland.occurrences, Math.pow(1 / existingIsland.occurrences, power));
|
|
3117
|
+
found = true;
|
|
3118
|
+
break;
|
|
3119
|
+
}
|
|
3120
|
+
if (!found && island.deltaCount > 0) islands.push(island);
|
|
3121
|
+
effectiveRatio *= 1 - prevObject.getDoubletapness(currentObject) * .75;
|
|
3122
|
+
if (island.deltaCount > 1) rhythmComplexitySum += Math.sqrt(effectiveRatio * startRatio) * currentHistoricalDecay;
|
|
3123
|
+
else rhythmComplexitySum += .7 * currentHistoricalDecay;
|
|
3124
|
+
startRatio = effectiveRatio;
|
|
3125
|
+
previousIsland = island;
|
|
3126
|
+
if (prevDelta + deltaDifferenceEpsilon < currentDelta) firstDeltaSwitch = false;
|
|
3127
|
+
island = new Island(currentDelta);
|
|
3128
|
+
}
|
|
3129
|
+
} else if (prevDelta > currentDelta + deltaDifferenceEpsilon) {
|
|
3130
|
+
firstDeltaSwitch = true;
|
|
3131
|
+
if (currentObject.object instanceof _rian8337_osu_base.Slider) effectiveRatio *= .6;
|
|
3132
|
+
if (prevObject.object instanceof _rian8337_osu_base.Slider) effectiveRatio *= .6;
|
|
3133
|
+
startRatio = effectiveRatio;
|
|
3134
|
+
island = new Island(currentDelta);
|
|
3135
|
+
}
|
|
3136
|
+
lastObject = prevObject;
|
|
3137
|
+
prevObject = currentObject;
|
|
3138
|
+
}
|
|
3139
|
+
rhythmComplexitySum *= _rian8337_osu_base.Interpolation.reverseLerp(island.deltaCount, 22, 3);
|
|
3140
|
+
return Math.sqrt(4 + rhythmComplexitySum * this.rhythmOverallMultiplier) / 2;
|
|
3141
|
+
}
|
|
3142
|
+
static getEffectiveRatio(deltaDifference) {
|
|
3143
|
+
const deltaDifferenceFraction = deltaDifference - Math.trunc(deltaDifference);
|
|
3144
|
+
return 1 + this.rhythmRatioMultiplier * Math.min(.5, _rian8337_osu_base.MathUtils.smoothstepBellCurve(deltaDifferenceFraction));
|
|
3145
|
+
}
|
|
3146
|
+
};
|
|
3147
|
+
// src/evaluators/osu/OsuSpeedEvaluator.ts
|
|
3148
|
+
/**
|
|
3149
|
+
* An evaluator for calculating osu!standard speed skill.
|
|
3150
|
+
*/
|
|
3151
|
+
var OsuSpeedEvaluator = class {
|
|
3152
|
+
static minSpeedBonus = 200;
|
|
3153
|
+
/**
|
|
3154
|
+
* Evaluates the difficulty of tapping the current object, based on:
|
|
3155
|
+
*
|
|
3156
|
+
* - time between pressing the previous and current object,
|
|
3157
|
+
* - and how easily they can be cheesed.
|
|
3158
|
+
*
|
|
3159
|
+
* @param current The current object.
|
|
3160
|
+
*/
|
|
3161
|
+
static evaluateDifficultyOf(current) {
|
|
3162
|
+
if (current.object instanceof _rian8337_osu_base.Spinner) return 0;
|
|
3163
|
+
let strainTime = current.strainTime;
|
|
3164
|
+
const doubletapness = 1 - current.getDoubletapness(current.next(0));
|
|
3165
|
+
strainTime /= _rian8337_osu_base.MathUtils.clamp(strainTime / current.hitWindowFor(_rian8337_osu_base.HitResult.Great) / .93, .92, 1);
|
|
3166
|
+
let speedBonus = 0;
|
|
3167
|
+
if (_rian8337_osu_base.MathUtils.millisecondsToBPM(strainTime) > this.minSpeedBonus) speedBonus = .75 * Math.pow((_rian8337_osu_base.MathUtils.bpmToMilliseconds(this.minSpeedBonus) - strainTime) / 40, 2);
|
|
3168
|
+
let difficulty = (1 + speedBonus) * 1e3 / strainTime;
|
|
3169
|
+
difficulty *= this.highBpmBonus(current.strainTime);
|
|
3170
|
+
return difficulty * doubletapness;
|
|
3171
|
+
}
|
|
3172
|
+
static highBpmBonus(ms) {
|
|
3173
|
+
return 1 / (1 - Math.pow(.3, ms / 1e3));
|
|
3174
|
+
}
|
|
3175
|
+
};
|
|
3176
|
+
// src/skills/osu/OsuAim.ts
|
|
3177
|
+
/**
|
|
3178
|
+
* Represents the skill required to correctly aim at every object in the map with a uniform CircleSize and normalized distances.
|
|
3179
|
+
*/
|
|
3180
|
+
var OsuAim = class extends VariableLengthStrainSkill {
|
|
3181
|
+
currentStrain = 0;
|
|
3182
|
+
skillMultiplierSnap = 70.9;
|
|
3183
|
+
skillMultiplierAgility = 2.35;
|
|
3184
|
+
skillMultiplierFlow = 242;
|
|
3185
|
+
skillMultiplierTotal = 1.12;
|
|
3186
|
+
combinedSnapNormExponent = 1.2;
|
|
3187
|
+
/**
|
|
3188
|
+
* The number of sections with the highest strains, which the peak strain reductions will apply to.
|
|
3189
|
+
* This is done in order to decrease their impact on the overall difficulty of the beatmap.
|
|
3190
|
+
*/
|
|
3191
|
+
reducedSectionTime = 4e3;
|
|
3192
|
+
/**
|
|
3193
|
+
* The baseline multiplier applied to the section with the biggest strain.
|
|
3194
|
+
*/
|
|
3195
|
+
reducedStrainBaseline = .727;
|
|
3196
|
+
sliderStrains = [];
|
|
3197
|
+
maxSliderStrain = 0;
|
|
3198
|
+
withSliders;
|
|
3199
|
+
constructor(mods, withSliders) {
|
|
3200
|
+
super(mods);
|
|
3201
|
+
this.withSliders = withSliders;
|
|
3202
|
+
}
|
|
3203
|
+
/**
|
|
3204
|
+
* Obtains the amount of sliders that are considered difficult in terms of relative strain.
|
|
3205
|
+
*/
|
|
3206
|
+
countDifficultSliders() {
|
|
3207
|
+
if (this.sliderStrains.length === 0 || this.maxSliderStrain === 0) return 0;
|
|
3208
|
+
return this.sliderStrains.reduce((total, strain) => total + 1 / (1 + Math.exp(-(strain / this.maxSliderStrain * 12 - 6))), 0);
|
|
3209
|
+
}
|
|
3210
|
+
/**
|
|
3211
|
+
* Obtains the amount of sliders that are considered difficult in terms of relative strain, weighted by consistency.
|
|
3212
|
+
*
|
|
3213
|
+
* @param difficultyValue The final difficulty value.
|
|
3214
|
+
*/
|
|
3215
|
+
countTopWeightedSliders(difficultyValue) {
|
|
3216
|
+
if (this.sliderStrains.length === 0) return 0;
|
|
3217
|
+
const consistentTopStrain = difficultyValue * (1 - this.decayWeight);
|
|
3218
|
+
if (consistentTopStrain === 0) return 0;
|
|
3219
|
+
return this.sliderStrains.reduce((total, next) => total + _rian8337_osu_base.MathUtils.offsetLogistic(next / consistentTopStrain, .88, 10, 1.1), 0);
|
|
3220
|
+
}
|
|
3221
|
+
strainValueAt(current) {
|
|
3222
|
+
if (this.mods.has(_rian8337_osu_base.ModAutopilot)) return 0;
|
|
3223
|
+
const decay = this.strainDecay(current.strainTime);
|
|
3224
|
+
this.currentStrain *= decay;
|
|
3225
|
+
this.currentStrain += this.calculateAdjustedDifficulty(current) * (1 - decay);
|
|
3226
|
+
if (current.object instanceof _rian8337_osu_base.Slider) {
|
|
3227
|
+
this.sliderStrains.push(this.currentStrain);
|
|
3228
|
+
this.maxSliderStrain = Math.max(this.maxSliderStrain, this.currentStrain);
|
|
3229
|
+
}
|
|
3230
|
+
return this.currentStrain;
|
|
3231
|
+
}
|
|
3232
|
+
calculateInitialStrain(time, current) {
|
|
3233
|
+
return this.currentStrain * this.strainDecay(time - (current.previous(0)?.startTime ?? 0));
|
|
3234
|
+
}
|
|
3235
|
+
saveToHitObject(current) {
|
|
3236
|
+
if (this.withSliders) current.aimStrainWithSliders = this.currentStrain;
|
|
3237
|
+
else current.aimStrainWithoutSliders = this.currentStrain;
|
|
3238
|
+
}
|
|
3239
|
+
calculateAdjustedDifficulty(current) {
|
|
3240
|
+
const snapDifficulty = OsuSnapAimEvaluator.evaluateDifficultyOf(current, this.withSliders) * this.skillMultiplierSnap;
|
|
3241
|
+
const agilityDifficulty = OsuAgilityEvaluator.evaluateDifficultyOf(current) * this.skillMultiplierAgility;
|
|
3242
|
+
const flowDifficulty = OsuFlowAimEvaluator.evaluateDifficultyOf(current, this.withSliders) * this.skillMultiplierFlow;
|
|
3243
|
+
let totalDifficulty = this.calculateTotalValue(snapDifficulty, agilityDifficulty, flowDifficulty);
|
|
3244
|
+
if (this.mods.has(_rian8337_osu_base.ModMagnetised)) {
|
|
3245
|
+
const magnetisedStrength = this.mods.get(_rian8337_osu_base.ModMagnetised).attractionStrength.value;
|
|
3246
|
+
totalDifficulty *= 1 - magnetisedStrength;
|
|
3247
|
+
}
|
|
3248
|
+
totalDifficulty *= .985 + Math.pow(Math.max(0, current.overallDifficulty), 2) / 4e3;
|
|
3249
|
+
return totalDifficulty;
|
|
3250
|
+
}
|
|
3251
|
+
calculateTotalValue(snapDifficulty, agilityDifficulty, flowDifficulty) {
|
|
3252
|
+
let combinedSnapDifficulty = _rian8337_osu_base.MathUtils.norm(this.combinedSnapNormExponent, snapDifficulty, agilityDifficulty);
|
|
3253
|
+
const pSnap = this.calculateSnapFlowProbability(flowDifficulty / combinedSnapDifficulty);
|
|
3254
|
+
const pFlow = 1 - pSnap;
|
|
3255
|
+
if (this.mods.has(_rian8337_osu_base.ModTouchDevice)) {
|
|
3256
|
+
snapDifficulty = Math.pow(snapDifficulty, .89);
|
|
3257
|
+
combinedSnapDifficulty = _rian8337_osu_base.MathUtils.norm(this.combinedSnapNormExponent, snapDifficulty, agilityDifficulty);
|
|
3258
|
+
}
|
|
3259
|
+
if (this.mods.has(_rian8337_osu_base.ModRelax)) {
|
|
3260
|
+
combinedSnapDifficulty *= .75;
|
|
3261
|
+
flowDifficulty *= .6;
|
|
3262
|
+
}
|
|
3263
|
+
return (combinedSnapDifficulty * pSnap + flowDifficulty * pFlow) * this.skillMultiplierTotal;
|
|
3264
|
+
}
|
|
3265
|
+
/**
|
|
3266
|
+
* Converts the ratio of snap to flow into the probability of snapping or flowing.
|
|
3267
|
+
*
|
|
3268
|
+
* Constraints:
|
|
3269
|
+
* - `P(snap) + P(flow) = 1` (the object is always either snapped or flowed)
|
|
3270
|
+
* - `P(snap) = f(snap / flow)` and `P(flow) = f(flow/snap)` (i.e., snap and flow are symmetric and
|
|
3271
|
+
* reversible). This means `f(x) + f(1/x) = 1`
|
|
3272
|
+
* - `0 <= f(x) <= 1` (cannot have negative or greater than 100% probability of snapping or flowing)
|
|
3273
|
+
*
|
|
3274
|
+
* This logistic function is a solution, which fits nicely with the general idea of interpolation and
|
|
3275
|
+
* provides a tuneable constant.
|
|
3276
|
+
*
|
|
3277
|
+
* @param ratio The ratio.
|
|
3278
|
+
* @returns The probability.
|
|
3279
|
+
*/
|
|
3280
|
+
calculateSnapFlowProbability(ratio) {
|
|
3281
|
+
if (ratio === 0) return 0;
|
|
3282
|
+
if (Number.isNaN(ratio)) return 1;
|
|
3283
|
+
return _rian8337_osu_base.MathUtils.logistic(-7.27 * Math.log(ratio));
|
|
3284
|
+
}
|
|
3285
|
+
difficultyValue() {
|
|
3286
|
+
let time = 0;
|
|
3287
|
+
let difficulty = 0;
|
|
3288
|
+
for (const strain of this.getReducedStrainPeaks()) {
|
|
3289
|
+
const startTime = time;
|
|
3290
|
+
const endTime = time + strain.sectionLength / this.maxSectionLength;
|
|
3291
|
+
const weight = Math.pow(this.decayWeight, startTime) - Math.pow(this.decayWeight, endTime);
|
|
3292
|
+
difficulty += strain.value * weight;
|
|
3293
|
+
time = endTime;
|
|
3294
|
+
}
|
|
3295
|
+
return difficulty / (1 - this.decayWeight);
|
|
3296
|
+
}
|
|
3297
|
+
getReducedStrainPeaks() {
|
|
3298
|
+
const strains = this.currentStrainPeaks.filter((s) => s.value > 0).sort((a, b) => b.value - a.value);
|
|
3299
|
+
let time = 0;
|
|
3300
|
+
let strainsToRemove = 0;
|
|
3301
|
+
const chunkSize = 20;
|
|
3302
|
+
while (strains.length > strainsToRemove && time < this.reducedSectionTime) {
|
|
3303
|
+
const strain = strains[strainsToRemove];
|
|
3304
|
+
for (let addedTime = 0; addedTime < strain.sectionLength; addedTime += chunkSize) {
|
|
3305
|
+
const scale = Math.log10(_rian8337_osu_base.Interpolation.lerp(1, 10, _rian8337_osu_base.MathUtils.clamp((time + addedTime) / this.reducedSectionTime, 0, 1)));
|
|
3306
|
+
strains.push(new StrainPeak(strain.value * _rian8337_osu_base.Interpolation.lerp(this.reducedStrainBaseline, 1, scale), Math.min(chunkSize, strain.sectionLength - addedTime)));
|
|
3307
|
+
}
|
|
3308
|
+
time += strain.sectionLength;
|
|
3309
|
+
++strainsToRemove;
|
|
3310
|
+
}
|
|
3311
|
+
strains.splice(0, strainsToRemove);
|
|
3312
|
+
return strains.sort((a, b) => b.value - a.value);
|
|
3313
|
+
}
|
|
3314
|
+
strainDecay(ms) {
|
|
3315
|
+
return Math.pow(.2, ms / 1e3);
|
|
3316
|
+
}
|
|
3317
|
+
};
|
|
3318
|
+
// src/skills/osu/OsuReading.ts
|
|
3319
|
+
/**
|
|
3320
|
+
* Represents the skill required to read every object in the beatmap.
|
|
3321
|
+
*/
|
|
3322
|
+
var OsuReading = class extends HarmonicSkill {
|
|
3323
|
+
clockRate;
|
|
3324
|
+
hitObjects;
|
|
3325
|
+
currentDifficulty = 0;
|
|
3326
|
+
skillMultiplier = 2.5;
|
|
3327
|
+
difficultyDecayBase = .8;
|
|
3328
|
+
constructor(mods, clockRate, hitObjects) {
|
|
3329
|
+
super(mods);
|
|
3330
|
+
this.clockRate = clockRate;
|
|
3331
|
+
this.hitObjects = hitObjects;
|
|
3332
|
+
}
|
|
3333
|
+
countTopWeightedObjectDifficulties(difficultyValue) {
|
|
3334
|
+
if (difficultyValue === 0) return 0;
|
|
3335
|
+
if (this.noteWeightSum === 0) return 0;
|
|
3336
|
+
const consistentTopNote = difficultyValue / this.noteWeightSum;
|
|
3337
|
+
if (consistentTopNote === 0) return 0;
|
|
3338
|
+
return this.objectDifficulties.reduce((total, next) => total + _rian8337_osu_base.MathUtils.offsetLogistic(next / consistentTopNote, 1.15, 5, 1.1), 0);
|
|
3339
|
+
}
|
|
3340
|
+
objectDifficultyOf(current) {
|
|
3341
|
+
const decay = this.difficultyDecay(current.deltaTime);
|
|
3342
|
+
this.currentDifficulty *= decay;
|
|
3343
|
+
this.currentDifficulty += this.calculateAdjustedDifficulty(current) * (1 - decay) * this.skillMultiplier;
|
|
3344
|
+
return this.currentDifficulty;
|
|
3345
|
+
}
|
|
3346
|
+
applyDifficultyTransformation(difficulties) {
|
|
3347
|
+
const reducedNoteCount = this.calculateReducedNoteCount();
|
|
3348
|
+
for (let i = 0; i < Math.min(difficulties.length, reducedNoteCount); ++i) difficulties[i] *= Math.log10(_rian8337_osu_base.Interpolation.lerp(1, 10, _rian8337_osu_base.MathUtils.clamp(i / reducedNoteCount, 0, 1)));
|
|
3349
|
+
}
|
|
3350
|
+
saveToHitObject(current, difficulty) {
|
|
3351
|
+
current.readingDifficulty = difficulty;
|
|
3352
|
+
}
|
|
3353
|
+
calculateAdjustedDifficulty(current) {
|
|
3354
|
+
let difficulty = OsuReadingEvaluator.evaluateDifficultyOf(current, this.mods);
|
|
3355
|
+
if (this.mods.has(_rian8337_osu_base.ModTouchDevice)) difficulty = Math.pow(difficulty, .89);
|
|
3356
|
+
if (this.mods.has(_rian8337_osu_base.ModMagnetised)) {
|
|
3357
|
+
const magnetisedStrength = this.mods.get(_rian8337_osu_base.ModMagnetised).attractionStrength.value;
|
|
3358
|
+
difficulty *= 1 - magnetisedStrength;
|
|
3359
|
+
}
|
|
3360
|
+
if (this.mods.has(_rian8337_osu_base.ModRelax)) difficulty *= .4;
|
|
3361
|
+
else if (this.mods.has(_rian8337_osu_base.ModAutopilot)) difficulty *= .1;
|
|
3362
|
+
difficulty *= .825 + Math.pow(Math.max(0, current.overallDifficulty), 2.2) / 1125;
|
|
3363
|
+
return difficulty;
|
|
3364
|
+
}
|
|
3365
|
+
calculateReducedNoteCount() {
|
|
3366
|
+
if (this.hitObjects.length < 2) return 0;
|
|
3367
|
+
const reducedDuration = this.hitObjects[1].startTime / this.clockRate + 6e4;
|
|
3368
|
+
let reducedNoteCount = 0;
|
|
3369
|
+
for (let i = 1; i < this.hitObjects.length; ++i) {
|
|
3370
|
+
if (this.hitObjects[i].startTime / this.clockRate > reducedDuration) break;
|
|
3371
|
+
++reducedNoteCount;
|
|
3372
|
+
}
|
|
3373
|
+
return reducedNoteCount;
|
|
3374
|
+
}
|
|
3375
|
+
difficultyDecay(ms) {
|
|
3376
|
+
return Math.pow(this.difficultyDecayBase, ms / 1e3);
|
|
3377
|
+
}
|
|
3378
|
+
};
|
|
3379
|
+
// src/skills/osu/OsuSpeed.ts
|
|
3380
|
+
/**
|
|
3381
|
+
* Represents the skill required to press keys or tap with regards to keeping up with the speed at which objects need to be hit.
|
|
3382
|
+
*/
|
|
3383
|
+
var OsuSpeed = class extends HarmonicSkill {
|
|
3384
|
+
harmonicScale = 20;
|
|
3385
|
+
currentDifficulty = 0;
|
|
3386
|
+
currentRhythm = 0;
|
|
3387
|
+
skillMultiplier = 1.16;
|
|
3388
|
+
strainDecayBase = .3;
|
|
3389
|
+
sliderDifficulties = [];
|
|
3390
|
+
maxDifficulty = 0;
|
|
3391
|
+
/**
|
|
3392
|
+
* The amount of notes that are relevant to the difficulty.
|
|
3393
|
+
*/
|
|
3394
|
+
relevantNoteCount() {
|
|
3395
|
+
if (this.objectDifficulties.length === 0 || this.maxDifficulty === 0) return 0;
|
|
3396
|
+
return this.objectDifficulties.reduce((total, next) => total + 1 / (1 + Math.exp(-(next / this.maxDifficulty * 12 - 6))), 0);
|
|
3397
|
+
}
|
|
3398
|
+
/**
|
|
3399
|
+
* Obtains the amount of sliders that are considered difficult in terms of relative difficulty, weighted by consistency.
|
|
3400
|
+
*
|
|
3401
|
+
* @param difficultyValue The final difficulty value.
|
|
3402
|
+
*/
|
|
3403
|
+
countTopWeightedSliders(difficultyValue) {
|
|
3404
|
+
if (this.sliderDifficulties.length === 0) return 0;
|
|
3405
|
+
if (this.noteWeightSum === 0) return 0;
|
|
3406
|
+
const consistentTopNote = difficultyValue / this.noteWeightSum;
|
|
3407
|
+
if (consistentTopNote === 0) return 0;
|
|
3408
|
+
return this.sliderDifficulties.reduce((total, next) => total + _rian8337_osu_base.MathUtils.offsetLogistic(next / consistentTopNote, .88, 10, 1.1), 0);
|
|
3409
|
+
}
|
|
3410
|
+
objectDifficultyOf(current) {
|
|
3411
|
+
if (this.mods.has(_rian8337_osu_base.ModRelax)) return 0;
|
|
3412
|
+
const decay = this.strainDecay(current.strainTime);
|
|
3413
|
+
this.currentDifficulty *= decay;
|
|
3414
|
+
this.currentDifficulty += this.calculateAdjustedDifficulty(current) * (1 - decay) * this.skillMultiplier;
|
|
3415
|
+
this.currentRhythm = OsuRhythmEvaluator.evaluateDifficultyOf(current);
|
|
3416
|
+
const difficulty = this.currentDifficulty * this.currentRhythm;
|
|
3417
|
+
this.maxDifficulty = Math.max(this.maxDifficulty, difficulty);
|
|
3418
|
+
if (current.object instanceof _rian8337_osu_base.Slider) this.sliderDifficulties.push(difficulty);
|
|
3419
|
+
return difficulty;
|
|
3420
|
+
}
|
|
3421
|
+
saveToHitObject(current) {
|
|
3422
|
+
current.speedStrain = this.currentDifficulty * this.currentRhythm;
|
|
3423
|
+
current.rhythmMultiplier = this.currentRhythm;
|
|
3424
|
+
}
|
|
3425
|
+
calculateAdjustedDifficulty(current) {
|
|
3426
|
+
let difficulty = OsuSpeedEvaluator.evaluateDifficultyOf(current);
|
|
3427
|
+
if (this.mods.has(_rian8337_osu_base.ModAutopilot)) difficulty *= .5;
|
|
3428
|
+
return difficulty;
|
|
3429
|
+
}
|
|
3430
|
+
strainDecay(ms) {
|
|
3431
|
+
return Math.pow(this.strainDecayBase, ms / 1e3);
|
|
3432
|
+
}
|
|
3433
|
+
};
|
|
3434
|
+
// src/OsuPerformanceCalculator.ts
|
|
3435
|
+
/**
|
|
3436
|
+
* A performance points calculator that calculates performance points for osu!standard gamemode.
|
|
3437
|
+
*/
|
|
3438
|
+
var OsuPerformanceCalculator = class OsuPerformanceCalculator extends PerformanceCalculator {
|
|
3439
|
+
static finalMultiplier = 1.12;
|
|
3440
|
+
static normExponent = 1.1;
|
|
3441
|
+
greatWindow = 0;
|
|
3442
|
+
okWindow = 0;
|
|
3443
|
+
mehWindow = 0;
|
|
3444
|
+
approachRate = 0;
|
|
3445
|
+
overallDifficulty = 0;
|
|
3446
|
+
_effectiveMissCount = 0;
|
|
3447
|
+
speedDeviation = 0;
|
|
3448
|
+
createPerformanceAttributes() {
|
|
3449
|
+
this._effectiveMissCount = _rian8337_osu_base.MathUtils.clamp(this.calculateComboBasedEstimatedMissCount(), this.computedAccuracy.nmiss, this.totalHits);
|
|
3450
|
+
let { finalMultiplier } = OsuPerformanceCalculator;
|
|
3451
|
+
const { spinnerCount, approachRate: ar, overallDifficulty: od, clockRate } = this.difficultyAttributes;
|
|
3452
|
+
if (this.mods.has(_rian8337_osu_base.ModNoFail)) finalMultiplier *= Math.max(.9, 1 - .02 * this._effectiveMissCount);
|
|
3453
|
+
if (this.mods.has(_rian8337_osu_base.ModSpunOut)) finalMultiplier *= 1 - Math.pow(spinnerCount / this.totalHits, .85);
|
|
3454
|
+
if (this.mods.has(_rian8337_osu_base.ModRelax)) {
|
|
3455
|
+
const n100Multiplier = .75 * Math.max(0, od > 0 ? 1 - od / 13.33 : 1);
|
|
3456
|
+
const n50Multiplier = Math.max(0, od > 0 ? 1 - Math.pow(od / 13.33, 5) : 1);
|
|
3457
|
+
this._effectiveMissCount = Math.min(this._effectiveMissCount + this.computedAccuracy.n100 * n100Multiplier + this.computedAccuracy.n50 * n50Multiplier, this.totalHits);
|
|
3458
|
+
}
|
|
3459
|
+
const hitWindow = new _rian8337_osu_base.OsuHitWindow(od);
|
|
3460
|
+
this.greatWindow = hitWindow.greatWindow / clockRate;
|
|
3461
|
+
this.okWindow = hitWindow.okWindow / clockRate;
|
|
3462
|
+
this.mehWindow = hitWindow.mehWindow / clockRate;
|
|
3463
|
+
this.approachRate = this.calculateRateAdjustedApproachRate(ar, clockRate);
|
|
3464
|
+
this.overallDifficulty = (79.5 - this.greatWindow) / 6;
|
|
3465
|
+
this.speedDeviation = this.calculateSpeedDeviation();
|
|
3466
|
+
const aim = this.calculateAimValue();
|
|
3467
|
+
const speed = this.calculateSpeedValue();
|
|
3468
|
+
const accuracy = this.calculateAccuracyValue();
|
|
3469
|
+
const flashlight = this.calculateFlashlightValue();
|
|
3470
|
+
const reading = this.calculateReadingValue();
|
|
3471
|
+
const cognitionValue = OsuDifficultyCalculator.sumCognitionDifficulty(reading, flashlight);
|
|
3472
|
+
return {
|
|
3473
|
+
total: _rian8337_osu_base.MathUtils.norm(OsuPerformanceCalculator.normExponent, aim, speed, accuracy, cognitionValue) * finalMultiplier,
|
|
3474
|
+
aim,
|
|
3475
|
+
speed,
|
|
3476
|
+
accuracy,
|
|
3477
|
+
flashlight,
|
|
3478
|
+
reading,
|
|
3479
|
+
effectiveMissCount: this._effectiveMissCount
|
|
3480
|
+
};
|
|
3481
|
+
}
|
|
3482
|
+
/**
|
|
3483
|
+
* Calculates the aim performance value of the beatmap.
|
|
3484
|
+
*/
|
|
3485
|
+
calculateAimValue() {
|
|
3486
|
+
if (this.mods.has(_rian8337_osu_base.ModAutopilot)) return 0;
|
|
3487
|
+
let { aimDifficulty } = this.difficultyAttributes;
|
|
3488
|
+
const { aimDifficultSliderCount, sliderFactor } = this.difficultyAttributes;
|
|
3489
|
+
if (aimDifficultSliderCount > 0) {
|
|
3490
|
+
let estimateImproperlyFollowedDifficultSliders;
|
|
3491
|
+
if (this.usingClassicSliderAccuracy) estimateImproperlyFollowedDifficultSliders = _rian8337_osu_base.MathUtils.clamp(Math.min(this.totalImperfectHits, this.difficultyAttributes.maxCombo - this.combo), 0, aimDifficultSliderCount);
|
|
3492
|
+
else estimateImproperlyFollowedDifficultSliders = _rian8337_osu_base.MathUtils.clamp(this.sliderEndsDropped + this.sliderTicksMissed, 0, aimDifficultSliderCount);
|
|
3493
|
+
aimDifficulty *= (1 - sliderFactor) * Math.pow(1 - estimateImproperlyFollowedDifficultSliders / aimDifficultSliderCount, 3) + sliderFactor;
|
|
3494
|
+
}
|
|
3495
|
+
let aimValue = OsuAim.difficultyToPerformance(aimDifficulty);
|
|
3496
|
+
let lengthBonus = .95 + .35 * Math.min(1, this.totalHits / 2e3);
|
|
3497
|
+
if (this.totalHits > 2e3) lengthBonus += Math.log10(this.totalHits / 2e3) * .5;
|
|
3498
|
+
aimValue *= lengthBonus;
|
|
3499
|
+
if (this._effectiveMissCount > 0) {
|
|
3500
|
+
const aimEstimatedSliderBreaks = this.calculateEstimatedSliderBreaks(this.difficultyAttributes.aimTopWeightedSliderFactor);
|
|
3501
|
+
const relevantMissCount = Math.min(this._effectiveMissCount + aimEstimatedSliderBreaks, this.totalImperfectHits + this.sliderTicksMissed);
|
|
3502
|
+
aimValue *= this.calculateMissPenalty(relevantMissCount, this.difficultyAttributes.aimDifficultStrainCount);
|
|
3503
|
+
}
|
|
3504
|
+
if (this.mods.has(_rian8337_osu_base.ModBlinds)) aimValue *= 1.3 + this.totalHits * (.0016 / (1 + 2 * this._effectiveMissCount)) * Math.pow(this.computedAccuracy.value, 16) * (1 - .003 * Math.pow(this.difficultyAttributes.drainRate, 2));
|
|
3505
|
+
else if (this.mods.has(_rian8337_osu_base.ModTraceable)) aimValue *= 1 + this.calculateTraceableBonus(this.difficultyAttributes.sliderFactor);
|
|
3506
|
+
aimValue *= this.computedAccuracy.value;
|
|
3507
|
+
return aimValue;
|
|
3508
|
+
}
|
|
3509
|
+
/**
|
|
3510
|
+
* Calculates the speed performance value of the beatmap.
|
|
3511
|
+
*/
|
|
3512
|
+
calculateSpeedValue() {
|
|
3513
|
+
if (this.mods.has(_rian8337_osu_base.ModRelax) || this.speedDeviation === Number.POSITIVE_INFINITY) return 0;
|
|
3514
|
+
let speedValue = OsuSpeed.difficultyToPerformance(this.difficultyAttributes.speedDifficulty);
|
|
3515
|
+
if (this._effectiveMissCount > 0) {
|
|
3516
|
+
const speedEstimatedSliderBreaks = this.calculateEstimatedSliderBreaks(this.difficultyAttributes.speedTopWeightedSliderFactor);
|
|
3517
|
+
const relevantMissCount = Math.min(this._effectiveMissCount + speedEstimatedSliderBreaks, this.totalImperfectHits + this.sliderTicksMissed);
|
|
3518
|
+
speedValue *= this.calculateMissPenalty(relevantMissCount, this.difficultyAttributes.speedDifficultStrainCount);
|
|
3519
|
+
}
|
|
3520
|
+
if (this.mods.has(_rian8337_osu_base.ModBlinds)) speedValue *= 1.12;
|
|
3521
|
+
speedValue *= this.calculateSpeedHighDeviationNerf();
|
|
3522
|
+
const effectiveHitWindow = 20 * Math.pow(4 / this.difficultyAttributes.speedDifficulty, .35);
|
|
3523
|
+
const effectiveAccuracy = _rian8337_osu_base.ErrorFunction.erf(effectiveHitWindow / this.speedDeviation);
|
|
3524
|
+
speedValue *= Math.pow(effectiveAccuracy, 2);
|
|
3525
|
+
return speedValue;
|
|
3526
|
+
}
|
|
3527
|
+
/**
|
|
3528
|
+
* Calculates the accuracy performance value of the beatmap.
|
|
3529
|
+
*/
|
|
3530
|
+
calculateAccuracyValue() {
|
|
3531
|
+
if (this.mods.has(_rian8337_osu_base.ModRelax)) return 0;
|
|
3532
|
+
const ncircles = !this.usingClassicSliderAccuracy || this.mods.has(_rian8337_osu_base.ModScoreV2) ? this.totalHits - this.difficultyAttributes.spinnerCount : this.difficultyAttributes.hitCircleCount;
|
|
3533
|
+
if (ncircles === 0) return 0;
|
|
3534
|
+
const realAccuracy = new _rian8337_osu_base.Accuracy({
|
|
3535
|
+
...this.computedAccuracy,
|
|
3536
|
+
n300: this.computedAccuracy.n300 - (this.totalHits - ncircles)
|
|
3537
|
+
});
|
|
3538
|
+
let accuracyValue = Math.pow(1.52163, this.overallDifficulty) * Math.pow(realAccuracy.n300 < 0 ? 0 : realAccuracy.value, 24) * 2.83;
|
|
3539
|
+
accuracyValue *= Math.pow(ncircles / 1e3, ncircles < 1e3 ? .3 : .1);
|
|
3540
|
+
if (this.mods.has(_rian8337_osu_base.ModBlinds)) accuracyValue *= 1.14;
|
|
3541
|
+
else if (this.mods.has(_rian8337_osu_base.ModTraceable)) accuracyValue *= 1 + .08 * _rian8337_osu_base.Interpolation.reverseLerp(this.approachRate, 11.5, 10);
|
|
3542
|
+
return accuracyValue;
|
|
3543
|
+
}
|
|
3544
|
+
/**
|
|
3545
|
+
* Calculates the flashlight performance value of the beatmap.
|
|
3546
|
+
*/
|
|
3547
|
+
calculateFlashlightValue() {
|
|
3548
|
+
if (!this.mods.has(_rian8337_osu_base.ModFlashlight)) return 0;
|
|
3549
|
+
let flashlightValue = Math.pow(this.difficultyAttributes.flashlightDifficulty, 2) * 25;
|
|
3550
|
+
flashlightValue *= Math.min(Math.pow(this.combo / this.difficultyAttributes.maxCombo, .8), 1);
|
|
3551
|
+
if (this._effectiveMissCount > 0) flashlightValue *= .97 * Math.pow(1 - Math.pow(this._effectiveMissCount / this.totalHits, .775), Math.pow(this._effectiveMissCount, .875));
|
|
3552
|
+
flashlightValue *= .5 + this.computedAccuracy.value / 2;
|
|
3553
|
+
return flashlightValue;
|
|
3554
|
+
}
|
|
3555
|
+
/**
|
|
3556
|
+
* Calculates the reading performance value of the beatmap.
|
|
3557
|
+
*/
|
|
3558
|
+
calculateReadingValue() {
|
|
3559
|
+
let readingValue = OsuReading.difficultyToPerformance(this.difficultyAttributes.readingDifficulty);
|
|
3560
|
+
if (this._effectiveMissCount > 0) {
|
|
3561
|
+
const aimEstimatedSliderBreaks = this.calculateEstimatedSliderBreaks(this.difficultyAttributes.aimTopWeightedSliderFactor);
|
|
3562
|
+
readingValue *= this.calculateMissPenalty(this._effectiveMissCount + aimEstimatedSliderBreaks, this.difficultyAttributes.readingDifficultNoteCount);
|
|
3563
|
+
}
|
|
3564
|
+
readingValue *= Math.pow(this.computedAccuracy.value, 3);
|
|
3565
|
+
return readingValue;
|
|
3566
|
+
}
|
|
3567
|
+
/**
|
|
3568
|
+
* Calculates a strain-based miss penalty.
|
|
3569
|
+
*
|
|
3570
|
+
* Strain-based miss penalty assumes that a player will miss on the hardest parts of a map,
|
|
3571
|
+
* so we use the amount of relatively difficult sections to adjust miss penalty
|
|
3572
|
+
* to make it more punishing on maps with lower amount of hard sections.
|
|
3573
|
+
*/
|
|
3574
|
+
calculateMissPenalty(missCount, difficultStrainCount) {
|
|
3575
|
+
if (missCount === 0) return 1;
|
|
3576
|
+
return .93 / (missCount / (4 * Math.log(difficultStrainCount)) + 1);
|
|
3577
|
+
}
|
|
3578
|
+
/**
|
|
3579
|
+
* Estimates a player's deviation on speed notes using {@link calculateDeviation}, assuming worst-case.
|
|
3580
|
+
*
|
|
3581
|
+
* Treats all speed notes as hit circles.
|
|
3582
|
+
*/
|
|
3583
|
+
calculateSpeedDeviation() {
|
|
3584
|
+
if (this.totalSuccessfulHits === 0) return Number.POSITIVE_INFINITY;
|
|
3585
|
+
const speedNoteCount = this.difficultyAttributes.speedNoteCount + (this.totalHits - this.difficultyAttributes.speedNoteCount) * .1;
|
|
3586
|
+
const relevantCountMiss = Math.min(this.computedAccuracy.nmiss, speedNoteCount);
|
|
3587
|
+
const relevantCountMeh = Math.min(this.computedAccuracy.n50, speedNoteCount - relevantCountMiss);
|
|
3588
|
+
const relevantCountOk = Math.min(this.computedAccuracy.n100, speedNoteCount - relevantCountMiss - relevantCountMeh);
|
|
3589
|
+
const relevantCountGreat = Math.max(0, speedNoteCount - relevantCountMiss - relevantCountMeh - relevantCountOk);
|
|
3590
|
+
return this.calculateDeviation(relevantCountGreat, relevantCountOk, relevantCountMeh);
|
|
3591
|
+
}
|
|
3592
|
+
/**
|
|
3593
|
+
* Estimates the player's tap deviation based on the OD, given number of greats, oks, mehs and misses,
|
|
3594
|
+
* assuming the player's mean hit error is 0. The estimation is consistent in that two SS scores on the
|
|
3595
|
+
* same map with the same settings will always return the same deviation.
|
|
3596
|
+
*
|
|
3597
|
+
* Misses are ignored because they are usually due to misaiming.
|
|
3598
|
+
*
|
|
3599
|
+
* Greats and oks are assumed to follow a normal distribution, whereas mehs are assumed to follow a uniform distribution.
|
|
3600
|
+
*/
|
|
3601
|
+
calculateDeviation(relevantCountGreat, relevantCountOk, relevantCountMeh) {
|
|
3602
|
+
if (relevantCountGreat + relevantCountOk + relevantCountMeh <= 0) return Number.POSITIVE_INFINITY;
|
|
3603
|
+
const { greatWindow, okWindow, mehWindow } = this;
|
|
3604
|
+
const n = Math.max(1, relevantCountGreat + relevantCountOk);
|
|
3605
|
+
const p = relevantCountGreat / n;
|
|
3606
|
+
const z = 2.32634787404;
|
|
3607
|
+
const pLowerBound = Math.min(p, (n * p + Math.pow(z, 2) / 2) / (n + Math.pow(z, 2)) - z / (n + Math.pow(z, 2)) * Math.sqrt(n * p * (1 - p) + Math.pow(z, 2) / 4));
|
|
3608
|
+
let deviation;
|
|
3609
|
+
if (pLowerBound > .01) {
|
|
3610
|
+
deviation = greatWindow / (Math.SQRT2 * _rian8337_osu_base.ErrorFunction.erfInv(pLowerBound));
|
|
3611
|
+
const okWindowTailAmount = Math.sqrt(2 / Math.PI) * okWindow * Math.exp(-.5 * Math.pow(okWindow / deviation, 2)) / (deviation * _rian8337_osu_base.ErrorFunction.erf(okWindow / (Math.SQRT2 * deviation)));
|
|
3612
|
+
deviation *= Math.sqrt(1 - okWindowTailAmount);
|
|
3613
|
+
} else deviation = okWindow / Math.sqrt(3);
|
|
3614
|
+
const mehVariance = (mehWindow * mehWindow + okWindow * mehWindow + okWindow * okWindow) / 3;
|
|
3615
|
+
deviation = Math.sqrt(((relevantCountGreat + relevantCountOk) * Math.pow(deviation, 2) + relevantCountMeh * mehVariance) / (relevantCountGreat + relevantCountOk + relevantCountMeh));
|
|
3616
|
+
return deviation;
|
|
3617
|
+
}
|
|
3618
|
+
/**
|
|
3619
|
+
* Calculates multiplier for speed to account for improper tapping based on the deviation and speed difficulty.
|
|
3620
|
+
*
|
|
3621
|
+
* [Graph](https://www.desmos.com/calculator/dmogdhzofn)
|
|
3622
|
+
*/
|
|
3623
|
+
calculateSpeedHighDeviationNerf() {
|
|
3624
|
+
if (this.speedDeviation == Number.POSITIVE_INFINITY) return 0;
|
|
3625
|
+
const speedValue = OsuSpeed.difficultyToPerformance(this.difficultyAttributes.speedDifficulty);
|
|
3626
|
+
const excessSpeedDifficultyCutoff = 100 + 220 * Math.pow(22 / this.speedDeviation, 6.5);
|
|
3627
|
+
if (speedValue <= excessSpeedDifficultyCutoff) return 1;
|
|
3628
|
+
const scale = 50;
|
|
3629
|
+
const adjustedSpeedValue = scale * (Math.log((speedValue - excessSpeedDifficultyCutoff) / scale + 1) + excessSpeedDifficultyCutoff / scale);
|
|
3630
|
+
const t = 1 - _rian8337_osu_base.Interpolation.reverseLerp(this.speedDeviation, 22, 27);
|
|
3631
|
+
return _rian8337_osu_base.Interpolation.lerp(adjustedSpeedValue, speedValue, t) / speedValue;
|
|
3632
|
+
}
|
|
3633
|
+
calculateEstimatedSliderBreaks(topWeightedSliderFactor) {
|
|
3634
|
+
const nonMissMistakes = this.computedAccuracy.n100 + this.computedAccuracy.n50;
|
|
3635
|
+
if (!this.usingClassicSliderAccuracy || nonMissMistakes === 0) return 0;
|
|
3636
|
+
const missedComboPercent = 1 - this.combo / this.difficultyAttributes.maxCombo;
|
|
3637
|
+
let estimatedSliderBreaks = Math.min(nonMissMistakes, this._effectiveMissCount * topWeightedSliderFactor);
|
|
3638
|
+
const nonMissMistakeAdjustment = (nonMissMistakes - estimatedSliderBreaks + 4.5) / (nonMissMistakes + 4);
|
|
3639
|
+
estimatedSliderBreaks *= _rian8337_osu_base.MathUtils.smoothstep(this._effectiveMissCount, 1, 2);
|
|
3640
|
+
return estimatedSliderBreaks * nonMissMistakeAdjustment * _rian8337_osu_base.MathUtils.offsetLogistic(missedComboPercent, .33, 15);
|
|
3641
|
+
}
|
|
3642
|
+
/**
|
|
3643
|
+
* Calculates the amount of misses + sliderbreaks from combo.
|
|
3644
|
+
*/
|
|
3645
|
+
calculateComboBasedEstimatedMissCount() {
|
|
3646
|
+
let missCount = this.computedAccuracy.nmiss;
|
|
3647
|
+
const { combo } = this;
|
|
3648
|
+
const { aimTopWeightedSliderFactor, sliderCount, maxCombo } = this.difficultyAttributes;
|
|
3649
|
+
if (sliderCount <= 0) return missCount;
|
|
3650
|
+
if (this.usingClassicSliderAccuracy) {
|
|
3651
|
+
const likelyMissedSliderendPortion = .04 + .06 * Math.pow(Math.min(aimTopWeightedSliderFactor, 1), 2);
|
|
3652
|
+
const fullComboThreshold = maxCombo - Math.min(4 + likelyMissedSliderendPortion * sliderCount, sliderCount);
|
|
3653
|
+
if (combo < fullComboThreshold) missCount = fullComboThreshold / Math.max(1, combo);
|
|
3654
|
+
missCount = Math.min(missCount, this.totalImperfectHits);
|
|
3655
|
+
const maxPossibleSliderBreaks = Math.min(sliderCount, (maxCombo - combo) / 2);
|
|
3656
|
+
if (missCount - this.computedAccuracy.nmiss > maxPossibleSliderBreaks) missCount = this.computedAccuracy.nmiss + maxPossibleSliderBreaks;
|
|
3657
|
+
} else {
|
|
3658
|
+
const fullComboThreshold = maxCombo - this.sliderEndsDropped;
|
|
3659
|
+
if (combo < fullComboThreshold) missCount = fullComboThreshold / Math.max(1, combo);
|
|
3660
|
+
missCount = Math.min(missCount, this.sliderTicksMissed + this.computedAccuracy.nmiss);
|
|
3661
|
+
}
|
|
3662
|
+
return missCount;
|
|
3663
|
+
}
|
|
3664
|
+
calculateTraceableBonus(sliderFactor = 1) {
|
|
3665
|
+
const highApproachRateSliderVisibilityFactor = .5 + Math.pow(sliderFactor, 6) / 2;
|
|
3666
|
+
const lowApproachRateSliderVisibilityFactor = Math.pow(sliderFactor, 6);
|
|
3667
|
+
let traceableBonus = .0275;
|
|
3668
|
+
traceableBonus += .025 * (12 - Math.max(this.approachRate, 7)) * highApproachRateSliderVisibilityFactor;
|
|
3669
|
+
if (this.approachRate < 7) traceableBonus += .025 * (7 - Math.max(this.approachRate, 0)) * lowApproachRateSliderVisibilityFactor;
|
|
3670
|
+
if (this.approachRate < 0) traceableBonus += .025 * (1 - Math.pow(1.5, this.approachRate)) * lowApproachRateSliderVisibilityFactor;
|
|
3671
|
+
return traceableBonus;
|
|
3672
|
+
}
|
|
3673
|
+
calculateRateAdjustedApproachRate(approachRate, clockRate) {
|
|
3674
|
+
const preempt = _rian8337_osu_base.BeatmapDifficulty.difficultyRange(approachRate, _rian8337_osu_base.HitObject.preemptMax, _rian8337_osu_base.HitObject.preemptMid, _rian8337_osu_base.HitObject.preemptMin) / clockRate;
|
|
3675
|
+
return _rian8337_osu_base.BeatmapDifficulty.inverseDifficultyRange(preempt, _rian8337_osu_base.HitObject.preemptMax, _rian8337_osu_base.HitObject.preemptMid, _rian8337_osu_base.HitObject.preemptMin);
|
|
3676
|
+
}
|
|
3677
|
+
};
|
|
3678
|
+
// src/preprocessing/OsuDifficultyHitObject.ts
|
|
3679
|
+
/**
|
|
3680
|
+
* Represents an osu!standard hit object with difficulty calculation values.
|
|
3681
|
+
*/
|
|
3682
|
+
var OsuDifficultyHitObject = class extends DifficultyHitObject {
|
|
3683
|
+
/**
|
|
3684
|
+
* The speed strain generated by the hitobject.
|
|
3685
|
+
*/
|
|
3686
|
+
speedStrain = 0;
|
|
3687
|
+
normalizedRadius = 50;
|
|
3688
|
+
get smallCircleBonus() {
|
|
3689
|
+
return Math.max(1, 1 + (30 - this.object.radius) / 70);
|
|
3690
|
+
}
|
|
3691
|
+
get overallDifficulty() {
|
|
3692
|
+
return (79.5 - this.hitWindowFor(_rian8337_osu_base.HitResult.Great) / 2) / 6;
|
|
3693
|
+
}
|
|
3694
|
+
mode = _rian8337_osu_base.Modes.Osu;
|
|
3695
|
+
};
|
|
3696
|
+
// src/skills/osu/OsuSkill.ts
|
|
3697
|
+
/**
|
|
3698
|
+
* Used to processes strain values of difficulty hitobjects, keep track of strain levels caused by the processed objects
|
|
3699
|
+
* and to calculate a final difficulty value representing the difficulty of hitting all the processed objects.
|
|
3700
|
+
*/
|
|
3701
|
+
var OsuSkill = class extends StrainSkill {
|
|
3702
|
+
difficulty = 0;
|
|
3703
|
+
difficultyValue() {
|
|
3704
|
+
const strains = this.currentStrainPeaks.slice().sort((a, b) => b - a);
|
|
3705
|
+
if (this.reducedSectionCount > 0) {
|
|
3706
|
+
for (let i = 0; i < Math.min(strains.length, this.reducedSectionCount); ++i) {
|
|
3707
|
+
const scale = Math.log10(_rian8337_osu_base.Interpolation.lerp(1, 10, _rian8337_osu_base.MathUtils.clamp(i / this.reducedSectionCount, 0, 1)));
|
|
3708
|
+
strains[i] *= _rian8337_osu_base.Interpolation.lerp(this.reducedSectionBaseline, 1, scale);
|
|
3709
|
+
}
|
|
3710
|
+
strains.sort((a, b) => b - a);
|
|
3711
|
+
}
|
|
3712
|
+
this.difficulty = 0;
|
|
3713
|
+
let weight = 1;
|
|
3714
|
+
for (const strain of strains) {
|
|
3715
|
+
const addition = strain * weight;
|
|
3716
|
+
if (this.difficulty + addition === this.difficulty) break;
|
|
3717
|
+
this.difficulty += addition;
|
|
3718
|
+
weight *= this.decayWeight;
|
|
3719
|
+
}
|
|
3720
|
+
return this.difficulty;
|
|
3721
|
+
}
|
|
3722
|
+
};
|
|
3723
|
+
// src/skills/osu/OsuFlashlight.ts
|
|
3724
|
+
/**
|
|
3725
|
+
* Represents the skill required to memorize and hit every object in a beatmap with the Flashlight mod enabled.
|
|
3726
|
+
*/
|
|
3727
|
+
var OsuFlashlight = class extends OsuSkill {
|
|
3728
|
+
totalObjects;
|
|
3729
|
+
reducedSectionCount = 0;
|
|
3730
|
+
reducedSectionBaseline = 1;
|
|
3731
|
+
decayWeight = 1;
|
|
3732
|
+
currentFlashlightStrain = 0;
|
|
3733
|
+
skillMultiplier = .058;
|
|
3734
|
+
static difficultyToPerformance(difficulty) {
|
|
3735
|
+
return Math.pow(difficulty, 2) * 25;
|
|
3736
|
+
}
|
|
3737
|
+
constructor(mods, totalObjects) {
|
|
3738
|
+
super(mods);
|
|
3739
|
+
this.totalObjects = totalObjects;
|
|
3740
|
+
}
|
|
3741
|
+
difficultyValue() {
|
|
3742
|
+
let sum = this.currentStrainPeaks.reduce((a, b) => a + b, 0);
|
|
3743
|
+
sum *= .7 + .1 * Math.min(1, this.totalObjects / 200) + (this.totalObjects > 200 ? .2 * Math.min(1, (this.totalObjects - 200) / 200) : 0);
|
|
3744
|
+
return sum;
|
|
3745
|
+
}
|
|
3746
|
+
strainValueAt(current) {
|
|
3747
|
+
if (!this.mods.has(_rian8337_osu_base.ModFlashlight)) return 0;
|
|
3748
|
+
this.currentFlashlightStrain *= this.strainDecay(current.deltaTime);
|
|
3749
|
+
this.currentFlashlightStrain += this.calculateAdjustedDifficulty(current) * this.skillMultiplier;
|
|
3750
|
+
return this.currentFlashlightStrain;
|
|
3751
|
+
}
|
|
3752
|
+
calculateInitialStrain(time, current) {
|
|
3753
|
+
return this.currentFlashlightStrain * this.strainDecay(time - (current.previous(0)?.startTime ?? 0));
|
|
3754
|
+
}
|
|
3755
|
+
saveToHitObject(current) {
|
|
3756
|
+
current.flashlightStrain = this.currentFlashlightStrain;
|
|
3757
|
+
}
|
|
3758
|
+
calculateAdjustedDifficulty(current) {
|
|
3759
|
+
let difficulty = OsuFlashlightEvaluator.evaluateDifficultyOf(current, this.mods);
|
|
3760
|
+
if (this.mods.has(_rian8337_osu_base.ModTouchDevice)) difficulty = Math.pow(difficulty, .9);
|
|
3761
|
+
if (this.mods.has(_rian8337_osu_base.ModMagnetised)) {
|
|
3762
|
+
const magnetisedStrength = this.mods.get(_rian8337_osu_base.ModMagnetised).attractionStrength.value;
|
|
3763
|
+
difficulty *= 1 - magnetisedStrength;
|
|
3764
|
+
}
|
|
3765
|
+
if (this.mods.has(_rian8337_osu_base.ModDeflate)) {
|
|
3766
|
+
const deflateInitialScale = this.mods.get(_rian8337_osu_base.ModDeflate).startScale.value;
|
|
3767
|
+
difficulty *= _rian8337_osu_base.MathUtils.clamp(_rian8337_osu_base.Interpolation.reverseLerp(deflateInitialScale, 11, 1), .1, 1);
|
|
3768
|
+
}
|
|
3769
|
+
if (this.mods.has(_rian8337_osu_base.ModRelax)) difficulty *= .7;
|
|
3770
|
+
else if (this.mods.has(_rian8337_osu_base.ModAutopilot)) difficulty *= .4;
|
|
3771
|
+
difficulty *= .985 + Math.pow(Math.max(0, current.overallDifficulty), 2) / 4e3;
|
|
3772
|
+
return difficulty;
|
|
3773
|
+
}
|
|
3774
|
+
strainDecay(ms) {
|
|
3775
|
+
return Math.pow(.15, ms / 1e3);
|
|
3776
|
+
}
|
|
3777
|
+
};
|
|
3778
|
+
// src/structures/OsuDifficultyAttributes.ts
|
|
3779
|
+
/**
|
|
3780
|
+
* Holds data that can be used to calculate osu!standard performance points.
|
|
3781
|
+
*/
|
|
3782
|
+
var OsuDifficultyAttributes = class extends DifficultyAttributes {
|
|
3783
|
+
approachRate = 0;
|
|
3784
|
+
drainRate = 0;
|
|
3785
|
+
speedDifficulty = 0;
|
|
3786
|
+
speedDifficultStrainCount = 0;
|
|
3787
|
+
speedTopWeightedSliderFactor = 0;
|
|
3788
|
+
constructor(cacheableAttributes) {
|
|
3789
|
+
super(cacheableAttributes);
|
|
3790
|
+
if (!cacheableAttributes) return;
|
|
3791
|
+
this.approachRate = cacheableAttributes.approachRate;
|
|
3792
|
+
this.drainRate = cacheableAttributes.drainRate;
|
|
3793
|
+
this.speedDifficulty = cacheableAttributes.speedDifficulty;
|
|
3794
|
+
this.speedDifficultStrainCount = cacheableAttributes.speedDifficultStrainCount;
|
|
3795
|
+
this.speedTopWeightedSliderFactor = cacheableAttributes.speedTopWeightedSliderFactor;
|
|
3796
|
+
}
|
|
3797
|
+
toString() {
|
|
3798
|
+
return super.toString() + ` (${this.aimDifficulty.toFixed(2)} aim, ${this.speedDifficulty.toFixed(2)} speed, ${this.flashlightDifficulty.toFixed(2)} flashlight, ${this.readingDifficulty.toFixed(2)} reading)`;
|
|
3799
|
+
}
|
|
3800
|
+
};
|
|
3801
|
+
// src/OsuDifficultyCalculator.ts
|
|
3802
|
+
/**
|
|
3803
|
+
* A difficulty calculator for osu!standard gamemode.
|
|
3804
|
+
*/
|
|
3805
|
+
var OsuDifficultyCalculator = class OsuDifficultyCalculator extends DifficultyCalculator {
|
|
3806
|
+
constructor() {
|
|
3807
|
+
super();
|
|
3808
|
+
this.difficultyAdjustmentMods.push(_rian8337_osu_base.ModTouchDevice, _rian8337_osu_base.ModBlinds);
|
|
3809
|
+
}
|
|
3810
|
+
retainDifficultyAdjustmentMods(mods) {
|
|
3811
|
+
return mods.filter((mod) => mod.isApplicableToOsu() && mod.isOsuRelevant && this.difficultyAdjustmentMods.some((m) => mod instanceof m));
|
|
3812
|
+
}
|
|
3813
|
+
createDifficultyAttributes(beatmap, playableBeatmap, skills) {
|
|
3814
|
+
const attributes = new OsuDifficultyAttributes();
|
|
3815
|
+
if (playableBeatmap.hitObjects.objects.length === 0) return attributes;
|
|
3816
|
+
attributes.mods = playableBeatmap.mods;
|
|
3817
|
+
attributes.maxCombo = playableBeatmap.maxCombo;
|
|
3818
|
+
attributes.clockRate = playableBeatmap.speedMultiplier;
|
|
3819
|
+
attributes.hitCircleCount = playableBeatmap.hitObjects.circles;
|
|
3820
|
+
attributes.sliderCount = playableBeatmap.hitObjects.sliders;
|
|
3821
|
+
attributes.spinnerCount = playableBeatmap.hitObjects.spinners;
|
|
3822
|
+
attributes.approachRate = playableBeatmap.difficulty.ar;
|
|
3823
|
+
attributes.overallDifficulty = playableBeatmap.difficulty.od;
|
|
3824
|
+
attributes.drainRate = playableBeatmap.difficulty.hp;
|
|
3825
|
+
const aim = skills.find((s) => s instanceof OsuAim && s.withSliders);
|
|
3826
|
+
const aimNoSlider = skills.find((s) => s instanceof OsuAim && !s.withSliders);
|
|
3827
|
+
const speed = skills.find((s) => s instanceof OsuSpeed);
|
|
3828
|
+
const flashlight = skills.find((s) => s instanceof OsuFlashlight);
|
|
3829
|
+
const reading = skills.find((s) => s instanceof OsuReading);
|
|
3830
|
+
const aimDifficultyValue = aim?.difficultyValue() ?? 0;
|
|
3831
|
+
const aimNoSliderDifficultyValue = aimNoSlider?.difficultyValue() ?? 0;
|
|
3832
|
+
attributes.aimDifficultSliderCount = aim?.countDifficultSliders() ?? 0;
|
|
3833
|
+
attributes.aimDifficultStrainCount = aim?.countTopWeightedStrains(aimDifficultyValue) ?? 0;
|
|
3834
|
+
attributes.sliderFactor = aimDifficultyValue > 0 ? this.calculateAimDifficultyRating(aimNoSliderDifficultyValue) / this.calculateAimDifficultyRating(aimDifficultyValue) : 1;
|
|
3835
|
+
const aimNoSliderTopWeightedSliderCount = aimNoSlider?.countTopWeightedSliders(aimNoSliderDifficultyValue) ?? 0;
|
|
3836
|
+
const aimNoSliderDifficultStrainCount = aimNoSlider?.countTopWeightedStrains(aimNoSliderDifficultyValue) ?? 0;
|
|
3837
|
+
attributes.aimTopWeightedSliderFactor = aimNoSliderTopWeightedSliderCount / Math.max(1, aimNoSliderDifficultStrainCount - aimNoSliderTopWeightedSliderCount);
|
|
3838
|
+
const speedDifficultyValue = speed?.difficultyValue() ?? 0;
|
|
3839
|
+
attributes.speedNoteCount = speed?.relevantNoteCount() ?? 0;
|
|
3840
|
+
attributes.speedDifficultStrainCount = speed?.countTopWeightedObjectDifficulties(speedDifficultyValue) ?? 0;
|
|
3841
|
+
const speedTopWeightedSliderCount = speed?.countTopWeightedSliders(speedDifficultyValue) ?? 0;
|
|
3842
|
+
attributes.speedTopWeightedSliderFactor = speedTopWeightedSliderCount / Math.max(1, attributes.speedDifficultStrainCount - speedTopWeightedSliderCount);
|
|
3843
|
+
const readingDifficultyValue = reading?.difficultyValue() ?? 0;
|
|
3844
|
+
attributes.readingDifficultNoteCount = reading?.countTopWeightedObjectDifficulties(readingDifficultyValue) ?? 0;
|
|
3845
|
+
attributes.aimDifficulty = this.calculateAimDifficultyRating(aimDifficultyValue);
|
|
3846
|
+
attributes.speedDifficulty = this.calculateDifficultyRating(speedDifficultyValue);
|
|
3847
|
+
attributes.flashlightDifficulty = this.calculateDifficultyRating(flashlight?.difficultyValue() ?? 0);
|
|
3848
|
+
attributes.readingDifficulty = this.calculateDifficultyRating(readingDifficultyValue);
|
|
3849
|
+
const baseAimPerformance = OsuAim.difficultyToPerformance(attributes.aimDifficulty);
|
|
3850
|
+
const baseSpeedPerformance = OsuSpeed.difficultyToPerformance(attributes.speedDifficulty);
|
|
3851
|
+
const baseFlashlightPerformance = OsuFlashlight.difficultyToPerformance(attributes.flashlightDifficulty);
|
|
3852
|
+
const baseReadingPerformance = OsuReading.difficultyToPerformance(attributes.readingDifficulty);
|
|
3853
|
+
const baseCognitionPerformance = OsuDifficultyCalculator.sumCognitionDifficulty(baseReadingPerformance, baseFlashlightPerformance);
|
|
3854
|
+
const basePerformance = _rian8337_osu_base.MathUtils.norm(OsuPerformanceCalculator.normExponent, baseAimPerformance, baseSpeedPerformance, baseCognitionPerformance);
|
|
3855
|
+
attributes.starRating = this.calculateStarRating(basePerformance);
|
|
3856
|
+
return attributes;
|
|
3857
|
+
}
|
|
3858
|
+
createPlayableBeatmap(beatmap, mods) {
|
|
3859
|
+
return beatmap.createOsuPlayableBeatmap(mods);
|
|
3860
|
+
}
|
|
3861
|
+
createDifficultyHitObjects(beatmap) {
|
|
3862
|
+
const clockRate = beatmap.speedMultiplier;
|
|
3863
|
+
const difficultyObjects = [];
|
|
3864
|
+
const { objects } = beatmap.hitObjects;
|
|
3865
|
+
for (let i = 1; i < objects.length; ++i) {
|
|
3866
|
+
const difficultyObject = new OsuDifficultyHitObject(objects[i], objects[i - 1], difficultyObjects, clockRate, i - 1);
|
|
3867
|
+
difficultyObject.computeProperties(clockRate);
|
|
3868
|
+
difficultyObjects.push(difficultyObject);
|
|
3869
|
+
}
|
|
3870
|
+
return difficultyObjects;
|
|
3871
|
+
}
|
|
3872
|
+
createSkills(beatmap) {
|
|
3873
|
+
const { mods } = beatmap;
|
|
3874
|
+
const skills = [];
|
|
3875
|
+
if (!mods.has(_rian8337_osu_base.ModAutopilot)) {
|
|
3876
|
+
skills.push(new OsuAim(mods, true));
|
|
3877
|
+
skills.push(new OsuAim(mods, false));
|
|
3878
|
+
}
|
|
3879
|
+
if (!mods.has(_rian8337_osu_base.ModRelax)) skills.push(new OsuSpeed(mods));
|
|
3880
|
+
skills.push(new OsuReading(mods, beatmap.speedMultiplier, beatmap.hitObjects.objects));
|
|
3881
|
+
if (mods.has(_rian8337_osu_base.ModFlashlight)) skills.push(new OsuFlashlight(mods, beatmap.hitObjects.objects.length));
|
|
3882
|
+
return skills;
|
|
3883
|
+
}
|
|
3884
|
+
createStrainPeakSkills(beatmap) {
|
|
3885
|
+
const { mods } = beatmap;
|
|
3886
|
+
return [
|
|
3887
|
+
new OsuAim(mods, true),
|
|
3888
|
+
new OsuAim(mods, false),
|
|
3889
|
+
new OsuSpeed(mods),
|
|
3890
|
+
new OsuFlashlight(mods, beatmap.hitObjects.objects.length)
|
|
3891
|
+
];
|
|
3892
|
+
}
|
|
3893
|
+
calculateAimDifficultyRating(difficultyValue) {
|
|
3894
|
+
return Math.pow(difficultyValue, .63) * .02275;
|
|
3895
|
+
}
|
|
3896
|
+
calculateDifficultyRating(difficultyValue) {
|
|
3897
|
+
return Math.sqrt(difficultyValue) * .0675;
|
|
3898
|
+
}
|
|
3899
|
+
calculateStarRating(basePerformance) {
|
|
3900
|
+
return Math.cbrt(basePerformance * OsuPerformanceCalculator.finalMultiplier);
|
|
3901
|
+
}
|
|
3902
|
+
static sumCognitionDifficulty(reading, flashlight) {
|
|
3903
|
+
if (reading <= 0) return flashlight;
|
|
3904
|
+
if (flashlight <= 0) return reading;
|
|
3905
|
+
return _rian8337_osu_base.MathUtils.norm(OsuPerformanceCalculator.normExponent, reading, flashlight * _rian8337_osu_base.MathUtils.clamp(flashlight / reading, .25, 1));
|
|
3906
|
+
}
|
|
3907
|
+
};
|
|
3908
|
+
exports.DifficultyAttributes = DifficultyAttributes;
|
|
3909
|
+
exports.DifficultyCalculator = DifficultyCalculator;
|
|
3910
|
+
exports.DifficultyHitObject = DifficultyHitObject;
|
|
3911
|
+
exports.DroidAgilityEvaluator = DroidAgilityEvaluator;
|
|
3912
|
+
exports.DroidAim = DroidAim;
|
|
3913
|
+
exports.DroidDifficultyAttributes = DroidDifficultyAttributes;
|
|
3914
|
+
exports.DroidDifficultyCalculator = DroidDifficultyCalculator;
|
|
3915
|
+
exports.DroidDifficultyHitObject = DroidDifficultyHitObject;
|
|
3916
|
+
exports.DroidFlashlight = DroidFlashlight;
|
|
3917
|
+
exports.DroidFlashlightEvaluator = DroidFlashlightEvaluator;
|
|
3918
|
+
exports.DroidFlowAimEvaluator = DroidFlowAimEvaluator;
|
|
3919
|
+
exports.DroidPerformanceCalculator = DroidPerformanceCalculator;
|
|
3920
|
+
exports.DroidReading = DroidReading;
|
|
3921
|
+
exports.DroidReadingEvaluator = DroidReadingEvaluator;
|
|
3922
|
+
exports.DroidRhythm = DroidRhythm;
|
|
3923
|
+
exports.DroidRhythmEvaluator = DroidRhythmEvaluator;
|
|
3924
|
+
exports.DroidSnapAimEvaluator = DroidSnapAimEvaluator;
|
|
3925
|
+
exports.DroidTap = DroidTap;
|
|
3926
|
+
exports.DroidTapEvaluator = DroidTapEvaluator;
|
|
3927
|
+
exports.ExtendedDroidDifficultyAttributes = ExtendedDroidDifficultyAttributes;
|
|
3928
|
+
exports.OsuAgilityEvaluator = OsuAgilityEvaluator;
|
|
3929
|
+
exports.OsuAim = OsuAim;
|
|
3930
|
+
exports.OsuDifficultyAttributes = OsuDifficultyAttributes;
|
|
3931
|
+
exports.OsuDifficultyCalculator = OsuDifficultyCalculator;
|
|
3932
|
+
exports.OsuDifficultyHitObject = OsuDifficultyHitObject;
|
|
3933
|
+
exports.OsuFlashlight = OsuFlashlight;
|
|
3934
|
+
exports.OsuFlashlightEvaluator = OsuFlashlightEvaluator;
|
|
3935
|
+
exports.OsuFlowAimEvaluator = OsuFlowAimEvaluator;
|
|
3936
|
+
exports.OsuPerformanceCalculator = OsuPerformanceCalculator;
|
|
3937
|
+
exports.OsuReading = OsuReading;
|
|
3938
|
+
exports.OsuReadingEvaluator = OsuReadingEvaluator;
|
|
3939
|
+
exports.OsuRhythmEvaluator = OsuRhythmEvaluator;
|
|
3940
|
+
exports.OsuSnapAimEvaluator = OsuSnapAimEvaluator;
|
|
3941
|
+
exports.OsuSpeed = OsuSpeed;
|
|
3942
|
+
exports.OsuSpeedEvaluator = OsuSpeedEvaluator;
|
|
3943
|
+
exports.PerformanceCalculator = PerformanceCalculator;
|
|
3944
|
+
|
|
3945
|
+
//# sourceMappingURL=index.cjs.map
|