@rian8337/osu-rebalance-difficulty-calculator 2.0.0-alpha.29 → 2.0.0-alpha.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +683 -425
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/typings/index.d.ts +288 -102
package/dist/index.js
CHANGED
|
@@ -4,6 +4,32 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var osuBase = require('@rian8337/osu-base');
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* An evaluator for calculating aim skill.
|
|
9
|
+
*
|
|
10
|
+
* This class should be considered an "evaluating" class and not persisted.
|
|
11
|
+
*/
|
|
12
|
+
class AimEvaluator {
|
|
13
|
+
static wideAngleMultiplier = 1.5;
|
|
14
|
+
static acuteAngleMultiplier = 2;
|
|
15
|
+
static sliderMultiplier = 1.5;
|
|
16
|
+
static velocityChangeMultiplier = 0.75;
|
|
17
|
+
/**
|
|
18
|
+
* Calculates the bonus of wide angles.
|
|
19
|
+
*/
|
|
20
|
+
static calculateWideAngleBonus(angle) {
|
|
21
|
+
return Math.pow(Math.sin((3 / 4) *
|
|
22
|
+
(Math.min((5 / 6) * Math.PI, Math.max(Math.PI / 6, angle)) -
|
|
23
|
+
Math.PI / 6)), 2);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Calculates the bonus of acute angles.
|
|
27
|
+
*/
|
|
28
|
+
static calculateAcuteAngleBonus(angle) {
|
|
29
|
+
return 1 - this.calculateWideAngleBonus(angle);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
7
33
|
/**
|
|
8
34
|
* Represents an osu!standard hit object with difficulty calculation values.
|
|
9
35
|
*/
|
|
@@ -12,6 +38,20 @@ class DifficultyHitObject {
|
|
|
12
38
|
* The underlying hitobject.
|
|
13
39
|
*/
|
|
14
40
|
object;
|
|
41
|
+
/**
|
|
42
|
+
* The index of this hitobject in the list of all hitobjects.
|
|
43
|
+
*
|
|
44
|
+
* This is one less than the actual index of the hitobject in the beatmap.
|
|
45
|
+
*/
|
|
46
|
+
index = 0;
|
|
47
|
+
/**
|
|
48
|
+
* The preempt time of the hitobject.
|
|
49
|
+
*/
|
|
50
|
+
timePreempt = 600;
|
|
51
|
+
/**
|
|
52
|
+
* The fade in time of the hitobject.
|
|
53
|
+
*/
|
|
54
|
+
timeFadeIn = 450;
|
|
15
55
|
/**
|
|
16
56
|
* The aim strain generated by the hitobject if sliders are considered.
|
|
17
57
|
*/
|
|
@@ -103,7 +143,7 @@ class DifficultyHitObject {
|
|
|
103
143
|
/**
|
|
104
144
|
* The note density of the hitobject.
|
|
105
145
|
*/
|
|
106
|
-
noteDensity =
|
|
146
|
+
noteDensity = 1;
|
|
107
147
|
/**
|
|
108
148
|
* The overlapping factor of the hitobject.
|
|
109
149
|
*
|
|
@@ -114,11 +154,64 @@ class DifficultyHitObject {
|
|
|
114
154
|
* Adjusted velocity of the hitobject, taking speed multiplier into account.
|
|
115
155
|
*/
|
|
116
156
|
velocity = 0;
|
|
157
|
+
hitObjects;
|
|
117
158
|
/**
|
|
118
159
|
* @param object The underlying hitobject.
|
|
160
|
+
* @param hitObjects All difficulty hitobjects in the processed beatmap.
|
|
119
161
|
*/
|
|
120
|
-
constructor(object) {
|
|
162
|
+
constructor(object, hitObjects) {
|
|
121
163
|
this.object = object;
|
|
164
|
+
this.hitObjects = hitObjects;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Gets the difficulty hitobject at a specific index with respect to the current
|
|
168
|
+
* difficulty hitobject's index.
|
|
169
|
+
*
|
|
170
|
+
* Will return `null` if the index is out of range.
|
|
171
|
+
*
|
|
172
|
+
* @param backwardsIndex The index to move backwards for.
|
|
173
|
+
* @returns The difficulty hitobject at the index with respect to the current
|
|
174
|
+
* difficulty hitobject's index, `null` if the index is out of range.
|
|
175
|
+
*/
|
|
176
|
+
previous(backwardsIndex) {
|
|
177
|
+
return this.hitObjects[this.index - backwardsIndex] ?? null;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Gets the difficulty hitobject at a specific index with respect to the current
|
|
181
|
+
* difficulty hitobject's index.
|
|
182
|
+
*
|
|
183
|
+
* Will return `null` if the index is out of range.
|
|
184
|
+
*
|
|
185
|
+
* @param forwardsIndex The index to move forwards for.
|
|
186
|
+
* @returns The difficulty hitobject at the index with respect to the current
|
|
187
|
+
* difficulty hitobject's index, `null` if the index is out of range.
|
|
188
|
+
*/
|
|
189
|
+
next(forwardsIndex) {
|
|
190
|
+
return this.hitObjects[this.index + forwardsIndex + 2] ?? null;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Calculates the opacity of the hitobject at a given time.
|
|
194
|
+
*
|
|
195
|
+
* @param time The time to calculate the hitobject's opacity at.
|
|
196
|
+
* @param isHidden Whether Hidden mod is used.
|
|
197
|
+
* @returns The opacity of the hitobject at the given time.
|
|
198
|
+
*/
|
|
199
|
+
opacityAt(time, isHidden) {
|
|
200
|
+
if (time > this.object.startTime) {
|
|
201
|
+
// Consider a hitobject as being invisible when its start time is passed.
|
|
202
|
+
// In reality the hitobject will be visible beyond its start time up until its hittable window has passed,
|
|
203
|
+
// but this is an approximation and such a case is unlikely to be hit where this function is used.
|
|
204
|
+
return 0;
|
|
205
|
+
}
|
|
206
|
+
const fadeInStartTime = this.object.startTime - this.timePreempt;
|
|
207
|
+
const fadeInDuration = this.timeFadeIn;
|
|
208
|
+
if (isHidden) {
|
|
209
|
+
const fadeOutStartTime = fadeInStartTime + fadeInDuration;
|
|
210
|
+
const fadeOutDuration = this.timePreempt * osuBase.ModHidden.fadeOutDurationMultiplier;
|
|
211
|
+
return Math.min(osuBase.MathUtils.clamp((time - fadeInStartTime) / fadeInDuration, 0, 1), 1 -
|
|
212
|
+
osuBase.MathUtils.clamp((time - fadeOutStartTime) / fadeOutDuration, 0, 1));
|
|
213
|
+
}
|
|
214
|
+
return osuBase.MathUtils.clamp((time - fadeInStartTime) / fadeInDuration, 0, 1);
|
|
122
215
|
}
|
|
123
216
|
}
|
|
124
217
|
|
|
@@ -157,8 +250,21 @@ class DifficultyHitObjectCreator {
|
|
|
157
250
|
const scalingFactor = this.getScalingFactor(params.objects[0].radius);
|
|
158
251
|
const difficultyObjects = [];
|
|
159
252
|
for (let i = 0; i < params.objects.length; ++i) {
|
|
160
|
-
const object = new DifficultyHitObject(params.objects[i]);
|
|
253
|
+
const object = new DifficultyHitObject(params.objects[i], difficultyObjects);
|
|
254
|
+
object.index = difficultyObjects.length - 1;
|
|
161
255
|
object.object.scale = scale;
|
|
256
|
+
object.timePreempt = params.preempt;
|
|
257
|
+
// Preempt time can go below 450ms. Normally, this is achieved via the DT mod or a
|
|
258
|
+
// custom speed multiplier which uniformly speeds up all animations game wide regardless of AR.
|
|
259
|
+
//
|
|
260
|
+
// This uniform speedup is hard to match 1:1, however we can at least make AR>10 (via mods)
|
|
261
|
+
// feel good by extending the upper linear function above.
|
|
262
|
+
//
|
|
263
|
+
// Note that this doesn't exactly match the AR>10 visuals as they're classically known, but it feels good.
|
|
264
|
+
// This adjustment is necessary for AR>10, otherwise timePreempt can become smaller
|
|
265
|
+
// leading to hitcircles not fully fading in.
|
|
266
|
+
object.timeFadeIn =
|
|
267
|
+
400 * Math.min(1, object.timePreempt / osuBase.MapStats.arToMS(10));
|
|
162
268
|
if (object.object instanceof osuBase.Slider) {
|
|
163
269
|
object.velocity =
|
|
164
270
|
object.object.velocity * params.speedMultiplier;
|
|
@@ -182,6 +288,11 @@ class DifficultyHitObjectCreator {
|
|
|
182
288
|
params.speedMultiplier;
|
|
183
289
|
// Cap to 25ms to prevent difficulty calculation breaking from simultaneous objects.
|
|
184
290
|
object.strainTime = Math.max(this.minDeltaTime, object.deltaTime);
|
|
291
|
+
if (object.object instanceof osuBase.Spinner ||
|
|
292
|
+
lastObject.object instanceof osuBase.Spinner) {
|
|
293
|
+
difficultyObjects.push(object);
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
185
296
|
const visibleObjects = params.objects
|
|
186
297
|
.filter((o) => o.startTime / params.speedMultiplier >=
|
|
187
298
|
object.startTime &&
|
|
@@ -189,12 +300,6 @@ class DifficultyHitObjectCreator {
|
|
|
189
300
|
object.endTime + params.preempt)
|
|
190
301
|
// The current object will be included, so we need to exclude it.
|
|
191
302
|
.slice(1);
|
|
192
|
-
object.noteDensity = 1;
|
|
193
|
-
if (object.object instanceof osuBase.Spinner ||
|
|
194
|
-
lastObject.object instanceof osuBase.Spinner) {
|
|
195
|
-
difficultyObjects.push(object);
|
|
196
|
-
continue;
|
|
197
|
-
}
|
|
198
303
|
for (const hitObject of visibleObjects) {
|
|
199
304
|
// Calculate delta time assuming the current object is a circle.
|
|
200
305
|
let deltaTime = Math.abs(hitObject.startTime / params.speedMultiplier -
|
|
@@ -284,9 +389,7 @@ class DifficultyHitObjectCreator {
|
|
|
284
389
|
if (this.mode === osuBase.modes.droid) {
|
|
285
390
|
slider.tail.startTime += osuBase.Slider.legacyLastTickOffset;
|
|
286
391
|
slider.tail.endTime += osuBase.Slider.legacyLastTickOffset;
|
|
287
|
-
slider.nestedHitObjects.sort((a, b) =>
|
|
288
|
-
return a.startTime - b.startTime;
|
|
289
|
-
});
|
|
392
|
+
slider.nestedHitObjects.sort((a, b) => a.startTime - b.startTime);
|
|
290
393
|
// Temporary lazy end position until a real result can be derived.
|
|
291
394
|
slider.lazyEndPosition = slider.stackedPosition;
|
|
292
395
|
// Stop here if the slider has too short duration due to float number limitation.
|
|
@@ -398,178 +501,54 @@ class DifficultyHitObjectCreator {
|
|
|
398
501
|
}
|
|
399
502
|
|
|
400
503
|
/**
|
|
401
|
-
*
|
|
504
|
+
* An evaluator for calculating osu!droid Aim skill.
|
|
402
505
|
*/
|
|
403
|
-
class
|
|
404
|
-
/**
|
|
405
|
-
* The hitobjects that were processed previously. They can affect the strain values of the following objects.
|
|
406
|
-
*
|
|
407
|
-
* The latest hitobject is at index 0.
|
|
408
|
-
*/
|
|
409
|
-
previous = [];
|
|
410
|
-
/**
|
|
411
|
-
* Number of previous hitobjects to keep inside the `previous` array.
|
|
412
|
-
*/
|
|
413
|
-
historyLength = 2;
|
|
414
|
-
/**
|
|
415
|
-
* The mods that this skill processes.
|
|
416
|
-
*/
|
|
417
|
-
mods;
|
|
418
|
-
constructor(mods) {
|
|
419
|
-
this.mods = mods;
|
|
420
|
-
}
|
|
421
|
-
processInternal(current) {
|
|
422
|
-
while (this.previous.length > this.historyLength) {
|
|
423
|
-
this.previous.pop();
|
|
424
|
-
}
|
|
425
|
-
this.process(current);
|
|
426
|
-
this.previous.unshift(current);
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
/**
|
|
431
|
-
* Used to processes strain values of difficulty hitobjects, keep track of strain levels caused by the processed objects
|
|
432
|
-
* and to calculate a final difficulty value representing the difficulty of hitting all the processed objects.
|
|
433
|
-
*/
|
|
434
|
-
class StrainSkill extends Skill {
|
|
435
|
-
/**
|
|
436
|
-
* The strain of currently calculated hitobject.
|
|
437
|
-
*/
|
|
438
|
-
currentStrain = 0;
|
|
439
|
-
/**
|
|
440
|
-
* The current section's strain peak.
|
|
441
|
-
*/
|
|
442
|
-
currentSectionPeak = 0;
|
|
443
|
-
/**
|
|
444
|
-
* Strain peaks are stored here.
|
|
445
|
-
*/
|
|
446
|
-
strainPeaks = [];
|
|
447
|
-
sectionLength = 400;
|
|
448
|
-
currentSectionEnd = 0;
|
|
449
|
-
process(current) {
|
|
450
|
-
// The first object doesn't generate a strain, so we begin with an incremented section end
|
|
451
|
-
if (this.previous.length === 0) {
|
|
452
|
-
this.currentSectionEnd =
|
|
453
|
-
Math.ceil(current.startTime / this.sectionLength) *
|
|
454
|
-
this.sectionLength;
|
|
455
|
-
}
|
|
456
|
-
while (current.startTime > this.currentSectionEnd) {
|
|
457
|
-
this.saveCurrentPeak();
|
|
458
|
-
this.startNewSectionFrom(this.currentSectionEnd);
|
|
459
|
-
this.currentSectionEnd += this.sectionLength;
|
|
460
|
-
}
|
|
461
|
-
this.currentStrain = this.strainValueAt(current);
|
|
462
|
-
this.saveToHitObject(current);
|
|
463
|
-
this.currentSectionPeak = Math.max(this.currentStrain, this.currentSectionPeak);
|
|
464
|
-
}
|
|
465
|
-
/**
|
|
466
|
-
* Saves the current peak strain level to the list of strain peaks, which will be used to calculate an overall difficulty.
|
|
467
|
-
*/
|
|
468
|
-
saveCurrentPeak() {
|
|
469
|
-
this.strainPeaks.push(this.currentSectionPeak);
|
|
470
|
-
}
|
|
471
|
-
/**
|
|
472
|
-
* Sets the initial strain level for a new section.
|
|
473
|
-
*
|
|
474
|
-
* @param offset The beginning of the new section in milliseconds, adjusted by speed multiplier.
|
|
475
|
-
*/
|
|
476
|
-
startNewSectionFrom(offset) {
|
|
477
|
-
// The maximum strain of the new section is not zero by default, strain decays as usual regardless of section boundaries.
|
|
478
|
-
// This means we need to capture the strain level at the beginning of the new section, and use that as the initial peak level.
|
|
479
|
-
this.currentSectionPeak =
|
|
480
|
-
this.currentStrain *
|
|
481
|
-
this.strainDecay(offset - this.previous[0].startTime);
|
|
482
|
-
}
|
|
483
|
-
/**
|
|
484
|
-
* Calculates strain decay for a specified time frame.
|
|
485
|
-
*
|
|
486
|
-
* @param ms The time frame to calculate.
|
|
487
|
-
*/
|
|
488
|
-
strainDecay(ms) {
|
|
489
|
-
return Math.pow(this.strainDecayBase, ms / 1000);
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
/**
|
|
494
|
-
* Used to processes strain values of difficulty hitobjects, keep track of strain levels caused by the processed objects
|
|
495
|
-
* and to calculate a final difficulty value representing the difficulty of hitting all the processed objects.
|
|
496
|
-
*/
|
|
497
|
-
class DroidSkill extends StrainSkill {
|
|
498
|
-
difficultyValue() {
|
|
499
|
-
const sortedStrains = this.strainPeaks
|
|
500
|
-
.slice()
|
|
501
|
-
.sort((a, b) => {
|
|
502
|
-
return b - a;
|
|
503
|
-
});
|
|
504
|
-
// We are reducing the highest strains first to account for extreme difficulty spikes.
|
|
505
|
-
for (let i = 0; i < Math.min(sortedStrains.length, this.reducedSectionCount); ++i) {
|
|
506
|
-
const scale = Math.log10(osuBase.Interpolation.lerp(1, 10, osuBase.MathUtils.clamp(i / this.reducedSectionCount, 0, 1)));
|
|
507
|
-
sortedStrains[i] *= osuBase.Interpolation.lerp(this.reducedSectionBaseline, 1, scale);
|
|
508
|
-
}
|
|
509
|
-
// Math here preserves the property that two notes of equal difficulty x, we have their summed difficulty = x * starsPerDouble.
|
|
510
|
-
// This also applies to two sets of notes with equal difficulty.
|
|
511
|
-
return Math.pow(sortedStrains.reduce((a, v) => {
|
|
512
|
-
if (v === 0) {
|
|
513
|
-
return a;
|
|
514
|
-
}
|
|
515
|
-
return a + Math.pow(v, 1 / Math.log2(this.starsPerDouble));
|
|
516
|
-
}, 0), Math.log2(this.starsPerDouble));
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
/**
|
|
521
|
-
* Represents the skill required to correctly aim at every object in the map with a uniform CircleSize and normalized distances.
|
|
522
|
-
*/
|
|
523
|
-
class DroidAim extends DroidSkill {
|
|
524
|
-
skillMultiplier = 23.25;
|
|
525
|
-
strainDecayBase = 0.15;
|
|
526
|
-
reducedSectionCount = 10;
|
|
527
|
-
reducedSectionBaseline = 0.75;
|
|
528
|
-
starsPerDouble = 1.05;
|
|
506
|
+
class DroidAimEvaluator extends AimEvaluator {
|
|
529
507
|
/**
|
|
530
508
|
* Spacing threshold for a single hitobject spacing.
|
|
531
509
|
*/
|
|
532
|
-
SINGLE_SPACING_THRESHOLD = 175;
|
|
510
|
+
static SINGLE_SPACING_THRESHOLD = 175;
|
|
533
511
|
// ~200 1/2 BPM jumps
|
|
534
|
-
minSpeedBonus = 150;
|
|
535
|
-
wideAngleMultiplier = 1.5;
|
|
536
|
-
acuteAngleMultiplier = 2;
|
|
537
|
-
sliderMultiplier = 1.5;
|
|
538
|
-
velocityChangeMultiplier = 0.75;
|
|
539
|
-
withSliders;
|
|
540
|
-
constructor(mods, withSliders) {
|
|
541
|
-
super(mods);
|
|
542
|
-
this.withSliders = withSliders;
|
|
543
|
-
}
|
|
512
|
+
static minSpeedBonus = 150;
|
|
544
513
|
/**
|
|
545
|
-
*
|
|
514
|
+
* Evaluates the difficulty of aiming the current object, based on:
|
|
515
|
+
*
|
|
516
|
+
* - cursor velocity to the current object,
|
|
517
|
+
* - angle difficulty,
|
|
518
|
+
* - sharp velocity increases,
|
|
519
|
+
* - and slider difficulty.
|
|
520
|
+
*
|
|
521
|
+
* @param current The current object.
|
|
522
|
+
* @param withSliders Whether to take slider difficulty into account.
|
|
546
523
|
*/
|
|
547
|
-
|
|
524
|
+
static evaluateDifficultyOf(current, withSliders) {
|
|
525
|
+
const last = current.previous(0);
|
|
548
526
|
if (current.object instanceof osuBase.Spinner ||
|
|
549
527
|
// Exclude overlapping objects that can be tapped at once.
|
|
550
528
|
(current.deltaTime < 5 &&
|
|
551
|
-
(
|
|
552
|
-
? Math.min(
|
|
553
|
-
:
|
|
529
|
+
((last?.object instanceof osuBase.Slider
|
|
530
|
+
? Math.min(last.object.stackedEndPosition.getDistance(current.object.stackedPosition), last.object.lazyEndPosition.getDistance(current.object.stackedPosition))
|
|
531
|
+
: last?.object.stackedEndPosition.getDistance(current.object.stackedPosition)) ?? Number.POSITIVE_INFINITY) <=
|
|
554
532
|
2 * current.object.radius)) {
|
|
555
533
|
return 0;
|
|
556
534
|
}
|
|
557
|
-
return this.aimStrainOf(current) +
|
|
535
|
+
return (this.aimStrainOf(current, withSliders) +
|
|
536
|
+
this.movementStrainOf(current));
|
|
558
537
|
}
|
|
559
538
|
/**
|
|
560
539
|
* Calculates the aim strain of a hitobject.
|
|
561
540
|
*/
|
|
562
|
-
aimStrainOf(current) {
|
|
563
|
-
if (
|
|
564
|
-
|
|
541
|
+
static aimStrainOf(current, withSliders) {
|
|
542
|
+
if (current.index <= 1 ||
|
|
543
|
+
current.previous(0)?.object instanceof osuBase.Spinner) {
|
|
565
544
|
return 0;
|
|
566
545
|
}
|
|
567
|
-
const last =
|
|
568
|
-
const lastLast =
|
|
546
|
+
const last = current.previous(0);
|
|
547
|
+
const lastLast = current.previous(1);
|
|
569
548
|
// Calculate the velocity to the current hitobject, which starts with a base distance / time assuming the last object is a hitcircle.
|
|
570
549
|
let currentVelocity = current.lazyJumpDistance / current.strainTime;
|
|
571
550
|
// But if the last object is a slider, then we extend the travel velocity through the slider into the current object.
|
|
572
|
-
if (last.object instanceof osuBase.Slider &&
|
|
551
|
+
if (last.object instanceof osuBase.Slider && withSliders) {
|
|
573
552
|
// Calculate the slider velocity from slider head to slider end.
|
|
574
553
|
const travelVelocity = last.travelDistance / last.travelTime;
|
|
575
554
|
// Calculate the movement velocity from slider end to current object.
|
|
@@ -581,7 +560,7 @@ class DroidAim extends DroidSkill {
|
|
|
581
560
|
}
|
|
582
561
|
// As above, do the same for the previous hitobject.
|
|
583
562
|
let prevVelocity = last.lazyJumpDistance / last.strainTime;
|
|
584
|
-
if (lastLast.object instanceof osuBase.Slider &&
|
|
563
|
+
if (lastLast.object instanceof osuBase.Slider && withSliders) {
|
|
585
564
|
const travelVelocity = lastLast.travelDistance / lastLast.travelTime;
|
|
586
565
|
const movementVelocity = last.minimumJumpTime !== 0
|
|
587
566
|
? last.minimumJumpDistance / last.minimumJumpTime
|
|
@@ -670,7 +649,7 @@ class DroidAim extends DroidSkill {
|
|
|
670
649
|
strain += Math.max(acuteAngleBonus * this.acuteAngleMultiplier, wideAngleBonus * this.wideAngleMultiplier +
|
|
671
650
|
velocityChangeBonus * this.velocityChangeMultiplier);
|
|
672
651
|
// Add in additional slider velocity bonus.
|
|
673
|
-
if (
|
|
652
|
+
if (withSliders) {
|
|
674
653
|
strain += sliderBonus * this.sliderMultiplier;
|
|
675
654
|
}
|
|
676
655
|
return strain;
|
|
@@ -678,27 +657,154 @@ class DroidAim extends DroidSkill {
|
|
|
678
657
|
/**
|
|
679
658
|
* Calculates the movement strain of a hitobject.
|
|
680
659
|
*/
|
|
681
|
-
movementStrainOf(current) {
|
|
660
|
+
static movementStrainOf(current) {
|
|
682
661
|
let speedBonus = 1;
|
|
683
662
|
if (current.strainTime < this.minSpeedBonus) {
|
|
684
663
|
speedBonus +=
|
|
685
664
|
0.75 *
|
|
686
665
|
Math.pow((this.minSpeedBonus - current.strainTime) / 45, 2);
|
|
687
666
|
}
|
|
688
|
-
const travelDistance =
|
|
667
|
+
const travelDistance = current.previous(0)?.travelDistance ?? 0;
|
|
689
668
|
const distance = Math.min(this.SINGLE_SPACING_THRESHOLD, travelDistance + current.minimumJumpDistance);
|
|
690
669
|
return ((50 *
|
|
691
670
|
speedBonus *
|
|
692
671
|
Math.pow(distance / this.SINGLE_SPACING_THRESHOLD, 5)) /
|
|
693
672
|
current.strainTime);
|
|
694
673
|
}
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
/**
|
|
677
|
+
* A bare minimal abstract skill for fully custom skill implementations.
|
|
678
|
+
*/
|
|
679
|
+
class Skill {
|
|
680
|
+
/**
|
|
681
|
+
* The mods that this skill processes.
|
|
682
|
+
*/
|
|
683
|
+
mods;
|
|
684
|
+
constructor(mods) {
|
|
685
|
+
this.mods = mods;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
/**
|
|
690
|
+
* Used to processes strain values of difficulty hitobjects, keep track of strain levels caused by the processed objects
|
|
691
|
+
* and to calculate a final difficulty value representing the difficulty of hitting all the processed objects.
|
|
692
|
+
*/
|
|
693
|
+
class StrainSkill extends Skill {
|
|
694
|
+
/**
|
|
695
|
+
* The strain of currently calculated hitobject.
|
|
696
|
+
*/
|
|
697
|
+
currentStrain = 0;
|
|
698
|
+
/**
|
|
699
|
+
* The current section's strain peak.
|
|
700
|
+
*/
|
|
701
|
+
currentSectionPeak = 0;
|
|
702
|
+
/**
|
|
703
|
+
* Strain peaks are stored here.
|
|
704
|
+
*/
|
|
705
|
+
strainPeaks = [];
|
|
706
|
+
sectionLength = 400;
|
|
707
|
+
currentSectionEnd = 0;
|
|
708
|
+
isFirstObject = true;
|
|
709
|
+
/**
|
|
710
|
+
* Calculates the strain value of a hitobject and stores the value in it. This value is affected by previously processed objects.
|
|
711
|
+
*
|
|
712
|
+
* @param current The hitobject to process.
|
|
713
|
+
*/
|
|
714
|
+
process(current) {
|
|
715
|
+
// The first object doesn't generate a strain, so we begin with an incremented section end
|
|
716
|
+
if (this.isFirstObject) {
|
|
717
|
+
this.currentSectionEnd =
|
|
718
|
+
Math.ceil(current.startTime / this.sectionLength) *
|
|
719
|
+
this.sectionLength;
|
|
720
|
+
this.isFirstObject = false;
|
|
721
|
+
}
|
|
722
|
+
while (current.startTime > this.currentSectionEnd) {
|
|
723
|
+
this.saveCurrentPeak();
|
|
724
|
+
this.startNewSectionFrom(this.currentSectionEnd, current);
|
|
725
|
+
this.currentSectionEnd += this.sectionLength;
|
|
726
|
+
}
|
|
727
|
+
// Ignore the first hitobject.
|
|
728
|
+
this.currentStrain = this.strainValueAt(current);
|
|
729
|
+
this.saveToHitObject(current);
|
|
730
|
+
this.currentSectionPeak = Math.max(this.currentStrain, this.currentSectionPeak);
|
|
731
|
+
}
|
|
732
|
+
/**
|
|
733
|
+
* Saves the current peak strain level to the list of strain peaks, which will be used to calculate an overall difficulty.
|
|
734
|
+
*/
|
|
735
|
+
saveCurrentPeak() {
|
|
736
|
+
this.strainPeaks.push(this.currentSectionPeak);
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* Calculates strain decay for a specified time frame.
|
|
740
|
+
*
|
|
741
|
+
* @param ms The time frame to calculate.
|
|
742
|
+
*/
|
|
743
|
+
strainDecay(ms) {
|
|
744
|
+
return Math.pow(this.strainDecayBase, ms / 1000);
|
|
745
|
+
}
|
|
746
|
+
/**
|
|
747
|
+
* Sets the initial strain level for a new section.
|
|
748
|
+
*
|
|
749
|
+
* @param offset The beginning of the new section in milliseconds, adjusted by speed multiplier.
|
|
750
|
+
* @param current The current hitobject.
|
|
751
|
+
*/
|
|
752
|
+
startNewSectionFrom(offset, current) {
|
|
753
|
+
// The maximum strain of the new section is not zero by default, strain decays as usual regardless of section boundaries.
|
|
754
|
+
// This means we need to capture the strain level at the beginning of the new section, and use that as the initial peak level.
|
|
755
|
+
this.currentSectionPeak =
|
|
756
|
+
this.currentStrain *
|
|
757
|
+
this.strainDecay(offset - current.previous(0).startTime);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
/**
|
|
762
|
+
* Used to processes strain values of difficulty hitobjects, keep track of strain levels caused by the processed objects
|
|
763
|
+
* and to calculate a final difficulty value representing the difficulty of hitting all the processed objects.
|
|
764
|
+
*/
|
|
765
|
+
class DroidSkill extends StrainSkill {
|
|
766
|
+
difficultyValue() {
|
|
767
|
+
const sortedStrains = this.strainPeaks
|
|
768
|
+
.slice()
|
|
769
|
+
.sort((a, b) => b - a);
|
|
770
|
+
// We are reducing the highest strains first to account for extreme difficulty spikes.
|
|
771
|
+
for (let i = 0; i < Math.min(sortedStrains.length, this.reducedSectionCount); ++i) {
|
|
772
|
+
const scale = Math.log10(osuBase.Interpolation.lerp(1, 10, osuBase.MathUtils.clamp(i / this.reducedSectionCount, 0, 1)));
|
|
773
|
+
sortedStrains[i] *= osuBase.Interpolation.lerp(this.reducedSectionBaseline, 1, scale);
|
|
774
|
+
}
|
|
775
|
+
// Math here preserves the property that two notes of equal difficulty x, we have their summed difficulty = x * starsPerDouble.
|
|
776
|
+
// This also applies to two sets of notes with equal difficulty.
|
|
777
|
+
return Math.pow(sortedStrains.reduce((a, v) => {
|
|
778
|
+
if (v <= 0) {
|
|
779
|
+
return a;
|
|
780
|
+
}
|
|
781
|
+
return a + Math.pow(v, 1 / Math.log2(this.starsPerDouble));
|
|
782
|
+
}, 0), Math.log2(this.starsPerDouble));
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
/**
|
|
787
|
+
* Represents the skill required to correctly aim at every object in the map with a uniform CircleSize and normalized distances.
|
|
788
|
+
*/
|
|
789
|
+
class DroidAim extends DroidSkill {
|
|
790
|
+
skillMultiplier = 23.25;
|
|
791
|
+
strainDecayBase = 0.15;
|
|
792
|
+
reducedSectionCount = 10;
|
|
793
|
+
reducedSectionBaseline = 0.75;
|
|
794
|
+
starsPerDouble = 1.05;
|
|
795
|
+
withSliders;
|
|
796
|
+
constructor(mods, withSliders) {
|
|
797
|
+
super(mods);
|
|
798
|
+
this.withSliders = withSliders;
|
|
799
|
+
}
|
|
695
800
|
/**
|
|
696
801
|
* @param current The hitobject to calculate.
|
|
697
802
|
*/
|
|
698
803
|
strainValueAt(current) {
|
|
699
804
|
this.currentStrain *= this.strainDecay(current.deltaTime);
|
|
700
805
|
this.currentStrain +=
|
|
701
|
-
|
|
806
|
+
DroidAimEvaluator.evaluateDifficultyOf(current, this.withSliders) *
|
|
807
|
+
this.skillMultiplier;
|
|
702
808
|
return this.currentStrain;
|
|
703
809
|
}
|
|
704
810
|
/**
|
|
@@ -712,39 +818,40 @@ class DroidAim extends DroidSkill {
|
|
|
712
818
|
current.aimStrainWithoutSliders = this.currentStrain;
|
|
713
819
|
}
|
|
714
820
|
}
|
|
715
|
-
/**
|
|
716
|
-
* Calculates the bonus of wide angles.
|
|
717
|
-
*/
|
|
718
|
-
calculateWideAngleBonus(angle) {
|
|
719
|
-
return Math.pow(Math.sin((3 / 4) *
|
|
720
|
-
(Math.min((5 / 6) * Math.PI, Math.max(Math.PI / 6, angle)) -
|
|
721
|
-
Math.PI / 6)), 2);
|
|
722
|
-
}
|
|
723
|
-
/**
|
|
724
|
-
* Calculates the bonus of acute angles.
|
|
725
|
-
*/
|
|
726
|
-
calculateAcuteAngleBonus(angle) {
|
|
727
|
-
return 1 - this.calculateWideAngleBonus(angle);
|
|
728
|
-
}
|
|
729
821
|
}
|
|
730
822
|
|
|
731
823
|
/**
|
|
732
|
-
*
|
|
824
|
+
* An evaluator for calculating flashlight skill.
|
|
825
|
+
*
|
|
826
|
+
* This class should be considered an "evaluating" class and not persisted.
|
|
733
827
|
*/
|
|
734
|
-
class
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
828
|
+
class FlashlightEvaluator {
|
|
829
|
+
static maxOpacityBonus = 0.4;
|
|
830
|
+
static hiddenBonus = 0.2;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
/**
|
|
834
|
+
* An evaluator for calculating osu!droid Flashlight skill.
|
|
835
|
+
*/
|
|
836
|
+
class DroidFlashlightEvaluator extends FlashlightEvaluator {
|
|
837
|
+
/**
|
|
838
|
+
* Evaluates the difficulty of memorizing and hitting the current object, based on:
|
|
839
|
+
*
|
|
840
|
+
* - distance between the previous and the current object,
|
|
841
|
+
* - the visual opacity of the current object,
|
|
842
|
+
* - and whether Hidden mod is enabled.
|
|
843
|
+
*
|
|
844
|
+
* @param current The current object.
|
|
845
|
+
* @param isHiddenMod Whether the Hidden mod is enabled.
|
|
846
|
+
*/
|
|
847
|
+
static evaluateDifficultyOf(current, isHiddenMod) {
|
|
848
|
+
const actualLast = current.previous(0);
|
|
742
849
|
if (current.object instanceof osuBase.Spinner ||
|
|
743
850
|
// Exclude overlapping objects that can be tapped at once.
|
|
744
851
|
(current.deltaTime < 5 &&
|
|
745
|
-
(
|
|
746
|
-
? Math.min(
|
|
747
|
-
:
|
|
852
|
+
((actualLast?.object instanceof osuBase.Slider
|
|
853
|
+
? Math.min(actualLast.object.stackedEndPosition.getDistance(current.object.stackedPosition), actualLast.object.lazyEndPosition.getDistance(current.object.stackedPosition))
|
|
854
|
+
: actualLast?.object.stackedEndPosition.getDistance(current.object.stackedPosition)) ?? Number.POSITIVE_INFINITY) <=
|
|
748
855
|
2 * current.object.radius)) {
|
|
749
856
|
return 0;
|
|
750
857
|
}
|
|
@@ -753,8 +860,8 @@ class DroidFlashlight extends DroidSkill {
|
|
|
753
860
|
let cumulativeStrainTime = 0;
|
|
754
861
|
let result = 0;
|
|
755
862
|
let last = current;
|
|
756
|
-
for (let i = 0; i <
|
|
757
|
-
const currentObject =
|
|
863
|
+
for (let i = 0; i < Math.min(current.index, 10); ++i) {
|
|
864
|
+
const currentObject = current.previous(i);
|
|
758
865
|
if (!(currentObject.object instanceof osuBase.Spinner) &&
|
|
759
866
|
// Exclude overlapping objects that can be tapped at once.
|
|
760
867
|
currentObject.deltaTime >= 5) {
|
|
@@ -766,21 +873,46 @@ class DroidFlashlight extends DroidSkill {
|
|
|
766
873
|
}
|
|
767
874
|
// We also want to nerf stacks so that only the first object of the stack is accounted for.
|
|
768
875
|
const stackNerf = Math.min(1, currentObject.lazyJumpDistance / scalingFactor / 25);
|
|
876
|
+
// Bonus based on how visible the object is.
|
|
877
|
+
const opacityBonus = 1 +
|
|
878
|
+
this.maxOpacityBonus *
|
|
879
|
+
(1.0 -
|
|
880
|
+
current.opacityAt(currentObject.startTime, isHiddenMod));
|
|
769
881
|
result +=
|
|
770
|
-
(stackNerf * scalingFactor * jumpDistance) /
|
|
882
|
+
(stackNerf * opacityBonus * scalingFactor * jumpDistance) /
|
|
771
883
|
cumulativeStrainTime;
|
|
772
884
|
}
|
|
773
885
|
last = currentObject;
|
|
774
886
|
}
|
|
887
|
+
// Additional bonus for Hidden due to there being no approach circles.
|
|
888
|
+
if (isHiddenMod) {
|
|
889
|
+
result *= 1 + this.hiddenBonus;
|
|
890
|
+
}
|
|
775
891
|
return Math.pow(smallDistNerf * result, 2);
|
|
776
892
|
}
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
/**
|
|
896
|
+
* Represents the skill required to memorize and hit every object in a beatmap with the Flashlight mod enabled.
|
|
897
|
+
*/
|
|
898
|
+
class DroidFlashlight extends DroidSkill {
|
|
899
|
+
skillMultiplier = 0.1;
|
|
900
|
+
strainDecayBase = 0.15;
|
|
901
|
+
reducedSectionCount = 10;
|
|
902
|
+
reducedSectionBaseline = 0.75;
|
|
903
|
+
starsPerDouble = 1.05;
|
|
904
|
+
isHidden;
|
|
905
|
+
constructor(mods) {
|
|
906
|
+
super(mods);
|
|
907
|
+
this.isHidden = mods.some((m) => m instanceof osuBase.ModHidden);
|
|
908
|
+
}
|
|
777
909
|
/**
|
|
778
910
|
* @param current The hitobject to calculate.
|
|
779
911
|
*/
|
|
780
912
|
strainValueAt(current) {
|
|
781
913
|
this.currentStrain *= this.strainDecay(current.deltaTime);
|
|
782
914
|
this.currentStrain +=
|
|
783
|
-
|
|
915
|
+
DroidFlashlightEvaluator.evaluateDifficultyOf(current, this.isHidden) * this.skillMultiplier;
|
|
784
916
|
return this.currentStrain;
|
|
785
917
|
}
|
|
786
918
|
saveToHitObject(current) {
|
|
@@ -788,6 +920,65 @@ class DroidFlashlight extends DroidSkill {
|
|
|
788
920
|
}
|
|
789
921
|
}
|
|
790
922
|
|
|
923
|
+
/**
|
|
924
|
+
* An evaluator for calculating speed or tap skill.
|
|
925
|
+
*
|
|
926
|
+
* This class should be considered an "evaluating" class and not persisted.
|
|
927
|
+
*/
|
|
928
|
+
class SpeedEvaluator {
|
|
929
|
+
// ~200 1/4 BPM streams
|
|
930
|
+
static minSpeedBonus = 75;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
/**
|
|
934
|
+
* An evaluator for calculating osu!droid tap skill.
|
|
935
|
+
*/
|
|
936
|
+
class DroidTapEvaluator extends SpeedEvaluator {
|
|
937
|
+
/**
|
|
938
|
+
* Evaluates the difficulty of tapping the current object, based on:
|
|
939
|
+
*
|
|
940
|
+
* - time between pressing the previous and current object,
|
|
941
|
+
* - distance between those objects,
|
|
942
|
+
* - and how easily they can be cheesed.
|
|
943
|
+
*
|
|
944
|
+
* @param current The current object.
|
|
945
|
+
* @param greatWindow The great hit window of the current object.
|
|
946
|
+
* @param considerCheesability Whether to consider cheesability.
|
|
947
|
+
*/
|
|
948
|
+
static evaluateDifficultyOf(current, greatWindow, considerCheesability) {
|
|
949
|
+
if (current.object instanceof osuBase.Spinner ||
|
|
950
|
+
// Exclude overlapping objects that can be tapped at once.
|
|
951
|
+
current.deltaTime < 5) {
|
|
952
|
+
return 0;
|
|
953
|
+
}
|
|
954
|
+
let strainTime = current.strainTime;
|
|
955
|
+
let doubletapness = 1;
|
|
956
|
+
if (considerCheesability) {
|
|
957
|
+
const greatWindowFull = greatWindow * 2;
|
|
958
|
+
// Nerf doubletappable doubles.
|
|
959
|
+
const next = current.next(0);
|
|
960
|
+
if (next) {
|
|
961
|
+
const currentDeltaTime = Math.max(1, current.deltaTime);
|
|
962
|
+
const nextDeltaTime = Math.max(1, next.deltaTime);
|
|
963
|
+
const deltaDifference = Math.abs(nextDeltaTime - currentDeltaTime);
|
|
964
|
+
const speedRatio = currentDeltaTime /
|
|
965
|
+
Math.max(currentDeltaTime, deltaDifference);
|
|
966
|
+
const windowRatio = Math.pow(Math.min(1, currentDeltaTime / greatWindowFull), 2);
|
|
967
|
+
doubletapness = Math.pow(speedRatio, 1 - windowRatio);
|
|
968
|
+
}
|
|
969
|
+
// Cap deltatime to the OD 300 hitwindow.
|
|
970
|
+
// 0.58 is derived from making sure 260 BPM 1/4 OD5 streams aren't nerfed harshly, whilst 0.91 limits the effect of the cap.
|
|
971
|
+
strainTime /= osuBase.MathUtils.clamp(strainTime / greatWindowFull / 0.58, 0.91, 1);
|
|
972
|
+
}
|
|
973
|
+
let speedBonus = 1;
|
|
974
|
+
if (strainTime < this.minSpeedBonus) {
|
|
975
|
+
speedBonus +=
|
|
976
|
+
0.75 * Math.pow((this.minSpeedBonus - strainTime) / 40, 2);
|
|
977
|
+
}
|
|
978
|
+
return (speedBonus * doubletapness) / strainTime;
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
|
|
791
982
|
/**
|
|
792
983
|
* Represents the skill required to press keys or tap with regards to keeping up with the speed at which objects need to be hit.
|
|
793
984
|
*/
|
|
@@ -801,65 +992,25 @@ class DroidTap extends DroidSkill {
|
|
|
801
992
|
minSpeedBonus = 75;
|
|
802
993
|
currentTapStrain = 0;
|
|
803
994
|
currentOriginalTapStrain = 0;
|
|
804
|
-
|
|
995
|
+
greatWindow;
|
|
805
996
|
constructor(mods, overallDifficulty) {
|
|
806
997
|
super(mods);
|
|
807
|
-
this.
|
|
998
|
+
this.greatWindow = new osuBase.OsuHitWindow(overallDifficulty).hitWindowFor300();
|
|
808
999
|
}
|
|
809
1000
|
/**
|
|
810
1001
|
* @param current The hitobject to calculate.
|
|
811
1002
|
*/
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
// Exclude overlapping objects that can be tapped at once.
|
|
815
|
-
current.deltaTime < 5) {
|
|
816
|
-
return 0;
|
|
817
|
-
}
|
|
818
|
-
let strainTime = current.strainTime;
|
|
819
|
-
const greatWindowFull = this.hitWindow.hitWindowFor300() * 2;
|
|
820
|
-
// Aim to nerf cheesy rhythms (very fast consecutive doubles with large deltatimes between).
|
|
821
|
-
if (this.previous[0] &&
|
|
822
|
-
strainTime < greatWindowFull &&
|
|
823
|
-
this.previous[0].strainTime > strainTime) {
|
|
824
|
-
strainTime = osuBase.Interpolation.lerp(this.previous[0].strainTime, strainTime, strainTime / greatWindowFull);
|
|
825
|
-
}
|
|
826
|
-
// Cap deltatime to the OD 300 hitwindow.
|
|
827
|
-
// 0.58 is derived from making sure 260 BPM 1/4 OD5 streams aren't nerfed harshly, whilst 0.91 limits the effect of the cap.
|
|
828
|
-
strainTime /= osuBase.MathUtils.clamp(strainTime / greatWindowFull / 0.58, 0.91, 1);
|
|
829
|
-
let speedBonus = 1;
|
|
830
|
-
if (strainTime < this.minSpeedBonus) {
|
|
831
|
-
speedBonus +=
|
|
832
|
-
0.75 * Math.pow((this.minSpeedBonus - strainTime) / 40, 2);
|
|
833
|
-
}
|
|
834
|
-
let originalSpeedBonus = 1;
|
|
835
|
-
if (current.strainTime < this.minSpeedBonus) {
|
|
836
|
-
originalSpeedBonus +=
|
|
837
|
-
0.75 *
|
|
838
|
-
Math.pow((this.minSpeedBonus - current.strainTime) / 40, 2);
|
|
839
|
-
}
|
|
840
|
-
const decay = this.strainDecay(current.deltaTime);
|
|
1003
|
+
strainValueAt(current) {
|
|
1004
|
+
const decay = this.strainDecay(current.strainTime);
|
|
841
1005
|
this.currentTapStrain *= decay;
|
|
842
1006
|
this.currentTapStrain +=
|
|
843
|
-
|
|
1007
|
+
DroidTapEvaluator.evaluateDifficultyOf(current, this.greatWindow, true) * this.skillMultiplier;
|
|
844
1008
|
this.currentOriginalTapStrain *= decay;
|
|
845
1009
|
this.currentOriginalTapStrain +=
|
|
846
|
-
|
|
847
|
-
this.skillMultiplier;
|
|
1010
|
+
DroidTapEvaluator.evaluateDifficultyOf(current, this.greatWindow, false) * this.skillMultiplier;
|
|
848
1011
|
this.currentOriginalTapStrain *= current.rhythmMultiplier;
|
|
849
1012
|
return this.currentTapStrain * current.rhythmMultiplier;
|
|
850
1013
|
}
|
|
851
|
-
/**
|
|
852
|
-
* Calculates the tap strain of a hitobject given a specific speed bonus and strain time.
|
|
853
|
-
*/
|
|
854
|
-
tapStrainOf(speedBonus, strainTime) {
|
|
855
|
-
return speedBonus / strainTime;
|
|
856
|
-
}
|
|
857
|
-
/**
|
|
858
|
-
* @param current The hitobject to calculate.
|
|
859
|
-
*/
|
|
860
|
-
strainValueAt(current) {
|
|
861
|
-
return this.strainValueOf(current);
|
|
862
|
-
}
|
|
863
1014
|
/**
|
|
864
1015
|
* @param current The hitobject to save to.
|
|
865
1016
|
*/
|
|
@@ -969,7 +1120,7 @@ class StarRating {
|
|
|
969
1120
|
calculateSkills(...skills) {
|
|
970
1121
|
this.objects.slice(1).forEach((h, i) => {
|
|
971
1122
|
skills.forEach((skill) => {
|
|
972
|
-
skill.
|
|
1123
|
+
skill.process(h);
|
|
973
1124
|
if (i === this.objects.length - 2) {
|
|
974
1125
|
// Don't forget to save the last strain peak, which would otherwise be ignored.
|
|
975
1126
|
skill.saveCurrentPeak();
|
|
@@ -996,31 +1147,26 @@ class StarRating {
|
|
|
996
1147
|
}
|
|
997
1148
|
|
|
998
1149
|
/**
|
|
999
|
-
*
|
|
1150
|
+
* An evaluator for calculating rhythm skill.
|
|
1151
|
+
*
|
|
1152
|
+
* This class should be considered an "evaluating" class and not persisted.
|
|
1000
1153
|
*/
|
|
1001
|
-
class
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
historyTimeMax = 5000; // 5 seconds of calculateRhythmBonus max.
|
|
1010
|
-
currentRhythm = 1;
|
|
1011
|
-
hitWindow;
|
|
1012
|
-
constructor(mods, overallDifficulty) {
|
|
1013
|
-
super(mods);
|
|
1014
|
-
this.hitWindow = new osuBase.OsuHitWindow(overallDifficulty);
|
|
1015
|
-
const odScaling = Math.pow(this.hitWindow.overallDifficulty, 2) / 400;
|
|
1016
|
-
this.rhythmMultiplier =
|
|
1017
|
-
0.75 +
|
|
1018
|
-
(this.hitWindow.overallDifficulty >= 0 ? odScaling : -odScaling);
|
|
1019
|
-
}
|
|
1154
|
+
class RhythmEvaluator {
|
|
1155
|
+
static historyTimeMax = 5000; // 5 seconds of calculateRhythmBonus max.
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
/**
|
|
1159
|
+
* An evaluator for calculating osu!droid Rhythm skill.
|
|
1160
|
+
*/
|
|
1161
|
+
class DroidRhythmEvaluator extends RhythmEvaluator {
|
|
1020
1162
|
/**
|
|
1021
|
-
* Calculates a rhythm multiplier for the difficulty of the tap associated
|
|
1163
|
+
* Calculates a rhythm multiplier for the difficulty of the tap associated
|
|
1164
|
+
* with historic data of the current object.
|
|
1165
|
+
*
|
|
1166
|
+
* @param current The current object.
|
|
1167
|
+
* @param greatWindow The great hit window of the current object.
|
|
1022
1168
|
*/
|
|
1023
|
-
|
|
1169
|
+
static evaluateDifficultyOf(current, greatWindow) {
|
|
1024
1170
|
if (current.object instanceof osuBase.Spinner ||
|
|
1025
1171
|
// Exclude overlapping objects that can be tapped at once.
|
|
1026
1172
|
current.deltaTime < 5) {
|
|
@@ -1033,8 +1179,18 @@ class DroidRhythm extends DroidSkill {
|
|
|
1033
1179
|
let startRatio = 0;
|
|
1034
1180
|
let firstDeltaSwitch = false;
|
|
1035
1181
|
let rhythmStart = 0;
|
|
1182
|
+
const historicalNoteCount = Math.min(current.index, 32);
|
|
1036
1183
|
// Exclude overlapping objects that can be tapped at once.
|
|
1037
|
-
const validPrevious =
|
|
1184
|
+
const validPrevious = [];
|
|
1185
|
+
for (let i = 0; i < historicalNoteCount; ++i) {
|
|
1186
|
+
const object = current.previous(i);
|
|
1187
|
+
if (!object) {
|
|
1188
|
+
break;
|
|
1189
|
+
}
|
|
1190
|
+
if (object.deltaTime >= 5) {
|
|
1191
|
+
validPrevious.push(object);
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1038
1194
|
while (rhythmStart < validPrevious.length - 2 &&
|
|
1039
1195
|
current.startTime - validPrevious[rhythmStart].startTime <
|
|
1040
1196
|
this.historyTimeMax) {
|
|
@@ -1055,9 +1211,8 @@ class DroidRhythm extends DroidSkill {
|
|
|
1055
1211
|
Math.min(0.5, Math.pow(Math.sin(Math.PI /
|
|
1056
1212
|
(Math.min(prevDelta, currentDelta) /
|
|
1057
1213
|
Math.max(prevDelta, currentDelta))), 2));
|
|
1058
|
-
const windowPenalty = Math.min(1, Math.max(0, Math.abs(prevDelta - currentDelta) -
|
|
1059
|
-
|
|
1060
|
-
(this.hitWindow.hitWindowFor300() * 0.4));
|
|
1214
|
+
const windowPenalty = Math.min(1, Math.max(0, Math.abs(prevDelta - currentDelta) - greatWindow * 0.4) /
|
|
1215
|
+
(greatWindow * 0.4));
|
|
1061
1216
|
let effectiveRatio = windowPenalty * currentRatio;
|
|
1062
1217
|
if (firstDeltaSwitch) {
|
|
1063
1218
|
if (prevDelta <= 1.25 * currentDelta &&
|
|
@@ -1115,10 +1270,39 @@ class DroidRhythm extends DroidSkill {
|
|
|
1115
1270
|
islandSize = 1;
|
|
1116
1271
|
}
|
|
1117
1272
|
}
|
|
1118
|
-
return Math.sqrt(4 +
|
|
1273
|
+
return (Math.sqrt(4 +
|
|
1274
|
+
rhythmComplexitySum *
|
|
1275
|
+
this.calculateRhythmMultiplier(greatWindow)) / 2);
|
|
1276
|
+
}
|
|
1277
|
+
/**
|
|
1278
|
+
* Calculates the rhythm multiplier of a given hit window.
|
|
1279
|
+
*
|
|
1280
|
+
* @param greatWindow The great hit window.
|
|
1281
|
+
*/
|
|
1282
|
+
static calculateRhythmMultiplier(greatWindow) {
|
|
1283
|
+
const od = osuBase.OsuHitWindow.hitWindow300ToOD(greatWindow);
|
|
1284
|
+
const odScaling = Math.pow(od, 2) / 400;
|
|
1285
|
+
return 0.75 + (od >= 0 ? odScaling : -odScaling);
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
/**
|
|
1290
|
+
* Represents the skill required to properly follow a beatmap's rhythm.
|
|
1291
|
+
*/
|
|
1292
|
+
class DroidRhythm extends DroidSkill {
|
|
1293
|
+
skillMultiplier = 1;
|
|
1294
|
+
reducedSectionCount = 5;
|
|
1295
|
+
reducedSectionBaseline = 0.75;
|
|
1296
|
+
strainDecayBase = 0.3;
|
|
1297
|
+
starsPerDouble = 1.75;
|
|
1298
|
+
currentRhythm = 1;
|
|
1299
|
+
hitWindow;
|
|
1300
|
+
constructor(mods, overallDifficulty) {
|
|
1301
|
+
super(mods);
|
|
1302
|
+
this.hitWindow = new osuBase.OsuHitWindow(overallDifficulty);
|
|
1119
1303
|
}
|
|
1120
1304
|
strainValueAt(current) {
|
|
1121
|
-
this.currentRhythm = this.
|
|
1305
|
+
this.currentRhythm = DroidRhythmEvaluator.evaluateDifficultyOf(current, this.hitWindow.hitWindowFor300());
|
|
1122
1306
|
this.currentStrain *= this.strainDecay(current.deltaTime);
|
|
1123
1307
|
this.currentStrain += this.currentRhythm - 1;
|
|
1124
1308
|
return this.currentStrain;
|
|
@@ -1130,32 +1314,30 @@ class DroidRhythm extends DroidSkill {
|
|
|
1130
1314
|
}
|
|
1131
1315
|
|
|
1132
1316
|
/**
|
|
1133
|
-
*
|
|
1317
|
+
* An evaluator for calculating osu!droid Rhythm skill.
|
|
1134
1318
|
*/
|
|
1135
|
-
class
|
|
1136
|
-
historyLength = 4;
|
|
1137
|
-
starsPerDouble = 1.025;
|
|
1138
|
-
reducedSectionCount = 10;
|
|
1139
|
-
reducedSectionBaseline = 0.75;
|
|
1140
|
-
skillMultiplier = 20;
|
|
1141
|
-
strainDecayBase = 0.1;
|
|
1142
|
-
preempt;
|
|
1143
|
-
isHidden;
|
|
1144
|
-
constructor(mods, preempt) {
|
|
1145
|
-
super(mods);
|
|
1146
|
-
this.preempt = preempt;
|
|
1147
|
-
this.isHidden = mods.some((m) => m instanceof osuBase.ModHidden);
|
|
1148
|
-
}
|
|
1319
|
+
class DroidVisualEvaluator {
|
|
1149
1320
|
/**
|
|
1150
|
-
*
|
|
1321
|
+
* Evaluates the difficulty of reading the current object, based on:
|
|
1322
|
+
*
|
|
1323
|
+
* - note density of the current object,
|
|
1324
|
+
* - overlapping factor of the current object,
|
|
1325
|
+
* - the preempt time of the current object,
|
|
1326
|
+
* - the velocity of the current object if it's a slider,
|
|
1327
|
+
* - past objects' velocity if they are sliders,
|
|
1328
|
+
* - and whether the Hidden mod is enabled.
|
|
1329
|
+
*
|
|
1330
|
+
* @param current The current object.
|
|
1331
|
+
* @param isHiddenMod Whether the Hidden mod is enabled.
|
|
1151
1332
|
*/
|
|
1152
|
-
|
|
1333
|
+
static evaluateDifficultyOf(current, isHiddenMod) {
|
|
1334
|
+
const last = current.previous(0);
|
|
1153
1335
|
if (current.object instanceof osuBase.Spinner ||
|
|
1154
1336
|
// Exclude overlapping objects that can be tapped at once.
|
|
1155
1337
|
(current.deltaTime < 5 &&
|
|
1156
|
-
(
|
|
1157
|
-
? Math.min(
|
|
1158
|
-
:
|
|
1338
|
+
((last?.object instanceof osuBase.Slider
|
|
1339
|
+
? Math.min(last.object.stackedEndPosition.getDistance(current.object.stackedPosition), last.object.lazyEndPosition.getDistance(current.object.stackedPosition))
|
|
1340
|
+
: last?.object.stackedEndPosition.getDistance(current.object.stackedPosition)) ?? Number.POSITIVE_INFINITY) <=
|
|
1159
1341
|
2 * current.object.radius)) {
|
|
1160
1342
|
return 0;
|
|
1161
1343
|
}
|
|
@@ -1164,15 +1346,15 @@ class DroidVisual extends DroidSkill {
|
|
|
1164
1346
|
let strain = Math.min(20, Math.pow(current.noteDensity, 2)) /
|
|
1165
1347
|
10 /
|
|
1166
1348
|
(1 + current.overlappingFactor);
|
|
1167
|
-
if (
|
|
1349
|
+
if (isHiddenMod) {
|
|
1168
1350
|
strain +=
|
|
1169
1351
|
Math.min(25, Math.pow(current.noteDensity, 1.25)) /
|
|
1170
1352
|
10 /
|
|
1171
1353
|
(1 + current.overlappingFactor / 1.25);
|
|
1172
1354
|
}
|
|
1173
1355
|
// Give bonus for AR higher than 10.33.
|
|
1174
|
-
if (
|
|
1175
|
-
strain += Math.pow(400 -
|
|
1356
|
+
if (current.timePreempt < 400) {
|
|
1357
|
+
strain += Math.pow(400 - current.timePreempt, 1.3) / 135;
|
|
1176
1358
|
}
|
|
1177
1359
|
if (current.object instanceof osuBase.Slider) {
|
|
1178
1360
|
const scalingFactor = 50 / current.object.radius;
|
|
@@ -1184,8 +1366,8 @@ class DroidVisual extends DroidSkill {
|
|
|
1184
1366
|
Math.min(1, current.travelDistance / scalingFactor / 125);
|
|
1185
1367
|
let cumulativeStrainTime = 0;
|
|
1186
1368
|
// Reward for velocity changes based on last few sliders.
|
|
1187
|
-
for (let i = 0; i <
|
|
1188
|
-
const last =
|
|
1369
|
+
for (let i = 0; i < Math.min(current.index, 4); ++i) {
|
|
1370
|
+
const last = current.previous(i);
|
|
1189
1371
|
cumulativeStrainTime += last.strainTime;
|
|
1190
1372
|
if (!(last.object instanceof osuBase.Slider) ||
|
|
1191
1373
|
// Exclude overlapping objects that can be tapped at once.
|
|
@@ -1205,10 +1387,27 @@ class DroidVisual extends DroidSkill {
|
|
|
1205
1387
|
}
|
|
1206
1388
|
return strain;
|
|
1207
1389
|
}
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
/**
|
|
1393
|
+
* Represents the skill required to read every object in the map.
|
|
1394
|
+
*/
|
|
1395
|
+
class DroidVisual extends DroidSkill {
|
|
1396
|
+
starsPerDouble = 1.025;
|
|
1397
|
+
reducedSectionCount = 10;
|
|
1398
|
+
reducedSectionBaseline = 0.75;
|
|
1399
|
+
skillMultiplier = 20;
|
|
1400
|
+
strainDecayBase = 0.1;
|
|
1401
|
+
isHidden;
|
|
1402
|
+
constructor(mods) {
|
|
1403
|
+
super(mods);
|
|
1404
|
+
this.isHidden = mods.some((m) => m instanceof osuBase.ModHidden);
|
|
1405
|
+
}
|
|
1208
1406
|
strainValueAt(current) {
|
|
1209
1407
|
this.currentStrain *= this.strainDecay(current.deltaTime);
|
|
1210
1408
|
this.currentStrain +=
|
|
1211
|
-
|
|
1409
|
+
DroidVisualEvaluator.evaluateDifficultyOf(current, this.isHidden) *
|
|
1410
|
+
this.skillMultiplier;
|
|
1212
1411
|
return this.currentStrain * (1 + (current.rhythmMultiplier - 1) / 5);
|
|
1213
1412
|
}
|
|
1214
1413
|
saveToHitObject(current) {
|
|
@@ -1313,7 +1512,7 @@ class DroidStarRating extends StarRating {
|
|
|
1313
1512
|
* Calculates the visual star rating of the beatmap and stores it in this instance.
|
|
1314
1513
|
*/
|
|
1315
1514
|
calculateVisual() {
|
|
1316
|
-
const visualSkill = new DroidVisual(this.mods
|
|
1515
|
+
const visualSkill = new DroidVisual(this.mods);
|
|
1317
1516
|
this.calculateSkills(visualSkill);
|
|
1318
1517
|
this.postCalculateVisual(visualSkill);
|
|
1319
1518
|
}
|
|
@@ -1388,7 +1587,7 @@ class DroidStarRating extends StarRating {
|
|
|
1388
1587
|
new DroidRhythm(this.mods, this.stats.od),
|
|
1389
1588
|
new DroidTap(this.mods, this.stats.od),
|
|
1390
1589
|
new DroidFlashlight(this.mods),
|
|
1391
|
-
new DroidVisual(this.mods
|
|
1590
|
+
new DroidVisual(this.mods),
|
|
1392
1591
|
];
|
|
1393
1592
|
}
|
|
1394
1593
|
/**
|
|
@@ -1741,10 +1940,6 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
|
|
|
1741
1940
|
const objectCount = this.stars.objects.length;
|
|
1742
1941
|
this.flashlight =
|
|
1743
1942
|
Math.pow(Math.pow(this.stars.flashlight, 0.8), 2) * 25;
|
|
1744
|
-
// Add an additional bonus for HDFL.
|
|
1745
|
-
if (this.stars.mods.some((m) => m instanceof osuBase.ModHidden)) {
|
|
1746
|
-
this.flashlight *= 1.3;
|
|
1747
|
-
}
|
|
1748
1943
|
// Combo scaling
|
|
1749
1944
|
this.flashlight *= this.comboPenalty;
|
|
1750
1945
|
if (this.effectiveMissCount > 0) {
|
|
@@ -1817,9 +2012,7 @@ class OsuSkill extends StrainSkill {
|
|
|
1817
2012
|
difficultyValue() {
|
|
1818
2013
|
const sortedStrains = this.strainPeaks
|
|
1819
2014
|
.slice()
|
|
1820
|
-
.sort((a, b) =>
|
|
1821
|
-
return b - a;
|
|
1822
|
-
});
|
|
2015
|
+
.sort((a, b) => b - a);
|
|
1823
2016
|
// We are reducing the highest strains first to account for extreme difficulty spikes.
|
|
1824
2017
|
for (let i = 0; i < Math.min(sortedStrains.length, this.reducedSectionCount); ++i) {
|
|
1825
2018
|
const scale = Math.log10(osuBase.Interpolation.lerp(1, 10, osuBase.MathUtils.clamp(i / this.reducedSectionCount, 0, 1)));
|
|
@@ -1827,9 +2020,7 @@ class OsuSkill extends StrainSkill {
|
|
|
1827
2020
|
}
|
|
1828
2021
|
// Difficulty is the weighted sum of the highest strains from every section.
|
|
1829
2022
|
// We're sorting from highest to lowest strain.
|
|
1830
|
-
sortedStrains.sort((a, b) =>
|
|
1831
|
-
return b - a;
|
|
1832
|
-
});
|
|
2023
|
+
sortedStrains.sort((a, b) => b - a);
|
|
1833
2024
|
let difficulty = 0;
|
|
1834
2025
|
let weight = 1;
|
|
1835
2026
|
for (const strain of sortedStrains) {
|
|
@@ -1845,39 +2036,32 @@ class OsuSkill extends StrainSkill {
|
|
|
1845
2036
|
}
|
|
1846
2037
|
|
|
1847
2038
|
/**
|
|
1848
|
-
*
|
|
2039
|
+
* An evaluator for calculating osu!standard Aim skill.
|
|
1849
2040
|
*/
|
|
1850
|
-
class
|
|
1851
|
-
skillMultiplier = 23.25;
|
|
1852
|
-
strainDecayBase = 0.15;
|
|
1853
|
-
reducedSectionCount = 10;
|
|
1854
|
-
reducedSectionBaseline = 0.75;
|
|
1855
|
-
difficultyMultiplier = 1.06;
|
|
1856
|
-
decayWeight = 0.9;
|
|
1857
|
-
wideAngleMultiplier = 1.5;
|
|
1858
|
-
acuteAngleMultiplier = 2;
|
|
1859
|
-
sliderMultiplier = 1.5;
|
|
1860
|
-
velocityChangeMultiplier = 0.75;
|
|
1861
|
-
withSliders;
|
|
1862
|
-
constructor(mods, withSliders) {
|
|
1863
|
-
super(mods);
|
|
1864
|
-
this.withSliders = withSliders;
|
|
1865
|
-
}
|
|
2041
|
+
class OsuAimEvaluator extends AimEvaluator {
|
|
1866
2042
|
/**
|
|
1867
|
-
*
|
|
2043
|
+
* Evaluates the difficulty of aiming the current object, based on:
|
|
2044
|
+
*
|
|
2045
|
+
* - cursor velocity to the current object,
|
|
2046
|
+
* - angle difficulty,
|
|
2047
|
+
* - sharp velocity increases,
|
|
2048
|
+
* - and slider difficulty.
|
|
2049
|
+
*
|
|
2050
|
+
* @param current The current object.
|
|
2051
|
+
* @param withSliders Whether to take slider difficulty into account.
|
|
1868
2052
|
*/
|
|
1869
|
-
|
|
2053
|
+
static evaluateDifficultyOf(current, withSliders) {
|
|
2054
|
+
const last = current.previous(0);
|
|
1870
2055
|
if (current.object instanceof osuBase.Spinner ||
|
|
1871
|
-
|
|
1872
|
-
|
|
2056
|
+
current.index <= 1 ||
|
|
2057
|
+
last?.object instanceof osuBase.Spinner) {
|
|
1873
2058
|
return 0;
|
|
1874
2059
|
}
|
|
1875
|
-
const
|
|
1876
|
-
const lastLast = this.previous[1];
|
|
2060
|
+
const lastLast = current.previous(1);
|
|
1877
2061
|
// Calculate the velocity to the current hitobject, which starts with a base distance / time assuming the last object is a hitcircle.
|
|
1878
2062
|
let currentVelocity = current.lazyJumpDistance / current.strainTime;
|
|
1879
2063
|
// But if the last object is a slider, then we extend the travel velocity through the slider into the current object.
|
|
1880
|
-
if (last.object instanceof osuBase.Slider &&
|
|
2064
|
+
if (last.object instanceof osuBase.Slider && withSliders) {
|
|
1881
2065
|
// Calculate the slider velocity from slider head to slider end.
|
|
1882
2066
|
const travelVelocity = last.travelDistance / last.travelTime;
|
|
1883
2067
|
// Calculate the movement velocity from slider end to current object.
|
|
@@ -1887,7 +2071,7 @@ class OsuAim extends OsuSkill {
|
|
|
1887
2071
|
}
|
|
1888
2072
|
// As above, do the same for the previous hitobject.
|
|
1889
2073
|
let prevVelocity = last.lazyJumpDistance / last.strainTime;
|
|
1890
|
-
if (lastLast.object instanceof osuBase.Slider &&
|
|
2074
|
+
if (lastLast.object instanceof osuBase.Slider && withSliders) {
|
|
1891
2075
|
const travelVelocity = lastLast.travelDistance / lastLast.travelTime;
|
|
1892
2076
|
const movementVelocity = last.minimumJumpDistance / last.minimumJumpTime;
|
|
1893
2077
|
prevVelocity = Math.max(prevVelocity, movementVelocity + travelVelocity);
|
|
@@ -1974,18 +2158,36 @@ class OsuAim extends OsuSkill {
|
|
|
1974
2158
|
strain += Math.max(acuteAngleBonus * this.acuteAngleMultiplier, wideAngleBonus * this.wideAngleMultiplier +
|
|
1975
2159
|
velocityChangeBonus * this.velocityChangeMultiplier);
|
|
1976
2160
|
// Add in additional slider velocity bonus.
|
|
1977
|
-
if (
|
|
2161
|
+
if (withSliders) {
|
|
1978
2162
|
strain += sliderBonus * this.sliderMultiplier;
|
|
1979
2163
|
}
|
|
1980
2164
|
return strain;
|
|
1981
2165
|
}
|
|
2166
|
+
}
|
|
2167
|
+
|
|
2168
|
+
/**
|
|
2169
|
+
* Represents the skill required to correctly aim at every object in the map with a uniform CircleSize and normalized distances.
|
|
2170
|
+
*/
|
|
2171
|
+
class OsuAim extends OsuSkill {
|
|
2172
|
+
skillMultiplier = 23.25;
|
|
2173
|
+
strainDecayBase = 0.15;
|
|
2174
|
+
reducedSectionCount = 10;
|
|
2175
|
+
reducedSectionBaseline = 0.75;
|
|
2176
|
+
difficultyMultiplier = 1.06;
|
|
2177
|
+
decayWeight = 0.9;
|
|
2178
|
+
withSliders;
|
|
2179
|
+
constructor(mods, withSliders) {
|
|
2180
|
+
super(mods);
|
|
2181
|
+
this.withSliders = withSliders;
|
|
2182
|
+
}
|
|
1982
2183
|
/**
|
|
1983
2184
|
* @param current The hitobject to calculate.
|
|
1984
2185
|
*/
|
|
1985
2186
|
strainValueAt(current) {
|
|
1986
2187
|
this.currentStrain *= this.strainDecay(current.deltaTime);
|
|
1987
2188
|
this.currentStrain +=
|
|
1988
|
-
|
|
2189
|
+
OsuAimEvaluator.evaluateDifficultyOf(current, this.withSliders) *
|
|
2190
|
+
this.skillMultiplier;
|
|
1989
2191
|
return this.currentStrain;
|
|
1990
2192
|
}
|
|
1991
2193
|
/**
|
|
@@ -1999,63 +2201,43 @@ class OsuAim extends OsuSkill {
|
|
|
1999
2201
|
current.aimStrainWithoutSliders = this.currentStrain;
|
|
2000
2202
|
}
|
|
2001
2203
|
}
|
|
2002
|
-
/**
|
|
2003
|
-
* Calculates the bonus of wide angles.
|
|
2004
|
-
*/
|
|
2005
|
-
calculateWideAngleBonus(angle) {
|
|
2006
|
-
return Math.pow(Math.sin((3 / 4) *
|
|
2007
|
-
(Math.min((5 / 6) * Math.PI, Math.max(Math.PI / 6, angle)) -
|
|
2008
|
-
Math.PI / 6)), 2);
|
|
2009
|
-
}
|
|
2010
|
-
/**
|
|
2011
|
-
* Calculates the bonus of acute angles.
|
|
2012
|
-
*/
|
|
2013
|
-
calculateAcuteAngleBonus(angle) {
|
|
2014
|
-
return 1 - this.calculateWideAngleBonus(angle);
|
|
2015
|
-
}
|
|
2016
2204
|
}
|
|
2017
2205
|
|
|
2018
2206
|
/**
|
|
2019
|
-
*
|
|
2207
|
+
* An evaluator for calculating osu!standard speed skill.
|
|
2020
2208
|
*/
|
|
2021
|
-
class
|
|
2209
|
+
class OsuSpeedEvaluator extends SpeedEvaluator {
|
|
2022
2210
|
/**
|
|
2023
2211
|
* Spacing threshold for a single hitobject spacing.
|
|
2024
2212
|
*/
|
|
2025
|
-
SINGLE_SPACING_THRESHOLD = 125;
|
|
2026
|
-
historyLength = 32;
|
|
2027
|
-
skillMultiplier = 1375;
|
|
2028
|
-
strainDecayBase = 0.3;
|
|
2029
|
-
reducedSectionCount = 5;
|
|
2030
|
-
reducedSectionBaseline = 0.75;
|
|
2031
|
-
difficultyMultiplier = 1.04;
|
|
2032
|
-
decayWeight = 0.9;
|
|
2033
|
-
rhythmMultiplier = 0.75;
|
|
2034
|
-
historyTimeMax = 5000; // 5 seconds of calculateRhythmBonus max.
|
|
2035
|
-
currentSpeedStrain = 0;
|
|
2036
|
-
currentRhythm = 0;
|
|
2037
|
-
// ~200 1/4 BPM streams
|
|
2038
|
-
minSpeedBonus = 75;
|
|
2039
|
-
greatWindow;
|
|
2040
|
-
constructor(mods, greatWindow) {
|
|
2041
|
-
super(mods);
|
|
2042
|
-
this.greatWindow = greatWindow;
|
|
2043
|
-
}
|
|
2213
|
+
static SINGLE_SPACING_THRESHOLD = 125;
|
|
2044
2214
|
/**
|
|
2045
|
-
*
|
|
2215
|
+
* Evaluates the difficulty of tapping the current object, based on:
|
|
2216
|
+
*
|
|
2217
|
+
* - time between pressing the previous and current object,
|
|
2218
|
+
* - distance between those objects,
|
|
2219
|
+
* - and how easily they can be cheesed.
|
|
2220
|
+
*
|
|
2221
|
+
* @param current The current object.
|
|
2222
|
+
* @param greatWindow The great hit window of the current object.
|
|
2046
2223
|
*/
|
|
2047
|
-
|
|
2224
|
+
static evaluateDifficultyOf(current, greatWindow) {
|
|
2048
2225
|
if (current.object instanceof osuBase.Spinner) {
|
|
2049
2226
|
return 0;
|
|
2050
2227
|
}
|
|
2228
|
+
const prev = current.previous(0);
|
|
2051
2229
|
let strainTime = current.strainTime;
|
|
2052
|
-
const greatWindowFull =
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2230
|
+
const greatWindowFull = greatWindow * 2;
|
|
2231
|
+
// Nerf doubletappable doubles.
|
|
2232
|
+
const next = current.next(0);
|
|
2233
|
+
let doubletapness = 1;
|
|
2234
|
+
if (next) {
|
|
2235
|
+
const currentDeltaTime = Math.max(1, current.deltaTime);
|
|
2236
|
+
const nextDeltaTime = Math.max(1, next.deltaTime);
|
|
2237
|
+
const deltaDifference = Math.abs(nextDeltaTime - currentDeltaTime);
|
|
2238
|
+
const speedRatio = currentDeltaTime / Math.max(currentDeltaTime, deltaDifference);
|
|
2239
|
+
const windowRatio = Math.pow(Math.min(1, currentDeltaTime / greatWindowFull), 2);
|
|
2240
|
+
doubletapness = Math.pow(speedRatio, 1 - windowRatio);
|
|
2059
2241
|
}
|
|
2060
2242
|
// Cap deltatime to the OD 300 hitwindow.
|
|
2061
2243
|
// 0.93 is derived from making sure 260 BPM 1/4 OD8 streams aren't nerfed harshly, whilst 0.92 limits the effect of the cap.
|
|
@@ -2065,27 +2247,29 @@ class OsuSpeed extends OsuSkill {
|
|
|
2065
2247
|
speedBonus +=
|
|
2066
2248
|
0.75 * Math.pow((this.minSpeedBonus - strainTime) / 40, 2);
|
|
2067
2249
|
}
|
|
2068
|
-
const travelDistance =
|
|
2250
|
+
const travelDistance = prev?.travelDistance ?? 0;
|
|
2069
2251
|
const distance = Math.min(this.SINGLE_SPACING_THRESHOLD, travelDistance + current.minimumJumpDistance);
|
|
2070
|
-
return ((speedBonus +
|
|
2252
|
+
return (((speedBonus +
|
|
2071
2253
|
speedBonus *
|
|
2072
|
-
Math.pow(distance / this.SINGLE_SPACING_THRESHOLD, 3.5))
|
|
2254
|
+
Math.pow(distance / this.SINGLE_SPACING_THRESHOLD, 3.5)) *
|
|
2255
|
+
doubletapness) /
|
|
2073
2256
|
strainTime);
|
|
2074
2257
|
}
|
|
2258
|
+
}
|
|
2259
|
+
|
|
2260
|
+
/**
|
|
2261
|
+
* An evaluator for calculating osu!standard Rhythm skill.
|
|
2262
|
+
*/
|
|
2263
|
+
class OsuRhythmEvaluator extends RhythmEvaluator {
|
|
2264
|
+
static rhythmMultiplier = 0.75;
|
|
2075
2265
|
/**
|
|
2076
|
-
*
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
this.strainValueOf(current) * this.skillMultiplier;
|
|
2082
|
-
this.currentRhythm = this.calculateRhythmBonus(current);
|
|
2083
|
-
return this.currentSpeedStrain * this.currentRhythm;
|
|
2084
|
-
}
|
|
2085
|
-
/**
|
|
2086
|
-
* Calculates a rhythm multiplier for the difficulty of the tap associated with historic data of the current object.
|
|
2266
|
+
* Calculates a rhythm multiplier for the difficulty of the tap associated
|
|
2267
|
+
* with historic data of the current object.
|
|
2268
|
+
*
|
|
2269
|
+
* @param current The current object.
|
|
2270
|
+
* @param greatWindow The great hit window of the current object.
|
|
2087
2271
|
*/
|
|
2088
|
-
|
|
2272
|
+
static evaluateDifficultyOf(current, greatWindow) {
|
|
2089
2273
|
if (current.object instanceof osuBase.Spinner) {
|
|
2090
2274
|
return 0;
|
|
2091
2275
|
}
|
|
@@ -2095,29 +2279,33 @@ class OsuSpeed extends OsuSkill {
|
|
|
2095
2279
|
// Store the ratio of the current start of an island to buff for tighter rhythms.
|
|
2096
2280
|
let startRatio = 0;
|
|
2097
2281
|
let firstDeltaSwitch = false;
|
|
2282
|
+
const historicalNoteCount = Math.min(current.index, 32);
|
|
2098
2283
|
let rhythmStart = 0;
|
|
2099
|
-
while (rhythmStart <
|
|
2100
|
-
current.startTime -
|
|
2284
|
+
while (rhythmStart < historicalNoteCount - 2 &&
|
|
2285
|
+
current.startTime - current.previous(rhythmStart).startTime <
|
|
2101
2286
|
this.historyTimeMax) {
|
|
2102
2287
|
++rhythmStart;
|
|
2103
2288
|
}
|
|
2104
2289
|
for (let i = rhythmStart; i > 0; --i) {
|
|
2290
|
+
const currentObject = current.previous(i - 1);
|
|
2291
|
+
const prevObject = current.previous(i);
|
|
2292
|
+
const lastObject = current.previous(i + 1);
|
|
2105
2293
|
// Scale note 0 to 1 from history to now.
|
|
2106
2294
|
let currentHistoricalDecay = (this.historyTimeMax -
|
|
2107
|
-
(current.startTime -
|
|
2295
|
+
(current.startTime - currentObject.startTime)) /
|
|
2108
2296
|
this.historyTimeMax;
|
|
2109
2297
|
// Either we're limited by time or limited by object count.
|
|
2110
|
-
currentHistoricalDecay = Math.min(currentHistoricalDecay, (
|
|
2111
|
-
const currentDelta =
|
|
2112
|
-
const prevDelta =
|
|
2113
|
-
const lastDelta =
|
|
2298
|
+
currentHistoricalDecay = Math.min(currentHistoricalDecay, (historicalNoteCount - i) / historicalNoteCount);
|
|
2299
|
+
const currentDelta = currentObject.strainTime;
|
|
2300
|
+
const prevDelta = prevObject.strainTime;
|
|
2301
|
+
const lastDelta = lastObject.strainTime;
|
|
2114
2302
|
const currentRatio = 1 +
|
|
2115
2303
|
6 *
|
|
2116
2304
|
Math.min(0.5, Math.pow(Math.sin(Math.PI /
|
|
2117
2305
|
(Math.min(prevDelta, currentDelta) /
|
|
2118
2306
|
Math.max(prevDelta, currentDelta))), 2));
|
|
2119
|
-
const windowPenalty = Math.min(1, Math.max(0, Math.abs(prevDelta - currentDelta) -
|
|
2120
|
-
(
|
|
2307
|
+
const windowPenalty = Math.min(1, Math.max(0, Math.abs(prevDelta - currentDelta) - greatWindow * 0.6) /
|
|
2308
|
+
(greatWindow * 0.6));
|
|
2121
2309
|
let effectiveRatio = windowPenalty * currentRatio;
|
|
2122
2310
|
if (firstDeltaSwitch) {
|
|
2123
2311
|
if (prevDelta <= 1.25 * currentDelta &&
|
|
@@ -2128,11 +2316,11 @@ class OsuSpeed extends OsuSkill {
|
|
|
2128
2316
|
}
|
|
2129
2317
|
}
|
|
2130
2318
|
else {
|
|
2131
|
-
if (
|
|
2319
|
+
if (currentObject.object instanceof osuBase.Slider) {
|
|
2132
2320
|
// BPM change is into slider, this is easy acc window.
|
|
2133
2321
|
effectiveRatio /= 8;
|
|
2134
2322
|
}
|
|
2135
|
-
if (
|
|
2323
|
+
if (prevObject.object instanceof osuBase.Slider) {
|
|
2136
2324
|
// BPM change was from a slider, this is typically easier than circle -> circle.
|
|
2137
2325
|
effectiveRatio /= 4;
|
|
2138
2326
|
}
|
|
@@ -2177,6 +2365,38 @@ class OsuSpeed extends OsuSkill {
|
|
|
2177
2365
|
}
|
|
2178
2366
|
return Math.sqrt(4 + rhythmComplexitySum * this.rhythmMultiplier) / 2;
|
|
2179
2367
|
}
|
|
2368
|
+
}
|
|
2369
|
+
|
|
2370
|
+
/**
|
|
2371
|
+
* Represents the skill required to press keys or tap with regards to keeping up with the speed at which objects need to be hit.
|
|
2372
|
+
*/
|
|
2373
|
+
class OsuSpeed extends OsuSkill {
|
|
2374
|
+
skillMultiplier = 1375;
|
|
2375
|
+
strainDecayBase = 0.3;
|
|
2376
|
+
reducedSectionCount = 5;
|
|
2377
|
+
reducedSectionBaseline = 0.75;
|
|
2378
|
+
difficultyMultiplier = 1.04;
|
|
2379
|
+
decayWeight = 0.9;
|
|
2380
|
+
currentSpeedStrain = 0;
|
|
2381
|
+
currentRhythm = 0;
|
|
2382
|
+
// ~200 1/4 BPM streams
|
|
2383
|
+
minSpeedBonus = 75;
|
|
2384
|
+
greatWindow;
|
|
2385
|
+
constructor(mods, greatWindow) {
|
|
2386
|
+
super(mods);
|
|
2387
|
+
this.greatWindow = greatWindow;
|
|
2388
|
+
}
|
|
2389
|
+
/**
|
|
2390
|
+
* @param current The hitobject to calculate.
|
|
2391
|
+
*/
|
|
2392
|
+
strainValueAt(current) {
|
|
2393
|
+
this.currentSpeedStrain *= this.strainDecay(current.strainTime);
|
|
2394
|
+
this.currentSpeedStrain +=
|
|
2395
|
+
OsuSpeedEvaluator.evaluateDifficultyOf(current, this.greatWindow) *
|
|
2396
|
+
this.skillMultiplier;
|
|
2397
|
+
this.currentRhythm = OsuRhythmEvaluator.evaluateDifficultyOf(current, this.greatWindow);
|
|
2398
|
+
return this.currentSpeedStrain * this.currentRhythm;
|
|
2399
|
+
}
|
|
2180
2400
|
/**
|
|
2181
2401
|
* @param current The hitobject to save to.
|
|
2182
2402
|
*/
|
|
@@ -2187,17 +2407,20 @@ class OsuSpeed extends OsuSkill {
|
|
|
2187
2407
|
}
|
|
2188
2408
|
|
|
2189
2409
|
/**
|
|
2190
|
-
*
|
|
2410
|
+
* An evaluator for calculating osu!standard Flashlight skill.
|
|
2191
2411
|
*/
|
|
2192
|
-
class
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2412
|
+
class OsuFlashlightEvaluator extends FlashlightEvaluator {
|
|
2413
|
+
/**
|
|
2414
|
+
* Evaluates the difficulty of memorizing and hitting the current object, based on:
|
|
2415
|
+
*
|
|
2416
|
+
* - distance between the previous and the current object,
|
|
2417
|
+
* - the visual opacity of the current object,
|
|
2418
|
+
* - and whether Hidden mod is enabled.
|
|
2419
|
+
*
|
|
2420
|
+
* @param current The current object.
|
|
2421
|
+
* @param isHiddenMod Whether the Hidden mod is enabled.
|
|
2422
|
+
*/
|
|
2423
|
+
static evaluateDifficultyOf(current, isHiddenMod) {
|
|
2201
2424
|
if (current.object instanceof osuBase.Spinner) {
|
|
2202
2425
|
return 0;
|
|
2203
2426
|
}
|
|
@@ -2206,8 +2429,8 @@ class OsuFlashlight extends OsuSkill {
|
|
|
2206
2429
|
let cumulativeStrainTime = 0;
|
|
2207
2430
|
let result = 0;
|
|
2208
2431
|
let last = current;
|
|
2209
|
-
for (let i = 0; i <
|
|
2210
|
-
const currentObject =
|
|
2432
|
+
for (let i = 0; i < Math.min(current.index, 10); ++i) {
|
|
2433
|
+
const currentObject = current.previous(i);
|
|
2211
2434
|
if (!(currentObject.object instanceof osuBase.Spinner)) {
|
|
2212
2435
|
const jumpDistance = current.object.stackedPosition.subtract(currentObject.object.endPosition).length;
|
|
2213
2436
|
cumulativeStrainTime += last.strainTime;
|
|
@@ -2217,21 +2440,47 @@ class OsuFlashlight extends OsuSkill {
|
|
|
2217
2440
|
}
|
|
2218
2441
|
// We also want to nerf stacks so that only the first object of the stack is accounted for.
|
|
2219
2442
|
const stackNerf = Math.min(1, currentObject.lazyJumpDistance / scalingFactor / 25);
|
|
2443
|
+
// Bonus based on how visible the object is.
|
|
2444
|
+
const opacityBonus = 1 +
|
|
2445
|
+
this.maxOpacityBonus *
|
|
2446
|
+
(1.0 -
|
|
2447
|
+
current.opacityAt(currentObject.startTime, isHiddenMod));
|
|
2220
2448
|
result +=
|
|
2221
|
-
(stackNerf * scalingFactor * jumpDistance) /
|
|
2449
|
+
(stackNerf * opacityBonus * scalingFactor * jumpDistance) /
|
|
2222
2450
|
cumulativeStrainTime;
|
|
2223
2451
|
}
|
|
2224
2452
|
last = currentObject;
|
|
2225
2453
|
}
|
|
2454
|
+
// Additional bonus for Hidden due to there being no approach circles.
|
|
2455
|
+
if (isHiddenMod) {
|
|
2456
|
+
result *= 1 + this.hiddenBonus;
|
|
2457
|
+
}
|
|
2226
2458
|
return Math.pow(smallDistNerf * result, 2);
|
|
2227
2459
|
}
|
|
2460
|
+
}
|
|
2461
|
+
|
|
2462
|
+
/**
|
|
2463
|
+
* Represents the skill required to memorize and hit every object in a beatmap with the Flashlight mod enabled.
|
|
2464
|
+
*/
|
|
2465
|
+
class OsuFlashlight extends OsuSkill {
|
|
2466
|
+
skillMultiplier = 0.05;
|
|
2467
|
+
strainDecayBase = 0.15;
|
|
2468
|
+
reducedSectionCount = 10;
|
|
2469
|
+
reducedSectionBaseline = 0.75;
|
|
2470
|
+
difficultyMultiplier = 1.06;
|
|
2471
|
+
decayWeight = 1;
|
|
2472
|
+
isHidden;
|
|
2473
|
+
constructor(mods) {
|
|
2474
|
+
super(mods);
|
|
2475
|
+
this.isHidden = mods.some((m) => m instanceof osuBase.ModHidden);
|
|
2476
|
+
}
|
|
2228
2477
|
/**
|
|
2229
2478
|
* @param current The hitobject to calculate.
|
|
2230
2479
|
*/
|
|
2231
2480
|
strainValueAt(current) {
|
|
2232
2481
|
this.currentStrain *= this.strainDecay(current.deltaTime);
|
|
2233
2482
|
this.currentStrain +=
|
|
2234
|
-
|
|
2483
|
+
OsuFlashlightEvaluator.evaluateDifficultyOf(current, this.isHidden) * this.skillMultiplier;
|
|
2235
2484
|
return this.currentStrain;
|
|
2236
2485
|
}
|
|
2237
2486
|
saveToHitObject(current) {
|
|
@@ -2609,10 +2858,6 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
|
|
|
2609
2858
|
Math.pow(Math.pow(this.stars.flashlight, this.stars.mods.some((m) => m instanceof osuBase.ModTouchDevice)
|
|
2610
2859
|
? 0.8
|
|
2611
2860
|
: 1), 2) * 25;
|
|
2612
|
-
// Add an additional bonus for HDFL.
|
|
2613
|
-
if (this.stars.mods.some((m) => m instanceof osuBase.ModHidden)) {
|
|
2614
|
-
this.flashlight *= 1.3;
|
|
2615
|
-
}
|
|
2616
2861
|
// Combo scaling
|
|
2617
2862
|
this.flashlight *= this.comboPenalty;
|
|
2618
2863
|
if (this.effectiveMissCount > 0) {
|
|
@@ -2648,21 +2893,34 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
|
|
|
2648
2893
|
}
|
|
2649
2894
|
}
|
|
2650
2895
|
|
|
2896
|
+
exports.AimEvaluator = AimEvaluator;
|
|
2651
2897
|
exports.DifficultyHitObject = DifficultyHitObject;
|
|
2652
2898
|
exports.DifficultyHitObjectCreator = DifficultyHitObjectCreator;
|
|
2653
2899
|
exports.DroidAim = DroidAim;
|
|
2900
|
+
exports.DroidAimEvaluator = DroidAimEvaluator;
|
|
2654
2901
|
exports.DroidFlashlight = DroidFlashlight;
|
|
2902
|
+
exports.DroidFlashlightEvaluator = DroidFlashlightEvaluator;
|
|
2655
2903
|
exports.DroidPerformanceCalculator = DroidPerformanceCalculator;
|
|
2656
2904
|
exports.DroidRhythm = DroidRhythm;
|
|
2905
|
+
exports.DroidRhythmEvaluator = DroidRhythmEvaluator;
|
|
2657
2906
|
exports.DroidStarRating = DroidStarRating;
|
|
2658
2907
|
exports.DroidTap = DroidTap;
|
|
2908
|
+
exports.DroidTapEvaluator = DroidTapEvaluator;
|
|
2659
2909
|
exports.DroidVisual = DroidVisual;
|
|
2910
|
+
exports.DroidVisualEvaluator = DroidVisualEvaluator;
|
|
2911
|
+
exports.FlashlightEvaluator = FlashlightEvaluator;
|
|
2660
2912
|
exports.MapStars = MapStars;
|
|
2661
2913
|
exports.OsuAim = OsuAim;
|
|
2914
|
+
exports.OsuAimEvaluator = OsuAimEvaluator;
|
|
2662
2915
|
exports.OsuFlashlight = OsuFlashlight;
|
|
2916
|
+
exports.OsuFlashlightEvaluator = OsuFlashlightEvaluator;
|
|
2663
2917
|
exports.OsuPerformanceCalculator = OsuPerformanceCalculator;
|
|
2918
|
+
exports.OsuRhythmEvaluator = OsuRhythmEvaluator;
|
|
2664
2919
|
exports.OsuSpeed = OsuSpeed;
|
|
2920
|
+
exports.OsuSpeedEvaluator = OsuSpeedEvaluator;
|
|
2665
2921
|
exports.OsuStarRating = OsuStarRating;
|
|
2666
2922
|
exports.PerformanceCalculator = PerformanceCalculator;
|
|
2923
|
+
exports.RhythmEvaluator = RhythmEvaluator;
|
|
2924
|
+
exports.SpeedEvaluator = SpeedEvaluator;
|
|
2667
2925
|
exports.StarRating = StarRating;
|
|
2668
2926
|
//# sourceMappingURL=index.js.map
|