Skip to content

Commit

Permalink
bandaid nan's in right hand jack stam, add jack stam debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed Jul 20, 2020
1 parent ec48292 commit 60aa6a4
Show file tree
Hide file tree
Showing 7 changed files with 230 additions and 125 deletions.
59 changes: 57 additions & 2 deletions Themes/Til Death/BGAnimations/_calcdisplay.lua
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,10 @@ local function updateCoolStuff()
local upperiter = #jap["Left"] > #jap["Right"] and #jap["Left"] or #jap["Right"]
for i = 1, upperiter do
if jap["Left"][i] then
jackdiffs["Left"][#jackdiffs["Left"] + 1] = { jap["Left"][i][1] + firstSecond/2/getCurRateValue(), jap["Left"][i][2] }
jackdiffs["Left"][#jackdiffs["Left"] + 1] = { jap["Left"][i][1] + firstSecond/2/getCurRateValue(), jap["Left"][i][2], jap["Left"][i][3] }
end
if jap["Right"][i] then
jackdiffs["Right"][#jackdiffs["Right"] + 1] = { jap["Right"][i][1] + firstSecond/2/getCurRateValue(), jap["Right"][i][2] }
jackdiffs["Right"][#jackdiffs["Right"] + 1] = { jap["Right"][i][1] + firstSecond/2/getCurRateValue(), jap["Right"][i][2], jap["Right"][i][3] }
end
end

Expand Down Expand Up @@ -774,6 +774,7 @@ o[#o + 1] = Def.Quad {
local hand = h == 1 and "L" or "R"
local index = convertPercentToIndexForJack(mx - leftEnd, rightEnd - leftEnd, jackdiffs[hnd])
local txt = string.format("%s: %5.4f\n", "Jack"..hand, jackdiffs[hnd][index][2])
local txt = string.format("%s: %5.4f\n", "Jack Stam"..hand, jackdiffs[hnd][index][3])
modText = modText .. txt
end
modText = modText:sub(1, #modText-1) -- remove the end whitespace
Expand Down Expand Up @@ -1174,6 +1175,55 @@ local function topGraphLine(mod, colorToUse, hand)
}
end

local function topGraphLineJackStam(mod, colorToUse, hand)
return Def.ActorMultiVertex {
InitCommand = function(self)
self:y(plotHeight+5)
end,
DoTheThingCommand = function(self)
if song and enabled then
self:SetVertices({})
self:SetDrawState {Mode = "DrawMode_Quads", First = 1, Num = 0}

if activeDiffGroup == -1 or (diffGroups[activeDiffGroup] and diffGroups[activeDiffGroup]["Jack"]) then
self:visible(true)
else
self:visible(false)
end

local hand = hand == 1 and "Left" or "Right"
local verts = {}
local values = jackdiffs[hand]
if not values or not values[1] then return end

for i = 1, #values do
--local x = fitX(i, #values) -- vector length based positioning
-- if used, final/firstsecond must be halved
-- they need to be halved because the numbers we use here are not half second interval based, but row time instead
local x = fitX(values[i][1], finalSecond / 2 / getCurRateValue()) -- song length based positioning
local y = fitY2(values[i][3] * 20, lowerGraphMin, lowerGraphMax)

setOffsetVerts(verts, x, y, colorToUse)
end

self:SetVertices(verts)
self:SetDrawState {Mode = "DrawMode_LineStrip", First = 1, Num = #verts}
else
self:visible(false)
end
end,
UpdateActiveLowerGraphMessageCommand = function(self)
if song and enabled then
if activeDiffGroup == -1 or (diffGroups[activeDiffGroup] and diffGroups[activeDiffGroup]["Jack"]) then
self:visible(true)
else
self:visible(false)
end
end
end
}
end

local function bottomGraphLineMSD(mod, colorToUse, hand)
return Def.ActorMultiVertex {
InitCommand = function(self)
Expand Down Expand Up @@ -1383,6 +1433,11 @@ for h = 1,2 do
o[#o+1] = bottomGraphLineJack(colr, h)
end

-- jack stam
for h = 1,2 do
o[#o+1] = topGraphLineJackStam("jack_stam", color("1,1,1,1"), h)
end

-- a bunch of things for stuff and things
o[#o + 1] = LoadFont("Common Normal") .. {
Name = "Seektext1",
Expand Down
94 changes: 63 additions & 31 deletions src/Etterna/MinaCalc/MinaCalc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,17 @@ Calc::CalcMain(const std::vector<NoteInfo>& NoteInfo,
}

MaxPoints = TotalMaxPoints(*this);

std::vector<float> mcbloop(NUM_Skillset);

// overall and stam will be left as 0.f by this loop
for (auto i = 0; i < NUM_Skillset; ++i) {
mcbloop[i] = Chisel(0.1F, 10.24F, score_goal, i, false);
mcbloop[i] =
Chisel(0.1F, 10.24F, score_goal, static_cast<Skillset>(i), false);
}

// stam is based on which calc produced the highest
// output without it
const auto highest_base_skillset = max_index(mcbloop);
// stam is based on which calc produced the highest output without it
const auto highest_base_skillset =
static_cast<Skillset>(max_index(mcbloop));
const auto base = mcbloop[highest_base_skillset];

/* rerun all with stam on, optimize by starting at the non-stam adjusted
Expand All @@ -104,10 +105,15 @@ Calc::CalcMain(const std::vector<NoteInfo>& NoteInfo,
* file as a whole, we could run it for the 2nd/3rd highest skillsets
* but i'm too lazy to implement that right now */
for (auto i = 0; i < NUM_Skillset; ++i) {
mcbloop[i] = Chisel(mcbloop[i] * 0.9F, 0.32F, score_goal, i, true);
mcbloop[i] = Chisel(mcbloop[i] * 0.9F,
0.32F,
score_goal,
static_cast<Skillset>(i),
true);
}

const auto highest_stam_adjusted_skillset = max_index(mcbloop);
const auto highest_stam_adjusted_skillset =
static_cast<Skillset>(max_index(mcbloop));

/* all relative scaling to specific skillsets should occur before this
* point, not after (it ended up this way due to the normalizers which
Expand Down Expand Up @@ -287,7 +293,8 @@ StamAdjust(const float x,

// tuned for jacks, dunno what this functionally means, yet
inline auto
JackStamAdjust(const float x, Calc& calc, const int hi) -> std::vector<std::pair<float,float>>
JackStamAdjust(const float x, Calc& calc, const int hi)
-> std::vector<std::pair<float, float>>
{
// Jack stamina Model params (see above)
static const auto stam_ceil = 1.05234F;
Expand All @@ -301,7 +308,9 @@ JackStamAdjust(const float x, Calc& calc, const int hi) -> std::vector<std::pair
const auto super_stam_ceil = 1.09F;

const auto& diff = calc.jack_diff.at(hi);
std::vector<std::pair<float,float>> doot(diff.size());
std::vector<std::pair<float, float>> doot(diff.size());

calc.jack_stam_stuff.at(hi).resize(diff.size());

for (size_t i = 0; i < diff.size(); i++) {
const auto avs1 = avs2;
Expand All @@ -316,6 +325,8 @@ JackStamAdjust(const float x, Calc& calc, const int hi) -> std::vector<std::pair

doot.at(i).first = diff.at(i).first;
doot.at(i).second = diff.at(i).second * mod;

calc.jack_stam_stuff.at(hi).at(i) = mod;
}

return doot;
Expand Down Expand Up @@ -438,6 +449,19 @@ CalcInternal(float& gotpoints,
}
}

TheGreatBazoinkazoinkInTheSky ulbu_that_which_consumes_all;

void
Calc::InitParamsFromDiskAndDevoteSelfToUlbu()
{
// only load the params file for release
#ifndef RELWITHDEBINFO
#if NDEBUG
ulbu_that_which_consumes_all.praise_the_glory_of_ulbu();
#endif
#endif
}

auto
Calc::InitializeHands(const std::vector<NoteInfo>& NoteInfo,
const float music_rate,
Expand All @@ -447,8 +471,8 @@ Calc::InitializeHands(const std::vector<NoteInfo>& NoteInfo,
if (fast_walk_and_check_for_skip(NoteInfo, music_rate, *this, offset))
return true;

TheGreatBazoinkazoinkInTheSky ulbu_that_which_consumes_all(*this);
ulbu_that_which_consumes_all();
// ulbu calculates everything needed for the block below (mostly pmods)
ulbu_that_which_consumes_all(this);

// main hand loop
for (const auto& hi : { left_hand, right_hand }) {
Expand Down Expand Up @@ -491,6 +515,7 @@ Calc::InitializeHands(const std::vector<NoteInfo>& NoteInfo,
}
}
}

return false;
}

Expand All @@ -507,7 +532,7 @@ auto
Calc::Chisel(float player_skill,
float resolution,
const float score_goal,
const int ss,
const Skillset ss,
const bool stamina,
const bool debugoutput) -> float
{
Expand Down Expand Up @@ -551,7 +576,7 @@ Calc::Chisel(float player_skill,
* point. i.e. we're so far below the skill
* benchmark it's impossible to reach the goal after
* just the first hand's losses are totaled */
if (gotpoints > reqpoints) {
if (true /*gotpoints > reqpoints*/) {
if (ss == Skill_JackSpeed) {
gotpoints -= jackloss(player_skill, *this, hi, stamina);
} else {
Expand Down Expand Up @@ -610,7 +635,7 @@ Calc::Chisel(float player_skill,
return player_skill + 2.F * resolution;
}

/* the new way we wil attempt to differentiate skillsets rather than using
/* The new way we wil attempt to differentiate skillsets rather than using
* normalizers is by detecting whether or not we think a file is mostly
* comprised of a given pattern, producing a downscaler that slightly buffs
* up those files and produces a downscaler for files not detected of that
Expand Down Expand Up @@ -672,7 +697,7 @@ Calc::InitAdjDiff(Calc& calc, const int& hi)
TheThing,
WideRangeAnchor,
WideRangeRoll,
WideRangeJumptrill,
WideRangeJumptrill,
OHTrill,
VOHTrill,
// Roll
Expand All @@ -682,7 +707,7 @@ Calc::InitAdjDiff(Calc& calc, const int& hi)
// stam, nothing, don't handle here
{},

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

// chordjack
Expand Down Expand Up @@ -719,23 +744,23 @@ Calc::InitAdjDiff(Calc& calc, const int& hi)
for (auto i = 0; i < calc.numitv; ++i) {
tp_mods.fill(1.F);

// total pattern mods for each skillset, we want this to be
// calculated before the main skillset loop because we might
// want access to the total js mod while on stream, or
// something
/* total pattern mods for each skillset, we want this to be
* calculated before the main skillset loop because we might
* want access to the total js mod while on stream, or
* something */
for (auto ss = 0; ss < NUM_Skillset; ++ss) {
// is this even faster than multiplying 1.f by 1.f a
// billion times?

// is this even faster than multiplying 1.f by 1.f a billion times?
if (ss == Skill_Overall || ss == Skill_Stamina) {
continue;
}

for (const auto& pmod : pmods_used.at(ss)) {
tp_mods.at(ss) *= calc.doot.at(hi).at(pmod).at(i);
}
}

// main skillset loop, for each skillset that isn't overall
// or stam
// main loop, for each skillset that isn't overall or stam
for (auto ss = 0; ss < NUM_Skillset; ++ss) {
if (ss == Skill_Overall || ss == Skill_Stamina) {
continue;
Expand All @@ -746,9 +771,7 @@ Calc::InitAdjDiff(Calc& calc, const int& hi)
auto* stam_base =
&(calc.base_diff_for_stam_mod.at(hi).at(ss).at(i));

// might need optimization, or not since this is not
// outside of a dumb loop now and is done once instead
// of a few hundred times
// ditto?
const auto funk = calc.soap.at(hi).at(NPSBase).at(i) *
tp_mods.at(ss) * basescalers.at(ss);
*adj_diff = funk;
Expand Down Expand Up @@ -820,8 +843,10 @@ make_debug_strings(const Calc& calc, std::vector<std::string>& debugstrings)
itvstring.append("\n");
}

if (!itvstring.empty())
if (!itvstring.empty()) {
itvstring.pop_back();
}

debugstrings.at(itv) = itvstring;
}
}
Expand Down Expand Up @@ -879,6 +904,9 @@ MinaSDCalcDebug(
return;
}

// always load params file for debug mode
ulbu_that_which_consumes_all.praise_the_glory_of_ulbu();

calc.debugmode = true;
calc.ssr = true;
calc.CalcMain(NoteInfo, musicrate, min(goal, ssr_goal_cap));
Expand All @@ -887,14 +915,18 @@ MinaSDCalcDebug(
handInfo.emplace_back(calc.debugValues.at(left_hand));
handInfo.emplace_back(calc.debugValues.at(right_hand));

// asdkfhjasdkfhaskdfjhasfd
/* ok so the problem atm is the multithreading of songload, if we want
* to update the file on disk with new values and not just overwrite it
* we have to write out after loading the values player defined, so the
* quick hack solution to do that is to only do it during debug output
* generation, which is fine for the time being, though not ideal */
if (!DoesFileExist(calc_params_xml)) {
const TheGreatBazoinkazoinkInTheSky ublov(calc);
const TheGreatBazoinkazoinkInTheSky ublov;
ublov.write_params_to_disk();
}
}

int mina_calc_version = 434;
int mina_calc_version = 435;
auto
GetCalcVersion() -> int
{
Expand Down
Loading

0 comments on commit 60aa6a4

Please sign in to comment.