diff --git a/src/Etterna/MinaCalc/Dependent/HD_PatternMods/WideRangeJJ.h b/src/Etterna/MinaCalc/Dependent/HD_PatternMods/WideRangeJJ.h index 8facebc4ea..83f962b71b 100644 --- a/src/Etterna/MinaCalc/Dependent/HD_PatternMods/WideRangeJJ.h +++ b/src/Etterna/MinaCalc/Dependent/HD_PatternMods/WideRangeJJ.h @@ -206,7 +206,7 @@ struct WideRangeJJMod // ideally take less than 5 intervals to drift pmod = fastsqrt(pmod + std::clamp(calming_comp, 0.F, 1.F)); } else { - pmod = taps_in_window / problems_in_window * 0.75; + pmod = taps_in_window / problems_in_window * 0.75F; } pmod = std::clamp(pmod, min_mod, max_mod); diff --git a/src/Etterna/MinaCalc/SequencedBaseDiffCalc.h b/src/Etterna/MinaCalc/SequencedBaseDiffCalc.h index b48b3d711a..ce8911d503 100644 --- a/src/Etterna/MinaCalc/SequencedBaseDiffCalc.h +++ b/src/Etterna/MinaCalc/SequencedBaseDiffCalc.h @@ -67,10 +67,6 @@ struct nps /// determine NPSBase, itv_points, CJBase for this hand static void actual_cancer(Calc& calc, const int& hand) { - // finger row times - auto last_left_row_time = s_init; - auto last_right_row_time = s_init; - auto scaly_ms_estimate = [](std::vector& input, const float& scaler) { float o = CalcMSEstimate(input, 3); @@ -83,81 +79,70 @@ struct nps return o; }; + // Per-finger data for msbase + struct FingerGaps + { + std::vector ms; + float last_row_time = s_init; + }; + + std::vector fingy(calc.col_masks.size()); + std::vector estimates; + for (auto itv = 0; itv < calc.numitv; ++itv) { auto notes = 0; - // times between rows for this interval for each finger - std::vector left_finger_ms{}; - std::vector right_finger_ms{}; - + for (auto& fing : fingy) { + fing.ms.clear(); + } + + // note time deltas per finger in this interval for (auto row = 0; row < calc.itv_size.at(itv); ++row) { const auto& cur = calc.adj_ni.at(itv).at(row); + auto cur_notes = cur.row_notes & calc.hand_col_masks[hand]; notes += cur.hand_counts.at(hand); const auto& crt = cur.row_time; - 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 = - ms_from(crt, last_left_row_time); - left_finger_ms.push_back(left_ms); + for (size_t col_index = 0; col_index < calc.col_masks.size(); ++col_index) { + if (cur_notes & calc.col_masks[col_index]) { + auto& fing = fingy[col_index]; + if (fing.last_row_time != s_init) { + const auto ms = ms_from(crt, fing.last_row_time); + fing.ms.push_back(ms); } - last_left_row_time = crt; - break; - case col_right: - if (last_right_row_time != s_init) { - const auto right_ms = - ms_from(crt, last_right_row_time); - right_finger_ms.push_back(right_ms); - } - last_right_row_time = crt; - break; - case col_ohjump: - if (last_right_row_time != s_init) { - const auto right_ms = - ms_from(crt, last_right_row_time); - right_finger_ms.push_back(right_ms); - } - if (last_left_row_time != s_init) { - const auto left_ms = - ms_from(crt, last_left_row_time); - left_finger_ms.push_back(left_ms); - } - last_left_row_time = crt; - last_right_row_time = crt; - break; - case col_empty: - case col_init: - default: - // none - break; + fing.last_row_time = crt; + } } } + // per finger deltas to ms estimates. for 4k estimates.size() == 2 + estimates.clear(); + for (auto& fing : fingy) { + if (fing.last_row_time != s_init) { + auto ms_est = scaly_ms_estimate(fing.ms, scaler_for_ms_base); + estimates.push_back(ms_est); + } + } + + // sort largest first and zero pad to hand note count + std::sort(estimates.begin(), estimates.end(), [](auto a, auto b) { return a > b; }); + estimates.resize(column_count(calc.hand_col_masks[hand])); + + // average fingy estimates for msbase. makes sense for 4k where there are 2 estimates. + // weighted_average fudges the 1/2 factor so generalising the 4k weights to nk is ?? + // so just telescope + float msdiff = estimates[0]; + for (size_t i = 1; i < estimates.size(); ++i) { + msdiff = weighted_average(msdiff, estimates[i], ms_base_finger_weighter, ms_base_finger_weighter_2); + } + // nps for this interval const auto nps = static_cast(notes) * finalscaler * 1.6F; calc.init_base_diff_vals.at(hand).at(NPSBase).at(itv) = nps; // ms base for this interval - const auto left = - scaly_ms_estimate(left_finger_ms, scaler_for_ms_base); - const auto right = - scaly_ms_estimate(right_finger_ms, scaler_for_ms_base); - float msdiff = 0.F; - if (left > right) { - msdiff = weighted_average(left, - right, - ms_base_finger_weighter, - ms_base_finger_weighter_2); - } else { - msdiff = weighted_average(right, - left, - ms_base_finger_weighter, - ms_base_finger_weighter_2); - } const auto msbase = finalscaler * msdiff; - calc.init_base_diff_vals.at(hand).at(MSBase).at(itv) = msbase; - ///// + calc.init_base_diff_vals.at(hand).at(MSBase).at(itv) = msbase; // set points for this interval calc.itv_points.at(hand).at(itv) = notes * 2; @@ -346,7 +331,7 @@ struct ceejay for (auto i = 0; i < static_ms.size(); i++) { // weight = 0 means all values become modev static_ms.at(i) = - weighted_average(static_ms.at(i), modev, static_ms_weight, 1.F); + weighted_average(static_ms.at(i), static_cast(modev), static_ms_weight, 1.F); } const auto ms_total = sum(static_ms); @@ -442,7 +427,7 @@ struct techyo auto chaos_comp = calc_chaos_comp(seq, ct, calc, hand, row_time); //insert(balance_ratios, balance_comp); teehee(chaos_comp); - calc.tc_static.at(row_counter) = teehee.get_mean_of_window(tc_static_base_window); + calc.tc_static.at(row_counter) = teehee.get_mean_of_window((int)tc_static_base_window); ++row_counter; } @@ -609,9 +594,9 @@ struct techyo float calc_balance_comp() const { const auto left = - get_total_for_windowf(count_left, balance_comp_window); + get_total_for_windowf(count_left, (unsigned)balance_comp_window); const auto right = - get_total_for_windowf(count_right, balance_comp_window); + get_total_for_windowf(count_right, (unsigned)balance_comp_window); // for this application of balance, dont care about half empty hands // or fully balanced hands @@ -662,13 +647,13 @@ struct techyo const auto c = (a + b) / 2; // coeff var. of last N ms times on either column - auto pineapple = seq._mw_any_ms.get_cv_of_window(chaos_comp_window); + auto pineapple = seq._mw_any_ms.get_cv_of_window((unsigned)chaos_comp_window); // coeff var. of last N ms times on left column auto porcupine = - seq._mw_sc_ms[col_left].get_cv_of_window(chaos_comp_window); + seq._mw_sc_ms[col_left].get_cv_of_window((unsigned)chaos_comp_window); // coeff var. of last N ms times on right column auto sequins = - seq._mw_sc_ms[col_right].get_cv_of_window(chaos_comp_window); + seq._mw_sc_ms[col_right].get_cv_of_window((unsigned)chaos_comp_window); // coeff var. is sd divided by mean // cv of 0 is 0 sd @@ -832,13 +817,13 @@ struct techyo { float o = 0.F; auto i = max_rows_for_single_interval; - while (i > max_rows_for_single_interval - window) { + while (i > max_rows_for_single_interval - (int)window) { i--; o += arr.at(i); } return o; } - + template void insert(std::array& arr, const T value) diff --git a/src/Etterna/MinaCalc/UlbuAcolytes.h b/src/Etterna/MinaCalc/UlbuAcolytes.h index ec4c0b689e..8fd99e06ad 100644 --- a/src/Etterna/MinaCalc/UlbuAcolytes.h +++ b/src/Etterna/MinaCalc/UlbuAcolytes.h @@ -174,7 +174,7 @@ fast_walk_and_check_for_skip(const std::vector& ni, // all columns from left to rightmost calc.col_masks.clear(); calc.col_masks.reserve(calc.keycount); - for (int i = 0; i < calc.keycount; i++) { + for (unsigned i = 0; i < calc.keycount; i++) { calc.col_masks.push_back(1 << i); }