@rian8337/osu-rebalance-difficulty-calculator 1.2.7 → 1.3.0

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 CHANGED
@@ -28,6 +28,10 @@ yarn add @rian8337/osu-base @rian8337/osu-rebalance-difficulty-calculator
28
28
 
29
29
  ## General usage
30
30
 
31
+ # Usage
32
+
33
+ ## Difficulty calculator
34
+
31
35
  ```js
32
36
  import { MapInfo } from "@rian8337/osu-base";
33
37
  import {
@@ -67,7 +71,7 @@ console.log(rating.droidStars);
67
71
  console.log(rating.pcStars);
68
72
  ```
69
73
 
70
- ## Specifying parameters
74
+ ### Specifying difficulty calculation parameters
71
75
 
72
76
  Parameters can be applied to alter the result of the calculation:
73
77
 
@@ -104,3 +108,103 @@ console.log(rating.droidStars);
104
108
  // osu!standard difficulty
105
109
  console.log(rating.pcStars);
106
110
  ```
111
+
112
+ ## Performance calculator
113
+
114
+ ```js
115
+ import { MapInfo } from "@rian8337/osu-base";
116
+ import {
117
+ DroidPerformanceCalculator,
118
+ MapStars,
119
+ OsuPerformanceCalculator,
120
+ } from "@rian8337/osu-rebalance-difficulty-calculator";
121
+
122
+ const beatmapInfo = await MapInfo.getInformation({ beatmapID: 901854 });
123
+
124
+ if (!beatmapInfo.title) {
125
+ return console.log("Beatmap not found");
126
+ }
127
+
128
+ const rating = new MapStars().calculate({
129
+ map: beatmapInfo.map,
130
+ });
131
+
132
+ // osu!droid performance
133
+ const droidPerformance = new DroidPerformanceCalculator().calculate({
134
+ stars: rating.droidStars,
135
+ });
136
+
137
+ console.log(droidPerformance);
138
+
139
+ // osu!standard performance
140
+ const osuPerformance = new OsuPerformanceCalculator().calculate({
141
+ stars: rating.pcStars,
142
+ });
143
+
144
+ console.log(osuPerformance);
145
+ ```
146
+
147
+ ### Specifying performance calculation parameters
148
+
149
+ Parameters can be passed to alter the result of the calculation:
150
+
151
+ - Combo: The maximum combo achieved. Defaults to the beatmap's maximum combo.
152
+ - Accuracy: The accuracy achieved. Defaults to 100%.
153
+ - Misses: The amount of misses achieved.
154
+ - Tap penalty: Penalty given from three-finger detection. Only applied for osu!droid gamemode. Defaults to 1.
155
+ - Custom statistics: Used to apply a custom speed multiplier and force AR. Defaults to none.
156
+
157
+ ```js
158
+ import { Accuracy, MapInfo, MapStats } from "@rian8337/osu-base";
159
+ import {
160
+ OsuPerformanceCalculator,
161
+ OsuStarRating,
162
+ } from "@rian8337/osu-rebalance-difficulty-calculator";
163
+
164
+ const beatmapInfo = await MapInfo.getInformation({ beatmapID: 901854 });
165
+
166
+ if (!beatmapInfo.title) {
167
+ return console.log("Beatmap not found");
168
+ }
169
+
170
+ const rating = new OsuStarRating().calculate({
171
+ map: beatmapInfo.map,
172
+ });
173
+
174
+ const accuracy = new Accuracy({
175
+ // Specify your misses here
176
+ nmiss: 1,
177
+
178
+ // The module provides a convenient way to specify accuracy based on the data that you have
179
+ // Remove the codes below as you see fit
180
+
181
+ // If you have hit data (amount of 300s, 100s, and 50s)
182
+ n300: 1000,
183
+ n100: 0,
184
+ n50: 0,
185
+
186
+ // If you have accuracy percentage
187
+ // While this method is more convenient to use, the amount of 300s, 100s, and 50s will be estimated
188
+ // This will lead to values being off when calculating for specific accuracies
189
+ percent: 100,
190
+ nobjects: beatmapInfo.objects,
191
+ });
192
+
193
+ const stats = new MapStats({
194
+ ar: 9.5,
195
+ isForceAR: true,
196
+ speedMultiplier: 1.25,
197
+ });
198
+
199
+ const performance = new OsuPerformanceCalculator().calculate({
200
+ stars: rating,
201
+ combo: 1250,
202
+ accPercent: accuracy,
203
+ // The tap penalty can be properly obtained by checking a replay for three finger usage
204
+ // However, a custom value can also be provided
205
+ tapPenalty: 1.5,
206
+ stats: stats,
207
+ });
208
+
209
+ console.log(performance);
210
+ ```
@@ -53,7 +53,10 @@ class DroidPerformanceCalculator extends PerformanceCalculator_1.PerformanceCalc
53
53
  const calculatedAR = this.mapStatistics.ar;
54
54
  this.aim = this.baseValue(Math.pow(this.stars.aim, 0.8));
55
55
  if (this.effectiveMissCount > 0) {
56
- this.aim *= this.calculateMissPenalty(this.stars.attributes.aimDifficultStrainCount);
56
+ // Penalize misses by assessing # of misses relative to the total # of objects. Default a 3% reduction for any # of misses.
57
+ this.aim *=
58
+ 0.97 *
59
+ Math.pow(1 - Math.pow(this.effectiveMissCount / objectCount, 0.775), this.effectiveMissCount);
57
60
  }
58
61
  // Combo scaling
59
62
  this.aim *= this.comboPenalty;
@@ -101,7 +104,10 @@ class DroidPerformanceCalculator extends PerformanceCalculator_1.PerformanceCalc
101
104
  const calculatedAR = this.mapStatistics.ar;
102
105
  this.tap = this.baseValue(this.stars.tap);
103
106
  if (this.effectiveMissCount > 0) {
104
- this.tap *= this.calculateMissPenalty(this.stars.attributes.speedDifficultStrainCount);
107
+ // Penalize misses by assessing # of misses relative to the total # of objects. Default a 3% reduction for any # of misses.
108
+ this.tap *=
109
+ 0.97 *
110
+ Math.pow(1 - Math.pow(this.effectiveMissCount / objectCount, 0.775), Math.pow(this.effectiveMissCount, 0.875));
105
111
  }
106
112
  // Combo scaling
107
113
  this.tap *= this.comboPenalty;
@@ -223,19 +229,5 @@ class DroidPerformanceCalculator extends PerformanceCalculator_1.PerformanceCalc
223
229
  this.flashlight.toFixed(2) +
224
230
  " flashlight)");
225
231
  }
226
- /**
227
- * Calculates miss penalty.
228
- *
229
- * @param difficultStrainCount Difficult strain count from calculation.
230
- * @returns The miss penalty.
231
- */
232
- calculateMissPenalty(difficultStrainCount) {
233
- // Miss penalty assumes that a player will miss on the hardest parts of a map,
234
- // so we use the amount of relatively difficult sections to adjust miss penalty
235
- // to make it more punishing on maps with lower amount of hard sections.
236
- return (0.97 /
237
- (this.effectiveMissCount / (2 * Math.sqrt(difficultStrainCount)) +
238
- 1));
239
- }
240
232
  }
241
233
  exports.DroidPerformanceCalculator = DroidPerformanceCalculator;
@@ -167,11 +167,6 @@ class DroidStarRating extends StarRating_1.StarRating {
167
167
  this.starValue(aimSkillWithoutSliders.difficultyValue()) /
168
168
  this.aim;
169
169
  }
170
- const objectStrains = this.objects.map((v) => v.aimStrainWithSliders);
171
- const maxStrain = Math.max(...objectStrains);
172
- if (maxStrain) {
173
- this.attributes.aimDifficultStrainCount = objectStrains.reduce((a, v) => a + Math.pow(v / maxStrain, 4), 0);
174
- }
175
170
  }
176
171
  /**
177
172
  * Called after tap skill calculation.
@@ -191,7 +186,6 @@ class DroidStarRating extends StarRating_1.StarRating {
191
186
  const maxStrain = Math.max(...objectStrains);
192
187
  if (maxStrain) {
193
188
  this.attributes.speedNoteCount = objectStrains.reduce((total, next) => total + 1 / (1 + Math.exp(-((next / maxStrain) * 12 - 6))), 0);
194
- this.attributes.speedDifficultStrainCount = objectStrains.reduce((a, v) => a + Math.pow(v / maxStrain, 4), 0);
195
189
  }
196
190
  }
197
191
  /**
@@ -18,7 +18,7 @@ class DroidRhythm extends DroidSkill_1.DroidSkill {
18
18
  this.historyTimeMax = 5000; // 5 seconds of calculateRhythmBonus max.
19
19
  this.currentRhythm = 1;
20
20
  this.hitWindow = new osu_base_1.OsuHitWindow(overallDifficulty);
21
- const odScaling = Math.pow(this.hitWindow.overallDifficulty, 2) / 250;
21
+ const odScaling = Math.pow(this.hitWindow.overallDifficulty, 2) / 400;
22
22
  this.rhythmMultiplier =
23
23
  0.75 +
24
24
  (this.hitWindow.overallDifficulty >= 0 ? odScaling : -odScaling);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rian8337/osu-rebalance-difficulty-calculator",
3
- "version": "1.2.7",
3
+ "version": "1.3.0",
4
4
  "description": "A module for calculating osu!standard beatmap difficulty and performance value with respect to the latest osu!lazer difficulty and performance algorithm.",
5
5
  "keywords": [
6
6
  "osu",
@@ -11,6 +11,7 @@
11
11
  "license": "MIT",
12
12
  "main": "dist/index.js",
13
13
  "types": "typings/index.d.ts",
14
+ "typedocMain": "src/index.ts",
14
15
  "files": [
15
16
  "dist/**",
16
17
  "typings/**"
@@ -21,7 +22,6 @@
21
22
  },
22
23
  "scripts": {
23
24
  "build": "tsc",
24
- "generate-docs": "typedoc src/index.ts",
25
25
  "lint": "eslint --ext ts",
26
26
  "prepare": "npm run build",
27
27
  "test": "jest -i"
@@ -30,10 +30,10 @@
30
30
  "url": "https://github.com/Rian8337/osu-droid-module/issues"
31
31
  },
32
32
  "dependencies": {
33
- "@rian8337/osu-base": "^1.2.1"
33
+ "@rian8337/osu-base": "^1.3.0"
34
34
  },
35
35
  "publishConfig": {
36
36
  "access": "public"
37
37
  },
38
- "gitHead": "18927f60c831515a666c7f7400beaa7573f28b64"
38
+ "gitHead": "0efc41e2d7f077aaf388424318ee9bd356ff611f"
39
39
  }
@@ -276,13 +276,6 @@ declare module "@rian8337/osu-rebalance-difficulty-calculator" {
276
276
  */
277
277
  private calculateFlashlightValue(): void;
278
278
  override toString(): string;
279
- /**
280
- * Calculates miss penalty.
281
- *
282
- * @param difficultStrainCount Difficult strain count from calculation.
283
- * @returns The miss penalty.
284
- */
285
- private calculateMissPenalty(difficultStrainCount: number): number;
286
279
  }
287
280
 
288
281
  /**
@@ -877,9 +870,9 @@ declare module "@rian8337/osu-rebalance-difficulty-calculator" {
877
870
  */
878
871
  mode?: modes;
879
872
  /**
880
- * The speed penalty to apply for penalized scores. Only applies to droid gamemode.
873
+ * The tap penalty to apply for penalized scores. Only applies to droid gamemode.
881
874
  */
882
- speedPenalty?: number;
875
+ tapPenalty?: number;
883
876
  /**
884
877
  * Custom map statistics to apply custom speed multiplier and force AR values as well as old statistics.
885
878
  */
@@ -919,9 +912,9 @@ declare module "@rian8337/osu-rebalance-difficulty-calculator" {
919
912
  */
920
913
  mode?: modes;
921
914
  /**
922
- * The speed penalty to apply for penalized scores.
915
+ * The tap penalty to apply for penalized scores.
923
916
  */
924
- speedPenalty?: number;
917
+ tapPenalty?: number;
925
918
  /**
926
919
  * Custom map statistics to apply custom speed multiplier and force AR values as well as old statistics.
927
920
  */