Etterna 0.74.4
Loading...
Searching...
No Matches
MinaCalc.h
1#pragma once
2#include "../Models/NoteData/NoteDataStructures.h"
3#include <string>
4#include <vector>
5#include <array>
6#include <memory>
7#include <unordered_map>
8
9// For internal, must be preprocessor defined
10#if defined(MINADLL_COMPILE) && defined(_WIN32)
11#define MINACALC_API __declspec(dllexport)
12#endif
13
14// For Stepmania
15#ifndef MINACALC_API
16#define MINACALC_API
17#endif
18
20using MinaSD = std::vector<std::vector<float>>;
21
22class Calc;
23struct Bazoinkazoink;
24
30static constexpr int default_interval_count = 1000;
31
35static constexpr int max_intervals = 100000;
36
42static constexpr int max_rows_for_single_interval = 50;
43
48enum hands
49{
50 left_hand,
51 right_hand,
52 num_hands,
53};
54
56static constexpr hands both_hands[num_hands] = { left_hand, right_hand };
57
62struct RowInfo
63{
68 unsigned row_notes = 0U;
69
71 int row_count = 0;
72
74 std::array<int, num_hands> hand_counts = { 0, 0 };
75
77 float row_time = 0.F;
78};
79
81class Calc
82{
83 public:
90 auto CalcMain(const std::vector<NoteInfo>& NoteInfo,
91 float music_rate,
92 float score_goal) -> std::vector<float>;
93
95 bool debugmode = false;
96
98 bool ssr = true;
99
101 bool loadparams = false;
102
104 unsigned keycount = 4;
105 std::array<unsigned, num_hands> hand_col_masks = { 0U, 0U };
106 std::vector<unsigned> col_masks{};
107 std::shared_ptr<Bazoinkazoink> ulbu_in_charge;
108
109 private:
114 void InitializeKeycountLogic();
115 std::unordered_map<unsigned, std::shared_ptr<Bazoinkazoink>> ulbu_collective{};
116
125 auto InitializeHands(
126 const std::vector<NoteInfo>& NoteInfo,
127 float music_rate,
128 float offset) -> bool;
129
135 auto Chisel(float player_skill,
136 float resolution,
137 float score_goal,
138 Skillset ss,
139 bool stamina,
140 bool debugoutput = false) -> float;
141
147 static inline void InitAdjDiff(
148 Calc& calc,
149 const int& hand);
150
151 public:
155 Calc() { resize_interval_dependent_vectors(default_interval_count); }
156
161 std::vector<std::array<RowInfo, max_rows_for_single_interval>>
163
165 std::vector<int> itv_size{};
166
171 std::array<std::vector<int>, num_hands> itv_points{};
172
177 std::array<std::array<std::vector<float>, NUM_CalcPatternMod>,
178 num_hands>
180
185 std::array<std::array<std::vector<float>, NUM_CalcDiffValue>,
186 num_hands>
188
209 std::array<std::array<std::vector<float>, NUM_Skillset>,
210 num_hands>
212
219 std::array<std::array<std::vector<float>, NUM_Skillset>,
220 num_hands>
222
230 std::vector<float> stam_adj_diff{};
231
239 std::array<std::vector<std::pair<float, float>>, num_hands> jack_diff{};
240
241 // number of jacks by hand for intervals
242 // std::array<std::vector<int>, num_hands>
243 // itv_jack_diff_size{};
244
246 std::array<std::vector<float>, num_hands> jack_loss{};
247
249 std::array<std::vector<float>, num_hands> jack_stam_stuff{};
250
255 std::array<float, max_rows_for_single_interval> tc_static{};
256
260 std::array<float, max_rows_for_single_interval> cj_static{};
261
263 int numitv = 0;
264
266 float MaxPoints = 0;
267
270 float grindscaler = 1.F;
271
277 std::array<std::vector<std::vector<std::vector<float>>>, num_hands>
279 std::array<std::array<std::vector<float>, NUM_Skillset>, num_hands> debugMSD{};
280 std::array<std::array<std::vector<float>, NUM_Skillset>, num_hands> debugPtLoss{};
281 std::array<std::array<std::vector<float>, NUM_Skillset>, num_hands> debugTotalPatternMod{};
282
285 std::array<std::array<std::vector<std::pair<float, float>>, 2>, num_hands>
287
289 std::array<std::vector<std::array<float, 4>>, num_hands> debugTechVals{};
290
296 {
297 // there isn't a real need to make our vectors smaller
298 if (amt < adj_ni.size())
299 return;
300
301 // grow each vector
302 // resize is used to construct defaults, the space should be used immediately
303 adj_ni.resize(amt);
304 itv_size.resize(amt);
305 for (auto& v : itv_points)
306 v.resize(amt);
307 for (auto& a : pmod_vals)
308 for (auto& v : a)
309 v.resize(amt);
310 for (auto& a : init_base_diff_vals)
311 for (auto& v : a)
312 v.resize(amt);
313 for (auto& a : base_adj_diff)
314 for (auto& v : a)
315 v.resize(amt);
316 for (auto& a : base_diff_for_stam_mod)
317 for (auto& v : a)
318 v.resize(amt);
319 stam_adj_diff.resize(amt);
320 }
321};
322
332MINACALC_API auto
333MinaSDCalc(const std::vector<NoteInfo>& NoteInfo,
334 float musicrate,
335 float goal,
336 const unsigned keycount,
337 Calc* calc) -> std::vector<float>;
346MINACALC_API auto
347MinaSDCalc(const std::vector<NoteInfo>& NoteInfo,
348 const unsigned keycount,
349 Calc* calc) -> MinaSD;
362MINACALC_API void
363MinaSDCalcDebug(
364 const std::vector<NoteInfo>& NoteInfo,
365 float musicrate,
366 float goal,
367 const unsigned keycount,
368 std::vector<std::vector<std::vector<std::vector<float>>>>& handInfo,
369 std::vector<std::string>& debugstrings,
370 Calc& calc);
372MINACALC_API auto
373GetCalcVersion() -> int;
Main driver class for the difficulty calculator as a whole.
Definition MinaCalc.h:82
std::array< std::vector< std::array< float, 4 > >, num_hands > debugTechVals
per hand vector of arrays: techyo chaos values of [row_time, pewp, obliosis, c]
Definition MinaCalc.h:289
bool loadparams
Set true to force calc params to load outside debug mode.
Definition MinaCalc.h:101
std::array< std::array< std::vector< float >, NUM_CalcDiffValue >, num_hands > init_base_diff_vals
Definition MinaCalc.h:187
int numitv
Total number of intervals for the current file/rate (one per half second)
Definition MinaCalc.h:263
std::array< std::vector< float >, num_hands > jack_stam_stuff
Only used for debugging jack stamina related adjustments to jack_diff.
Definition MinaCalc.h:249
std::vector< float > stam_adj_diff
Definition MinaCalc.h:230
std::array< float, max_rows_for_single_interval > tc_static
Definition MinaCalc.h:255
std::array< std::array< std::vector< float >, NUM_Skillset >, num_hands > base_diff_for_stam_mod
Definition MinaCalc.h:221
std::array< std::array< std::vector< std::pair< float, float > >, 2 >, num_hands > debugMovingWindowCV
Definition MinaCalc.h:286
float grindscaler
Definition MinaCalc.h:270
void resize_interval_dependent_vectors(size_t amt)
Definition MinaCalc.h:295
std::vector< std::array< RowInfo, max_rows_for_single_interval > > adj_ni
Definition MinaCalc.h:162
std::array< std::array< std::vector< float >, NUM_CalcPatternMod >, num_hands > pmod_vals
Definition MinaCalc.h:179
bool ssr
Set true for score related output, and false for MSD caching.
Definition MinaCalc.h:98
unsigned keycount
Assigns the keymode specific logic.
Definition MinaCalc.h:104
Calc()
Definition MinaCalc.h:155
bool debugmode
For debug output. Should only ever be true at music select.
Definition MinaCalc.h:95
std::array< std::vector< float >, num_hands > jack_loss
unused - formerly populated by jack related point loss values
Definition MinaCalc.h:246
auto CalcMain(const std::vector< NoteInfo > &NoteInfo, float music_rate, float score_goal) -> std::vector< float >
Definition MinaCalc.cpp:51
std::array< std::vector< std::vector< std::vector< float > > >, num_hands > debugValues
Definition MinaCalc.h:278
std::array< std::vector< int >, num_hands > itv_points
Definition MinaCalc.h:171
std::array< std::vector< std::pair< float, float > >, num_hands > jack_diff
Definition MinaCalc.h:239
std::array< float, max_rows_for_single_interval > cj_static
Definition MinaCalc.h:260
float MaxPoints
Total points achievable in the current file (two per note)
Definition MinaCalc.h:266
std::vector< int > itv_size
Number of rows in each interval.
Definition MinaCalc.h:165
std::array< std::array< std::vector< float >, NUM_Skillset >, num_hands > base_adj_diff
Definition MinaCalc.h:211
Definition UlbuBase.h:15
Definition NoteDataStructures.h:7
Definition MinaCalc.h:63
float row_time
Rate-scaled time of this row.
Definition MinaCalc.h:77
unsigned row_notes
Definition MinaCalc.h:68
std::array< int, num_hands > hand_counts
Counting the left handed and right handed notes in this row.
Definition MinaCalc.h:74
int row_count
1-4 referring to if the row is a tap, jump, hand, or quad.
Definition MinaCalc.h:71