Skip to content

Commit

Permalink
ulbu reorg, begin generic ss pmods | 511
Browse files Browse the repository at this point in the history
  • Loading branch information
poco0317 committed Sep 4, 2023
1 parent 0551a9a commit 602e718
Show file tree
Hide file tree
Showing 15 changed files with 561 additions and 245 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,9 @@ local modnames = {
--"rpos",
--"rpj",
"totpm",

"gstrea",
"gchstr",
"gbrack",

-- CalcPatternMods above this line
-- CalcDebugMisc mods meant for only the top graph:
Expand Down Expand Up @@ -1020,7 +1022,9 @@ local modColors = {
--color("1,1,1"), -- rpos
--color("1,1,1"), -- rpj
color("0.7,1,0"), -- lime = totalpatternmod

color("1,1,1"), -- genericstream
color("1,1,1"), -- genericchordstream
color("1,1,1"), -- genericbracketing

-- place CalcPatternMod Colors above this line
-- MISC MODS START HERE (same order as miscToUpperMods)
Expand Down
6 changes: 6 additions & 0 deletions Themes/Til Death/BGAnimations/_calcdisplay.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,9 @@ local modnames = {
--"rpos",
--"rpj",
"totpm",
"gstrea",
"gchstr",
"gbrack",


-- CalcPatternMods above this line
Expand Down Expand Up @@ -1263,6 +1266,9 @@ local modColors = {
--color("1,1,1"), -- rpos
--color("1,1,1"), -- rpj
color("0.7,1,0"), -- lime = totalpatternmod
color("1,1,1"), -- genericstream
color("1,1,1"), -- genericchordstream
color("1,1,1"), -- genericbracketing


-- place CalcPatternMod Colors above this line
Expand Down
5 changes: 4 additions & 1 deletion src/Etterna/MinaCalc/Agnostic/HA_PatternMods/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ list(APPEND HA_PATTERN_MODS
"HSDensity.h"
"JS.h"
"Stream.h"
"TheThingFinder.h")
"TheThingFinder.h"
"GenericStream.h"
"GenericChordstream.h"
"GenericBracketing.h")

target_sources(Etterna PUBLIC ${HA_PATTERN_MODS})
128 changes: 128 additions & 0 deletions src/Etterna/MinaCalc/Agnostic/HA_PatternMods/GenericBracketing.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
#pragma once
#include "../../PatternModHelpers.h"
#include "../MetaIntervalInfo.h"

/// Hand-Agnostic PatternMod detecting Handstream.
/// Looks for jacks, jumptrills, and hands (3-chords)
struct GBracketingMod
{
const CalcPatternMod _pmod = GBracketing;
// const std::vector<CalcPatternMod> _dbg = { HSS, HSJ };
const std::string name = "GenericBracketingMod";
const int min_tap_size = jump;

#pragma region params

float min_mod = 0.6F;
float max_mod = 1.1F;
float mod_base = 0.4F;
float prop_buffer = 1.F;

float total_prop_min = min_mod;
float total_prop_max = max_mod;

// was ~32/7, is higher now to push up light hs (maybe overkill tho)
float total_prop_scaler = 5.571F;
float total_prop_base = 0.4F;

float split_hand_pool = 1.6F;
float split_hand_min = 0.89F;
float split_hand_max = 1.F;
float split_hand_scaler = 1.F;

float jack_pool = 1.35F;
float jack_min = 0.5F;
float jack_max = 1.F;
float jack_scaler = 1.F;

float decay_factor = 0.05F;

const std::vector<std::pair<std::string, float*>> _params{
{ "min_mod", &min_mod },
{ "max_mod", &max_mod },
{ "mod_base", &mod_base },
{ "prop_buffer", &prop_buffer },

{ "total_prop_scaler", &total_prop_scaler },
{ "total_prop_min", &total_prop_min },
{ "total_prop_max", &total_prop_max },
{ "total_prop_base", &total_prop_base },

{ "split_hand_pool", &split_hand_pool },
{ "split_hand_min", &split_hand_min },
{ "split_hand_max", &split_hand_max },
{ "split_hand_scaler", &split_hand_scaler },

{ "jack_pool", &jack_pool },
{ "jack_min", &jack_min },
{ "jack_max", &jack_max },
{ "jack_scaler", &jack_scaler },

{ "decay_factor", &decay_factor },
};
#pragma endregion params and param map

float total_prop = 0.F;
float jumptrill_prop = 0.F;
float jack_prop = 0.F;
float last_mod = min_mod;
float pmod = min_mod;
float t_taps = 0.F;

void full_reset()
{
last_mod = min_mod;
}

void decay_mod()
{
pmod = std::clamp(last_mod - decay_factor, min_mod, max_mod);
last_mod = pmod;
}

auto operator()(const metaItvInfo& mitvi) -> float
{
const auto& itvi = mitvi._itvi;

// empty interval, don't decay mod or update last_mod
if (itvi.total_taps == 0) {
return neutral;
}

// look ma no hands
if (itvi.taps_by_size.at(min_tap_size) == 0) {
decay_mod();
return pmod;
}

t_taps = static_cast<float>(itvi.total_taps);

// when bark of dog into canyon scream at you
total_prop = total_prop_base +
(static_cast<float>((itvi.taps_by_size.at(min_tap_size)) +
prop_buffer) /
(t_taps - prop_buffer) * total_prop_scaler);
total_prop =
std::clamp(fastsqrt(total_prop), total_prop_min, total_prop_max);

// downscale by jack density rather than upscale, like cj does
jack_prop = std::clamp(
jack_pool - (static_cast<float>(mitvi.actual_jacks) / t_taps),
jack_min,
jack_max);

pmod =
std::clamp(total_prop * jumptrill_prop * jack_prop, min_mod, max_mod);

if (mitvi.dunk_it) {
pmod *= 0.99F;
}

// set last mod, we're using it to create a decaying mod that won't
// result in extreme spikiness if files alternate between js and
// hs/stream
last_mod = pmod;

return pmod;
}
};
139 changes: 139 additions & 0 deletions src/Etterna/MinaCalc/Agnostic/HA_PatternMods/GenericChordstream.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
#pragma once
#include "../../PatternModHelpers.h"

/// Hand-Agnostic PatternMod detecting Jumpstream.
/// Looks for jacks, jumptrills, and jumps (2-chords)
struct GChordStreamMod
{
const CalcPatternMod _pmod = GChordStream;
// const std::vector<CalcPatternMod> _dbg = { JSS, JSJ };
const std::string name = "GenericChordStreamMod";
const int min_tap_size = jump;

#pragma region params
float min_mod = 0.6F;
float max_mod = 1.1F;
float mod_base = 0.F;
float prop_buffer = 1.F;

float total_prop_min = min_mod;
float total_prop_max = max_mod;
float total_prop_scaler = 2.714F; // ~19/7

float split_hand_pool = 1.5F;
float split_hand_min = 0.9F;
float split_hand_max = 1.F;
float split_hand_scaler = 1.F;

float jack_pool = 1.35F;
float jack_min = 0.5F;
float jack_max = 1.F;
float jack_scaler = 1.F;

float decay_factor = 0.05F;

const std::vector<std::pair<std::string, float*>> _params{
{ "min_mod", &min_mod },
{ "max_mod", &max_mod },
{ "mod_base", &mod_base },
{ "prop_buffer", &prop_buffer },

{ "total_prop_scaler", &total_prop_scaler },
{ "total_prop_min", &total_prop_min },
{ "total_prop_max", &total_prop_max },

{ "split_hand_pool", &split_hand_pool },
{ "split_hand_min", &split_hand_min },
{ "split_hand_max", &split_hand_max },
{ "split_hand_scaler", &split_hand_scaler },

{ "jack_pool", &jack_pool },
{ "jack_min", &jack_min },
{ "jack_max", &jack_max },
{ "jack_scaler", &jack_scaler },

{ "decay_factor", &decay_factor },
};
#pragma endregion params and param map

float total_prop = 0.F;
float jumptrill_prop = 0.F;
float jack_prop = 0.F;
float last_mod = min_mod;
float pmod = min_mod;
float t_taps = 0.F;

// inline void set_dbg(std::vector<float> doot[], const int& i)
//{
// doot[JSS][i] = jumptrill_prop;
// doot[JSJ][i] = jack_prop;
//}

void full_reset()
{
last_mod = min_mod;
}

void decay_mod()
{
pmod = std::clamp(last_mod - decay_factor, min_mod, max_mod);
last_mod = pmod;
}

auto operator()(const metaItvInfo& mitvi) -> float
{
const auto& itvi = mitvi._itvi;

// empty interval, don't decay js mod or update last_mod
if (itvi.total_taps == 0) {
return neutral;
}

// at least 1 tap but no jumps
if (itvi.taps_by_size.at(min_tap_size) == 0) {
decay_mod();
return pmod;
}

/* end case optimizations */

t_taps = static_cast<float>(itvi.total_taps);

// creepy banana
total_prop =
static_cast<float>(itvi.taps_by_size.at(min_tap_size) + prop_buffer) /
(t_taps - prop_buffer) * total_prop_scaler;
total_prop =
std::clamp(fastsqrt(total_prop), total_prop_min, total_prop_max);

// punish lots splithand jumptrills
// uhh this might also catch oh jumptrills can't remember
jumptrill_prop = std::clamp(
split_hand_pool - (static_cast<float>(mitvi.not_js) / t_taps),
split_hand_min,
split_hand_max);

// downscale by jack density rather than upscale like cj
// theoretically the ohjump downscaler should handle
// this but handling it here gives us more flexbility
// with the ohjump mod
jack_prop = std::clamp(
jack_pool - (static_cast<float>(mitvi.actual_jacks) / t_taps),
jack_min,
jack_max);

pmod =
std::clamp(total_prop * jumptrill_prop * jack_prop, min_mod, max_mod);

if (mitvi.dunk_it) {
pmod *= 0.99F;
}

// set last mod, we're using it to create a decaying mod that won't
// result in extreme spikiness if files alternate between js and
// hs/stream
last_mod = pmod;

return pmod;
}
};
Loading

0 comments on commit 602e718

Please sign in to comment.