Skip to content

Commit

Permalink
split minacalc pmod logic into keymodes
Browse files Browse the repository at this point in the history
made a bit of this code less static and more generic....
right now the extra keymode specific stuff isnt used
  • Loading branch information
poco0317 committed Aug 26, 2023
1 parent 4492d3e commit 9b5a56c
Show file tree
Hide file tree
Showing 11 changed files with 407 additions and 193 deletions.
10 changes: 9 additions & 1 deletion src/Etterna/MinaCalc/Agnostic/MetaRowInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ struct metaRowInfo
bool gluts_maybe = false; // not really used/tested yet
bool twas_jack = false;

Calc& _calc;

explicit metaRowInfo(Calc& calc)
: _calc(calc)
{

}

void reset()
{
time = s_init;
Expand Down Expand Up @@ -79,7 +87,7 @@ struct metaRowInfo
{
twas_jack = false;

for (const auto& id : col_ids) {
for (const auto& id : _calc.col_masks) {
if (is_jack_at_col(id, notes, last_notes)) {
// not scaled to the number of jacks anymore
++mitvi.actual_jacks;
Expand Down
4 changes: 3 additions & 1 deletion src/Etterna/MinaCalc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ list(APPEND GENERAL_CALC_SRC
"SequencedBaseDiffCalc.h"
"SequencingHelpers.h"
"Ulbu.h"
"UlbuAcolytes.h")
"UlbuAcolytes.h"
"UlbuBase.h"
"UlbuSevenKey.h")

target_sources(Etterna PUBLIC ${GENERAL_CALC_SRC})
8 changes: 8 additions & 0 deletions src/Etterna/MinaCalc/Dependent/MetaHandInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ struct metaHandInfo
int offhand_taps = 0;
int offhand_ohjumps = 0;

Calc& _calc;

explicit metaHandInfo(Calc& calc)
: _calc(calc)
{

}

/// we need to reset everything between hands or the trailing values from the
/// end of one will carry over into the start of the other, not a huge
/// practical deal but it could theoretically be abused and it's good
Expand Down
142 changes: 36 additions & 106 deletions src/Etterna/MinaCalc/MinaCalc.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "MinaCalc.h"
#include "Ulbu.h"
#include "UlbuSevenKey.h"
#include "MinaCalcHelpers.h"

#include <cmath>
Expand Down Expand Up @@ -475,21 +476,48 @@ Calc::InitializeHands(const std::vector<NoteInfo>& NoteInfo,

// ulbu calculates everything needed for the block below
// (mostly patternmods)
thread_local TheGreatBazoinkazoinkInTheSky ulbu_that_which_consumes_all(
*this);
thread_local std::unordered_map<unsigned, std::unique_ptr<Bazoinkazoink>> ulbu_collective{};

bool keycount_defined = false;
if (!ulbu_collective.contains(keycount)) {
switch (keycount) {
case 4u:
ulbu_collective.emplace(
keycount,
std::make_unique<TheGreatBazoinkazoinkInTheSky>(*this));
keycount_defined = true;
break;
case 7u:
ulbu_collective.emplace(
keycount,
std::make_unique<TheSevenFootedBazoinkazoink>(*this));
keycount_defined = true;
break;
default:
if (!ulbu_collective.contains(0u)) {
ulbu_collective.emplace(
0u, std::make_unique<Bazoinkazoink>(*this));
}
break;
}
} else {
keycount_defined = true;
}
auto t_keycount = keycount_defined ? keycount : 0u;
auto& all_consuming_ulbu = ulbu_collective.at(t_keycount);

// if debug, force params to load
if (debugmode || loadparams)
ulbu_that_which_consumes_all.load_calc_params_from_disk(true);
all_consuming_ulbu->load_calc_params_from_disk(true);

// reset ulbu patternmod structs
// run agnostic patternmod/sequence loop
// run dependent patternmod/sequence loop
ulbu_that_which_consumes_all();
(*all_consuming_ulbu)();

// loop over hands to set adjusted difficulties using the patternmods
for (const auto& hand : both_hands) {
InitAdjDiff(*this, hand);
InitAdjDiff(*this, all_consuming_ulbu, hand);

// post pattern mod smoothing for cj
// (Chordjack related tuning done: this is disabled for now)
Expand Down Expand Up @@ -720,107 +748,9 @@ Calc::Chisel(const float player_skill,
* misclassing hard and polluting leaderboards, and good scores on overrated
* files will simply produce high ratings in every category */
inline void
Calc::InitAdjDiff(Calc& calc, const int& hand)
Calc::InitAdjDiff(Calc& calc, std::unique_ptr<Bazoinkazoink>& all_consuming_ulbu, const int& hand)
{
static const std::array<std::vector<int>, NUM_Skillset> pmods_used = { {
// overall, nothing, don't handle here
{},

// stream
{
Stream,
OHTrill,
VOHTrill,
Roll,
Chaos,
WideRangeRoll,
WideRangeJumptrill,
WideRangeJJ,
FlamJam,
// OHJumpMod,
// Balance,
// RanMan,
// WideRangeBalance,
},

// js
{
JS,
// OHJumpMod,
// Chaos,
// Balance,
// TheThing,
// TheThing2,
WideRangeBalance,
WideRangeJumptrill,
WideRangeJJ,
// WideRangeRoll,
// OHTrill,
VOHTrill,
// Roll,
RollJS,
// RanMan,
FlamJam,
// WideRangeAnchor,
},

// hs
{
HS,
OHJumpMod,
TheThing,
// WideRangeAnchor,
WideRangeRoll,
WideRangeJumptrill,
WideRangeJJ,
OHTrill,
VOHTrill,
// Roll,
// RanMan,
FlamJam,
HSDensity,
},

// stam, nothing, don't handle here
{},

// jackspeed, doesn't use pmods (atm)
{},

// chordjack
{
CJ,
// CJDensity,
CJOHJump,
CJOHAnchor,
VOHTrill,
// WideRangeAnchor,
FlamJam, // you may say, why? why not?
// WideRangeJJ,
WideRangeJumptrill,
},

// tech, duNNO wat im DOIN
{
OHTrill,
VOHTrill,
Balance,
Roll,
// OHJumpMod,
Chaos,
WideRangeJumptrill,
WideRangeJJ,
WideRangeBalance,
WideRangeRoll,
FlamJam,
// RanMan,
Minijack,
// WideRangeAnchor,
TheThing,
TheThing2,
},
} };

const auto& pmods_used = all_consuming_ulbu->get_pmods();
std::array<float, NUM_Skillset> pmod_product_cur_interval = {};

// ok this loop is pretty wack i know, for each interval
Expand Down Expand Up @@ -1016,7 +946,7 @@ MinaSDCalcDebug(
}
}

int mina_calc_version = 505;
int mina_calc_version = 506;
auto
GetCalcVersion() -> int
{
Expand Down
11 changes: 10 additions & 1 deletion src/Etterna/MinaCalc/MinaCalc.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <string>
#include <vector>
#include <array>
#include <memory>

// For internal, must be preprocessor defined
#if defined(MINADLL_COMPILE) && defined(_WIN32)
Expand All @@ -18,6 +19,7 @@
using MinaSD = std::vector<std::vector<float>>;

class Calc;
struct Bazoinkazoink;

/** This defines the base size for each interval-based vector in MinaCalc.
* Each interval is one half second. If any situation arises in which the
Expand Down Expand Up @@ -97,6 +99,11 @@ class Calc
/// Set true to force calc params to load outside debug mode.
bool loadparams = false;

/// Assigns the keymode specific logic
unsigned keycount = 4;
std::array<unsigned, num_hands> hand_col_masks = { 0U, 0U };
std::vector<unsigned> col_masks{};

private:
/** Splits up the chart by each hand and processes them individually to
* produce hand specific base difficulty values, which are then passed to
Expand Down Expand Up @@ -127,7 +134,9 @@ class Calc
* Iterates over each interval, and every skillset for each interval.
* Skips iterations of Overall and Stamina (unaffected by patternmods).
*/
static inline void InitAdjDiff(Calc& calc, const int& hand);
static inline void InitAdjDiff(Calc& calc,
std::unique_ptr<Bazoinkazoink>& all_consuming_ulbu,
const int& hand);

public:
/** Each Calc instance created sets up the interval related vectors.
Expand Down
2 changes: 1 addition & 1 deletion src/Etterna/MinaCalc/SequencedBaseDiffCalc.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ struct nps
notes += cur.hand_counts.at(hand);

const auto& crt = cur.row_time;
switch (determine_col_type(cur.row_notes, hand_col_ids[hand])) {
switch (determine_col_type(cur.row_notes, calc.hand_col_masks[hand])) {
case col_left:
if (last_left_row_time != s_init) {
const auto left_ms =
Expand Down
46 changes: 28 additions & 18 deletions src/Etterna/MinaCalc/SequencingHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

/* generic sequencing functions and defs to help either agnostic or dependent
* sequencers do their stuff */
static const std::array<unsigned, 4> col_ids = { 1U, 2U, 4U, 8U };

/// default for any field tracking seconds
constexpr float s_init = -5.F;
Expand All @@ -14,26 +13,37 @@ constexpr float ms_init = 5000.F;
/// global multiplier to standardize baselines
constexpr float finalscaler = 3.632F * 1.06F;

// outputs 0b1111 for 4, 0b111 for 3, etc
inline auto
keycount_to_bin(const unsigned& keycount) -> unsigned
{
if (keycount < 2)
return 0b11;
return ~(~1 << (keycount - 1));
}

// outputs 0b1100 for 4, 0b110 for 3, etc
inline auto
right_mask(const unsigned& keycount) -> unsigned
{
if (keycount <= 2)
return 0b10;
return keycount_to_bin(keycount) >> (keycount / 2) << (keycount / 2);
}

// outputs 0b0011 for 4, 0b001 for 3, etc
inline auto
left_mask(const unsigned& keycount) -> unsigned
{
const auto m = right_mask(keycount);
return ~m & static_cast<int>(std::exp2(std::ceil(std::log2(m))) - 1);
}

// count number of 1's in noterow binary
inline auto
column_count(const unsigned& notes) -> int
{
// singles
if (notes == 1U || notes == 2U || notes == 4U || notes == 8U) {
return 1;
}

// hands
if (notes == 7U || notes == 11U || notes == 13U || notes == 14U) {
return 3;
}

// quad
if (notes == 15U) {
return 4;
}

// everything else is a jump
return 2;
return std::popcount(notes);
}

/// milliseconds between two given timestamps in seconds
Expand Down
Loading

0 comments on commit 9b5a56c

Please sign in to comment.