Algorithm Overview

The algorithm calculates a bonus score for each member based on their performance in Clan War Leagues. The key components considered in the score calculation are stars earned, attacks used, destruction percentage, donations, and the relative Town Hall level. Additionally, the algorithm accounts for alt accounts and calculates an extra bonus based on their performance.

Variables

  1. Input Variables:
    • M: List of members in the clan.
    • A: List of attacks used by a member.
    • T_s: Total Stars per player.
    • T_a: Total Attacks per player.
    • T_d: Total Destruction Percentage per player.
    • T_h: List of Average Relative TH per War.
  2. Calculation Weights:
    • W_s: Weight for stars.
    • W_a: Weight for attacks.
    • W_d: Weight for destruction percentage.
    • W_don: Weight for donations up to a threshold.
    • W_don_extra: Extra weight for donations beyond the threshold.
    • W_th: Town Hall differential multiplier.
    • W_alt: Alt account weight.
    • P_alt_max: Maximum extra percentage from alt accounts.
  3. Thresholds:
    • D_thresh: Default donations threshold.
    • E_don_max: Maximum extra donations percentage.
    • E_don_thresh: Extra donations threshold.

Step-by-Step Calculation

  1. Filter Out Non-Participants: Remove any member m from M where m's list of attacks A is empty.
  2. Calculate Individual Scores for Each Member: For each member m in M:
    • Base Score Calculation:
      S_base = (s / T_s) * W_s + (a / T_a) * W_a + (d / T_d) * W_d
      where s, a, and d represent the stars earned, attacks used, and destruction percentage for m, respectively.
    • Donation Score Calculation:
      • If d <= D_thresh: S_don = (d / D_thresh) * W_don
      • Else:
        • Calculate S_don_base = W_don.
        • Calculate d_extra = d - D_thresh.
        • Set P_don_extra = S_don_base + min(E_don_max, W_don_extra * (d_extra / E_don_thresh)).
        • Set S_don = P_don_extra.
    • Town Hall Differential Adjustment:
      • Initialize M_th = 0.
      • For each attack A_i in m's attacks, adjust M_th based on TH differential for that war.
      • Adjust M_th by averaging over the number of attacks: M_th = M_th / a.
      • Apply M_th to adjust the score: S_final = S_base * (1 + M_th).
  3. Calculate Alt Account Bonuses: For each member m in M who is not an alt and has alt accounts:
    • Sum up the bonus from all alt accounts a: P_alt = sum(a_score * W_alt).
    • Limit P_alt to P_alt_max.
    • Update m's score: S_final = S_final + P_alt.
  4. Sort Members by Score: Sort M in descending order by S_final to determine the bonus allocation order.
  5. Done: The output list M reflects the final scores, providing a ranking of members based on their performance metrics and adjustments. This ranking helps in distributing the CWL bonuses to top performers.