Skip to content

Commit

Permalink
relink chains | 457
Browse files Browse the repository at this point in the history
chains are not some ohj ripoff and now use a base and are very lightly tuned

also found a sequencer bug lol
  • Loading branch information
poco0317 committed Sep 5, 2021
1 parent cb4a723 commit e4373cc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 101 deletions.
124 changes: 24 additions & 100 deletions src/Etterna/MinaCalc/Dependent/HD_PatternMods/Chains.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,20 @@ struct ChainsMod
float min_mod = 0.7F;
float max_mod = 1.2F;

float max_seq_prop_weight = .5F;
float max_seq_base = 1.F;
float max_seq_scaler = 1.F;

float anchor_base = 1.F;
float anchor_scaler = 1.F;
float chain_swap_base = 1.F;
float chain_swap_scaler = 1.F;
/// how much chain swap or how much anchor matters
float chain_anchor_weight = .5F;
/// how much the result of the chain/anchor component matters
/// when weighted against the sequence component
float chain_anchor_component_weight = .5F;

float prop_base = 1.F;
float prop_scaler = 1.F;
float anchor_len_weight = .5F;
float len_scaler = 0.0003F;
float swap_scaler = 0.00075F;

float base = 1.F;

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

{ "max_seq_prop_weight", &max_seq_prop_weight },
{ "max_seq_base", &max_seq_base },
{ "max_seq_scaler", &max_seq_scaler },
{ "prop_base", &prop_base },
{ "prop_scaler", &prop_scaler },

{ "anchor_base", &anchor_base },
{ "anchor_scaler", &anchor_scaler },
{ "chain_swap_base", &chain_swap_base },
{ "chain_swap_scaler", &chain_swap_scaler },
{ "chain_anchor_weight", &chain_anchor_weight },
{ "chain_anchor_component_weight", &chain_anchor_component_weight },
{ "len_scaler", &len_scaler },
{ "anchor_len_weight", &anchor_len_weight },
{ "swap_scaler", &swap_scaler },
};
#pragma endregion params and param map

Expand All @@ -53,13 +34,6 @@ struct ChainsMod
int max_total_len = 0;
int max_anchor_len = 0;

// combination of max components of sequencer
float base_seq_prop = 0.F;
// size of sequence scaled to total taps in hand
float base_size_prop = 0.F;

float max_seq_component = neutral;
float prop_component = neutral;
float pmod = neutral;

#pragma region generic functions
Expand All @@ -72,11 +46,6 @@ struct ChainsMod
max_total_len = 0;
max_anchor_len = 0;

base_seq_prop = 0.F;
base_size_prop = 0.F;

max_seq_component = neutral;
prop_component = neutral;
pmod = neutral;
}

Expand All @@ -87,23 +56,6 @@ struct ChainsMod
chain(ct, bt, last_ct);
}

// build component based on max sequence relative to hand taps
void set_max_seq_comp()
{
max_seq_component = max_seq_base + (base_seq_prop * max_seq_scaler);
max_seq_component = max_seq_component < 0.1F ? 0.1F : max_seq_component;
max_seq_component = fastsqrt(max_seq_component);
}

// build component based on number of taps in any chain sequence
// relative to hand taps
void set_prop_comp()
{
prop_component = prop_base + (base_size_prop * prop_scaler);
prop_component = prop_component < 0.1F ? 0.1F : prop_component;
prop_component = fastsqrt(prop_component);
}

void set_pmod(const metaItvHandInfo& mitvhi)
{
const auto& itvhi = mitvhi._itvhi;
Expand All @@ -120,61 +72,33 @@ struct ChainsMod
return;
}

// pmod = base + (sum)
// max anchor / total rows * scale
// max swaps / total rows * scale

// an interval with only jacks of 11112222 has no completed seq
// the clamp should catch that scenario
// otherwise assume conditions which continue chains are in chains
auto taps_in_any_sequence = std::clamp(base_types[base_single_single] +
base_types[base_single_jump] +
base_types[base_jump_single],
0,
1,
max_total_len);
auto tapsF = static_cast<float>(taps_in_any_sequence);

auto csF = static_cast<float>(max_chain_swaps);
auto clF = static_cast<float>(max_total_len);
auto caF = static_cast<float>(max_anchor_len);

// proportion of swaps to chain size
// any swap also requires a chain of size 2
// some intervals have no chains, so could divide by 0
auto chain_swap_prop = std::max(csF, 1.F) / std::max(clF, 1.F);
auto swap_prop_scaled = fastsqrt(std::max(
chain_swap_base + (chain_swap_prop * chain_swap_scaler), .1F));

// proportion of longest anchor to longest chain
// a chain will swap at least once
// longest anchor will be up to (max_total_len - 2)
auto longest_anchor_prop = std::max(caF, 1.F) / std::max(clF, 1.F);
auto anchor_prop_scaled = fastsqrt(
std::max(anchor_base + (longest_anchor_prop * anchor_scaler), .1F));

base_seq_prop = clF / itvhi.get_taps_nowf();
set_max_seq_comp();
base_size_prop = taps_in_any_sequence / itvhi.get_taps_nowf();
set_prop_comp();

// chain_anchor_weight should be [0,1]
// 1 -> anchor-swap_component = chain_swap_prop
// 0 -> anchor-swap_component = anchor_prop
auto anchor_swap_component = weighted_average(
swap_prop_scaled, anchor_prop_scaled, chain_anchor_weight, 1.F);

// chain_anchor_component_weight should be [0,1]
// 1 -> seq_component = anchor-swap_component
// 0 -> seq_component = seq_component
max_seq_component = weighted_average(anchor_swap_component,
max_seq_component,
chain_anchor_component_weight,
1.F);

max_seq_component = std::clamp(max_seq_component, 0.1F, max_mod);
prop_component = std::clamp(prop_component, 0.1F, max_mod);

// max_seq_weight should be [0,1]
// 1 -> pmod = max_seq_component
// 0 -> pmod = prop_component
pmod = weighted_average(
max_seq_component, prop_component, max_seq_prop_weight, 1.F);
pmod = std::clamp(pmod, min_mod, max_mod);
// anchor_len_weight should be [0,1]
// 1 -> worth = entire chain length
// 0 -> worth = longest anchor length
auto anchor_len_worth =
weighted_average(clF, caF, anchor_len_weight, 1.F);

auto anchor_worth = fastsqrt(anchor_len_worth / tapsF * len_scaler);
auto swap_worth = fastsqrt(csF / tapsF * swap_scaler);
pmod = std::clamp(base + anchor_worth + swap_worth, min_mod, max_mod);
}

auto operator()(const metaItvHandInfo& mitvhi) -> float
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ struct Chain_Sequencer
chain_swapping = false;
max_anchor_len = get_max_anchor_len();
cur_anchor_len = 0;
chain_swaps++;
}

void operator()(const col_type& ct, const base_type& bt, const col_type& last_ct)
Expand Down
2 changes: 1 addition & 1 deletion src/Etterna/MinaCalc/MinaCalc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ MinaSDCalcDebug(
}
}

int mina_calc_version = 456;
int mina_calc_version = 457;
auto
GetCalcVersion() -> int
{
Expand Down

0 comments on commit e4373cc

Please sign in to comment.