Skip to content

Commit

Permalink
re-enable and unbreak jackstam and get the debugging for it "right"
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed May 21, 2020
1 parent 6b069ab commit 45be862
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 27 deletions.
73 changes: 48 additions & 25 deletions src/Etterna/Globals/MinaCalc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,33 +323,40 @@ static const float basescalers[NUM_Skillset] = { 0.f, 0.97f, 0.89f, 0.89f,
// SOMEHOW MAKES JAKES EASIER SO DISABLED FOR NOW (it's also sort of redundant
// with the entire system as it is so this may not be needed
inline void
Calc::JackStamAdjust(float x, int t, int mode)
Calc::JackStamAdjust(float x, int t, int mode, bool debug)
{
float stam_floor =
0.95f; // stamina multiplier min (increases as chart advances)
float mod = 0.95f; // mutliplier

const bool dbg = true && debug;

float stam_ceil = 1.075234f;
float stam_mag = 75.f;
float stam_fscale = 125.f;
float stam_prop = 0.55424f;
float stam_floor = 1.f;
float mod = 1.f;
if (mode == 4)
stam_mag *= 4;
float avs1 = 0.f;
float avs2 = 0.f;
float local_ceil = stam_ceil;
const float super_stam_ceil = 1.11f;
const float super_stam_ceil = 1.09f;
const auto& diff = jacks[mode][t];

static const float stam_ceil = 1.035234f; // stamina multiplier max
static const float stam_mag = 75.f; // multiplier generation scaler
static const float stam_fscale =
125.f; // how fast the floor rises (it's lava)
static const float stam_prop = 1.5424f;

if (debugmode) {
if (debug) {
left_hand.debugValues[2][JackStamMod].resize(numitv);
right_hand.debugValues[2][JackStamMod].resize(numitv);

// each interval
for (size_t i = 0; i < diff.size(); ++i) {
float mod_sum = 0.f;
// each jack in the interval
for (size_t j = 0; j < diff[i].size(); ++j) {
avs1 = avs2;
avs2 = diff[i][j];

if (dbg)
std::cout << "mod was : " << mod
<< " at diff : " << diff[i][j] << std::endl;

mod +=
((((avs1 + avs2) / 2.f) / (stam_prop * x)) - 1.f) / stam_mag;
if (mod > 0.95f)
Expand All @@ -358,6 +365,10 @@ Calc::JackStamAdjust(float x, int t, int mode)

mod =
min(CalcClamp(mod, stam_floor, local_ceil), super_stam_ceil);

if (dbg)
std::cout << "mod now : " << mod << std::endl;

mod_sum += mod;
stam_adj_jacks[t][i][j] = diff[i][j] * mod;
}
Expand Down Expand Up @@ -398,15 +409,15 @@ hit_the_road(float x, float y, int mode)

// returns a positive number or 0, output should be subtracted
float
Calc::JackLoss(float x, int mode, float mpl, bool stam)
Calc::JackLoss(float x, int mode, float mpl, bool stam, bool debug)
{
const bool dbg = false && debugmode;
// adjust for stam before main loop, since main loop is interval -> track
// and not track -> interval, we could also try doing this on the fly with
// an inline but i cba to mess with that atm
if (stam)
for (auto t : { 0, 1, 2, 3 })
JackStamAdjust(x, t, mode);
JackStamAdjust(x, t, mode, debug);

float total_point_loss = 0.f;
// we should just store jacks in intervals in the first place
Expand All @@ -419,11 +430,10 @@ Calc::JackLoss(float x, int mode, float mpl, bool stam)
for (int i = 0; i < numitv; ++i) {
// yes i think this does just have to be this slow
for (auto& t : zto3) {
// stam is broken atm and also redundant with stuffs
// const auto& seagull = stam ? stam_adj_jacks[t][i] :
// jacks[mode][t][i];
const auto& seagull =
stam ? stam_adj_jacks[t][i] : jacks[mode][t][i];
float loss = 0.f;
for (auto& j : jacks[mode][t][i]) {
for (auto& j : seagull) {
if (x >= j)
continue;
loss += hit_the_road(x, j, mode);
Expand Down Expand Up @@ -553,7 +563,6 @@ Calc::SequenceJack(const Finger& f, int track, int mode)
std::cout << "fdiff: " << jacks[mode][track][itv][ind] << "\n"
<< std::endl;
}

}
}
}
Expand Down Expand Up @@ -1023,15 +1032,15 @@ Calc::Chisel(float player_skill,
// multiple points throughout a file, that just results in
// oversaturation and bad grouping
float jloss = max(
JackLoss(player_skill, 1, max_points_lost, false),
max(JackLoss(player_skill, 2, max_points_lost, false),
JackLoss(player_skill, 3, max_points_lost, false)));
JackLoss(player_skill, 1, max_points_lost, true),
max(JackLoss(player_skill, 2, max_points_lost, true),
JackLoss(player_skill, 3, max_points_lost, true)));
gotpoints -= jloss;
} else {
if (ss == Skill_Technical)
/*if (ss == Skill_Technical)
gotpoints -=
(JackLoss(player_skill, 0, max_points_lost, false)) /
7.5f;
7.5f;*/
left_hand.CalcInternal(
gotpoints, player_skill, ss, stamina);
if (gotpoints > reqpoints)
Expand All @@ -1048,7 +1057,21 @@ Calc::Chisel(float player_skill,
// these are the values for msd/stam adjusted msd/pointloss the
// latter two are dependent on player_skill and so should only
// be recalculated with the final value already determined
// getting the jackstam debug output right is lame i know
if (debugoutput) {
float jl1 =
JackLoss(player_skill, 1, max_points_lost, true, debugoutput);
float jl2 =
JackLoss(player_skill, 2, max_points_lost, true, debugoutput);
float jl3 =
JackLoss(player_skill, 3, max_points_lost, true, debugoutput);
if (jl1 > jl2 && jl1 > jl3)
JackLoss(player_skill, 1, max_points_lost, true, debugoutput);
else if (jl2 > jl3)
JackLoss(player_skill, 2, max_points_lost, true, debugoutput);
else
JackLoss(player_skill, 3, max_points_lost, true, debugoutput);

left_hand.CalcInternal(
gotpoints, player_skill, ss, stamina, debugoutput);
right_hand.CalcInternal(
Expand Down
4 changes: 2 additions & 2 deletions src/Etterna/Globals/MinaCalc.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ class Calc
float music_rate,
float score_goal);

void JackStamAdjust(float x, int t, int mode);
float JackLoss(float x, int mode, float mpl, bool stam);
void JackStamAdjust(float x, int t, int mode, bool debug = false);
float JackLoss(float x, int mode, float mpl, bool stam, bool debug = false);
void SequenceJack(const Finger& f, int track, int mode);

bool debugmode = false;
Expand Down

0 comments on commit 45be862

Please sign in to comment.