Armchair GM
2026-27 The league's active season. Trades, cap positions, and scenarios are computed against it.

Documentation The six pillars

Roster construction

Position coverage, skill coverage, functional depth, and roster completeness measure the composition of the roster.

Aggregation

The table below is extracted from the pillar's declared metric weights at build time. Open the metric implementation notes and source to inspect its raw inputs, normalization, branches, and fallback handling.

pillar_score = Σ(metric_score × metric_weight)

Metric weights

Metric Declared weight
Roster completeness 15.0%
Position coverage 25.0%
Skill coverage 35.0%
Functional depth 25.0%

Implementation

These notes and source files are captured from this deployment's code. Expand a module for its algorithm and branches, or download the Elixir file for local inspection.

roster_construction.exElixir

lib/trade_machine/gm_grade_v2/pillars/roster_construction.ex

Aggregates AVC's four Roster Construction metrics over the final roster.

Roster Completeness, Position Coverage, Skill Coverage, and Functional Depth retain full precision through the fixed 15/25/35/25 weighted sum.

Download source ↓

SHA-256 79c76ca74af8e2b75cc96a080122d24b55558d63d679e89dcbc3b66511fb9805

defmodule TradeMachine.GMGradeV2.Pillars.RosterConstruction do
  @moduledoc """
  Aggregates AVC's four Roster Construction metrics over the final roster.

  Roster Completeness, Position Coverage, Skill Coverage, and Functional Depth
  retain full precision through the fixed 15/25/35/25 weighted sum.
  """

  alias TradeMachine.GMGradeV2.Benchmark
  alias TradeMachine.GMGradeV2.ChallengeSnapshot
  alias TradeMachine.GMGradeV2.Pillars.RosterConstruction.FunctionalDepth
  alias TradeMachine.GMGradeV2.Pillars.RosterConstruction.Inputs
  alias TradeMachine.GMGradeV2.Pillars.RosterConstruction.PositionCoverage
  alias TradeMachine.GMGradeV2.Pillars.RosterConstruction.RosterCompleteness
  alias TradeMachine.GMGradeV2.Pillars.RosterConstruction.SkillCoverage
  alias TradeMachine.GMGradeV2.Result.MetricResult
  alias TradeMachine.GMGradeV2.Result.PillarResult
  alias TradeMachine.GMGradeV2.Weighting

  @metric_weights %{
    roster_completeness: 0.15,
    position_coverage: 0.25,
    skill_coverage: 0.35,
    functional_depth: 0.25
  }

  @metric_modules [
    RosterCompleteness,
    PositionCoverage,
    SkillCoverage,
    FunctionalDepth
  ]

  if abs(Enum.sum(Map.values(@metric_weights)) - 1.0) > 1.0e-9 do
    raise "Roster Construction metric weights must sum to 1.0"
  end

  @doc """
  The published metric weights this pillar aggregates with.

  Public so the parameter registry and the model-document seed can read the
  authored weights instead of restating them (plan §5.1).
  """
  @spec metric_weights() :: %{atom() => float()}
  def metric_weights, do: @metric_weights

  @doc """
  Returns the full-precision Roster Construction pillar result.

  `weights` defaults to the published `metric_weights/0`; a resolved grading
  model supplies its own set (plan §5.1).
  """
  @spec score(map(), ChallengeSnapshot.t(), Weighting.weights()) :: PillarResult.t()
  def score(
        %{roster: roster} = scenario_state,
        %ChallengeSnapshot{benchmark: %Benchmark{} = benchmark} = snapshot,
        weights \\ @metric_weights
      )
      when is_list(roster) do
    scoring_state =
      scenario_state
      |> Map.put(:roster, Inputs.hydrate_roster(roster, snapshot))
      |> Map.put(
        :model_override,
        Map.merge(
          Inputs.model_override(snapshot),
          Map.get(scenario_state, :constants_override, %{})
        )
      )

    metric_results = Enum.map(@metric_modules, & &1.score(scoring_state, snapshot))
    {strongest, weakest} = extrema(metric_results)

    %PillarResult{
      key: :roster_construction,
      version: benchmark.version,
      score: Weighting.combine(metric_results, weights),
      metric_results: metric_results,
      metric_weights: weights,
      explanation: explanation(strongest, weakest),
      strongest: strongest.key,
      weakest: weakest.key
    }
  end

  # Enum.max_by/min_by retain the first item on a tie, so published metric order
  # provides a stable tie-break without a second priority table.
  defp extrema(metric_results) do
    {
      Enum.max_by(metric_results, & &1.score),
      Enum.min_by(metric_results, & &1.score)
    }
  end

  defp explanation(
         %MetricResult{key: strongest_key, score: strongest_score},
         %MetricResult{key: weakest_key, score: weakest_score}
       ) do
    "Roster Construction combines four full-roster metrics; " <>
      "#{label(strongest_key)} is strongest at #{strongest_score}, while " <>
      "#{label(weakest_key)} is weakest at #{weakest_score}."
  end

  defp label(:roster_completeness), do: "Roster Completeness"
  defp label(:position_coverage), do: "Position Coverage"
  defp label(:skill_coverage), do: "Skill Coverage"
  defp label(:functional_depth), do: "Functional Depth"
end
functional_depth.exElixir

lib/trade_machine/gm_grade_v2/pillars/roster_construction/functional_depth.ex

Scores AVC's Functional Depth metric over the entire final roster.

Position Depth credits a player's listed position at their shared contribution factor and adjacent positions at 35% of that factor. Skill Redundancy counts contribution-factor units only for reliability-adjusted skill indexes of at least 60. Skill Concentration measures the best player's share of each skill's top-three adjusted indexes.

Per D-24, concentration is neutral (50) for a skill with fewer than three measured indexes or a zero top-three sum, and every such use is recorded as a fallback.

The result's inputs.detail records who makes up each total, so a breakdown can show them without working anything out again:

    %{
      experience_minutes: 800,
      position_depth: %{"PG" => [%{player_id: id, name: name, listed_at: "PG",
                                   amount: 1.0, season_minutes: 2100,
                                   two_way: false}, ...], ...all five},
      skill_redundancy: %{shooting: [%{player_id: id, name: name, figure: 85.1,
                                       amount: 1.0, season_minutes: 2100,
                                       two_way: false}, ...], ...all five},
      skill_concentration: %{shooting: %{players: [%{player_id: id, name: name,
                                                     figure: 85.1}, ...],
                                         stand_in: nil}, ...all five}
    }

* position_depth : every player who adds to a position, at his own listed position ( listed_at is that position) or a neighbouring one (his contribution times the neighbour credit), largest amount first. A position's amounts sum to inputs.position_depth.units[position] . * skill_redundancy : every qualified provider of the skill, largest amount first, then highest figure. A skill's amounts sum to inputs.skill_redundancy.units[skill] . * skill_concentration : the players whose figures were used, largest first, and stand_in : nil where the skill was scored normally (the first figure over the sum of them is inputs.skill_concentration.top_player_shares[skill] ), otherwise which reason the neutral score was used for, "fewer_than_three" (with the players there were) or "zero_total" .

season_minutes and two_way are what a player's contribution was worked out from ( SkillIndexes.contribution_basis/1 ), and experience_minutes is the number of minutes that counts as full experience under the same model override. Nothing reads detail to compute a score.

Download source ↓

SHA-256 42c0853faff27cc625bda8d3241e2b4f114df3ed6840f4f8c5271090706523b1

defmodule TradeMachine.GMGradeV2.Pillars.RosterConstruction.FunctionalDepth do
  @moduledoc """
  Scores AVC's Functional Depth metric over the entire final roster.

  Position Depth credits a player's listed position at their shared
  contribution factor and adjacent positions at 35% of that factor. Skill
  Redundancy counts contribution-factor units only for reliability-adjusted
  skill indexes of at least 60. Skill Concentration measures the best player's
  share of each skill's top-three adjusted indexes.

  Per D-24, concentration is neutral (50) for a skill with fewer than three
  measured indexes or a zero top-three sum, and every such use is recorded as a
  fallback.

  The result's `inputs.detail` records who makes up each total, so a breakdown
  can show them without working anything out again:

      %{
        experience_minutes: 800,
        position_depth: %{"PG" => [%{player_id: id, name: name, listed_at: "PG",
                                     amount: 1.0, season_minutes: 2100,
                                     two_way: false}, ...], ...all five},
        skill_redundancy: %{shooting: [%{player_id: id, name: name, figure: 85.1,
                                         amount: 1.0, season_minutes: 2100,
                                         two_way: false}, ...], ...all five},
        skill_concentration: %{shooting: %{players: [%{player_id: id, name: name,
                                                       figure: 85.1}, ...],
                                           stand_in: nil}, ...all five}
      }

    * `position_depth`: every player who adds to a position, at his own listed
      position (`listed_at` is that position) or a neighbouring one (his
      contribution times the neighbour credit), largest amount first. A
      position's amounts sum to `inputs.position_depth.units[position]`.
    * `skill_redundancy`: every qualified provider of the skill, largest amount
      first, then highest figure. A skill's amounts sum to
      `inputs.skill_redundancy.units[skill]`.
    * `skill_concentration`: the players whose figures were used, largest
      first, and `stand_in`: `nil` where the skill was scored normally (the
      first figure over the sum of them is
      `inputs.skill_concentration.top_player_shares[skill]`), otherwise which
      reason the neutral score was used for, `"fewer_than_three"` (with the
      players there were) or `"zero_total"`.

  `season_minutes` and `two_way` are what a player's contribution was worked
  out from (`SkillIndexes.contribution_basis/1`), and `experience_minutes` is
  the number of minutes that counts as full experience under the same model
  override. Nothing reads `detail` to compute a score.
  """

  alias TradeMachine.GMGradeV2.Benchmark
  alias TradeMachine.GMGradeV2.ChallengeSnapshot
  alias TradeMachine.GMGradeV2.ModelVersion
  alias TradeMachine.GMGradeV2.Pillars.RosterConstruction.Inputs
  alias TradeMachine.GMGradeV2.Pillars.RosterConstruction.PositionCoverage
  alias TradeMachine.GMGradeV2.Result.MetricResult
  alias TradeMachine.GMGradeV2.SkillIndexes

  @adjacent %{
    "PG" => ["SG"],
    "SG" => ["PG", "SF"],
    "SF" => ["SG", "PF"],
    "PF" => ["SF", "C"],
    "C" => ["PF"]
  }
  @adjacent_credit 0.35
  @qualified_index 60.0
  @average_weight 0.70
  @weakest_weight 0.30
  @weights %{position_depth: 0.35, skill_redundancy: 0.40, skill_concentration: 0.25}
  @neutral_concentration 50.0

  @doc "Returns a full-precision Functional Depth metric result."
  @spec score(map(), ChallengeSnapshot.t()) :: MetricResult.t()
  def score(
        %{roster: roster} = scenario_state,
        %ChallengeSnapshot{benchmark: %Benchmark{} = benchmark} = snapshot
      )
      when is_list(roster) do
    tables =
      benchmark
      |> Benchmark.section(:skills)
      |> Map.fetch!("player_percentiles")

    override = Inputs.model_override(scenario_state, snapshot)
    profiles = profiles(roster, tables, override)

    {position_depth, position_inputs, position_fallbacks, position_entries} =
      position_depth(profiles)

    {skill_redundancy, redundancy_inputs} = skill_redundancy(profiles)

    {skill_concentration, concentration_inputs, concentration_fallbacks, concentration_entries} =
      skill_concentration(profiles)

    supporting = %{
      position_depth: position_depth,
      skill_redundancy: skill_redundancy,
      skill_concentration: skill_concentration
    }

    %MetricResult{
      key: :functional_depth,
      version: benchmark.version,
      score:
        position_depth * @weights.position_depth +
          skill_redundancy * @weights.skill_redundancy +
          skill_concentration * @weights.skill_concentration,
      inputs: %{
        position_depth: position_inputs,
        skill_redundancy: redundancy_inputs,
        skill_concentration: concentration_inputs,
        detail: %{
          experience_minutes: ModelVersion.experience_minutes(override),
          position_depth: position_entries,
          skill_redundancy: redundancy_entries(profiles),
          skill_concentration: concentration_entries
        }
      },
      supporting: supporting,
      weights: @weights,
      fallbacks: position_fallbacks ++ concentration_fallbacks,
      explanation:
        "Functional Depth combines position depth (35%), skill redundancy (40%), " <>
          "and skill concentration (25%) across the entire roster."
    }
  end

  @doc "Converts non-negative position-depth units through AVC's piecewise curve."
  @spec position_depth_score(number()) :: float()
  def position_depth_score(units) when is_number(units) and units >= 0 do
    cond do
      units <= 2.0 -> units * 50.0
      units <= 3.0 -> 100.0
      units <= 4.0 -> interpolate(units, 3.0, 100.0, 4.0, 90.0)
      units <= 5.0 -> interpolate(units, 4.0, 90.0, 5.0, 75.0)
      true -> 75.0
    end
  end

  @doc "Converts non-negative qualified-provider units through AVC's redundancy curve."
  @spec redundancy_score(number()) :: float()
  def redundancy_score(units) when is_number(units) and units >= 0 do
    cond do
      units <= 1.0 -> interpolate(units, 0.0, 0.0, 1.0, 45.0)
      units <= 2.0 -> interpolate(units, 1.0, 45.0, 2.0, 75.0)
      units <= 3.0 -> interpolate(units, 2.0, 75.0, 3.0, 90.0)
      units <= 4.0 -> interpolate(units, 3.0, 90.0, 4.0, 100.0)
      true -> 100.0
    end
  end

  @doc "Converts a best-player top-three share through AVC's concentration curve."
  @spec concentration_score(number()) :: float()
  def concentration_score(share) when is_number(share) and share >= 0 do
    cond do
      share <= 0.40 -> 100.0
      share <= 0.45 -> interpolate(share, 0.40, 100.0, 0.45, 85.0)
      share <= 0.50 -> interpolate(share, 0.45, 85.0, 0.50, 70.0)
      share <= 0.55 -> interpolate(share, 0.50, 70.0, 0.55, 50.0)
      share <= 0.60 -> interpolate(share, 0.55, 50.0, 0.60, 30.0)
      share <= 0.65 -> interpolate(share, 0.60, 30.0, 0.65, 10.0)
      true -> 10.0
    end
  end

  defp profiles(roster, tables, override) do
    Enum.map(roster, fn player ->
      %{
        player: player,
        position: PositionCoverage.normalize_position!(fetch_any!(player, :position)),
        contribution_factor: SkillIndexes.contribution_factor(player, override),
        indexes: SkillIndexes.player_indexes(player, tables, %{override: override}).skills
      }
    end)
  end

  defp position_depth(profiles) do
    initial = Map.new(PositionCoverage.positions(), &{&1, 0.0})
    no_entries = Map.new(PositionCoverage.positions(), &{&1, []})

    {units, fallbacks, entries} =
      Enum.reduce(profiles, {initial, [], no_entries}, fn profile, {units, fallbacks, entries} ->
        case profile.contribution_factor do
          factor when is_number(factor) ->
            units =
              units
              |> Map.update!(profile.position, &(&1 + factor))
              |> add_adjacent_units(profile.position, factor)

            {units, fallbacks, add_position_entries(entries, profile, factor)}

          nil ->
            fallback = %{
              input: player_identifier(profile.player),
              method: :missing_contribution_factor,
              note:
                "#{player_label(profile.player)} has no season-minutes sample, so no " <>
                  "position-depth or qualified-provider credit was invented."
            }

            {units, [fallback | fallbacks], entries}
        end
      end)

    scores = Map.new(units, fn {position, value} -> {position, position_depth_score(value)} end)
    {score, average, weakest} = weakest_blend(Map.values(scores))

    inputs = %{
      units: units,
      scores: scores,
      average_score: average,
      weakest_score: weakest
    }

    entries =
      Map.new(entries, fn {position, players} ->
        {position, players |> Enum.reverse() |> Enum.sort_by(& &1.amount, :desc)}
      end)

    {score, inputs, Enum.reverse(fallbacks), entries}
  end

  # The entries `position_depth/1` records beside its units: the player at his
  # own position, at his contribution, and at each neighbouring position, at
  # the amount `add_adjacent_units/3` adds there. Prepended; reversed once at
  # the end so each position keeps roster order before sorting.
  defp add_position_entries(entries, profile, factor) do
    own = player_entry(profile, %{listed_at: profile.position, amount: factor})

    entries = Map.update!(entries, profile.position, &[own | &1])

    Enum.reduce(Map.fetch!(@adjacent, profile.position), entries, fn adjacent, acc ->
      entry =
        player_entry(profile, %{
          listed_at: profile.position,
          amount: factor * @adjacent_credit
        })

      Map.update!(acc, adjacent, &[entry | &1])
    end)
  end

  defp skill_redundancy(profiles) do
    units =
      Map.new(SkillIndexes.skills(), fn skill ->
        value =
          Enum.reduce(profiles, 0.0, fn profile, total ->
            if qualified_provider?(profile, skill) do
              total + profile.contribution_factor
            else
              total
            end
          end)

        {skill, value}
      end)

    scores = Map.new(units, fn {skill, value} -> {skill, redundancy_score(value)} end)
    {score, average, weakest} = weakest_blend(Map.values(scores))

    {score,
     %{
       qualified_index_threshold: @qualified_index,
       units: units,
       scores: scores,
       average_score: average,
       weakest_score: weakest
     }}
  end

  # The one test of who counts as a provider of a skill, used by the units
  # above and by the entries recorded beside them.
  defp qualified_provider?(profile, skill) do
    index = get_in(profile, [:indexes, skill, :index])
    is_number(index) and index >= @qualified_index and is_number(profile.contribution_factor)
  end

  defp redundancy_entries(profiles) do
    Map.new(SkillIndexes.skills(), fn skill ->
      providers =
        profiles
        |> Enum.filter(&qualified_provider?(&1, skill))
        |> Enum.map(fn profile ->
          player_entry(profile, %{
            figure: get_in(profile, [:indexes, skill, :index]),
            amount: profile.contribution_factor
          })
        end)
        |> Enum.sort_by(&{&1.amount, &1.figure}, :desc)

      {skill, providers}
    end)
  end

  defp skill_concentration(profiles) do
    initial = {%{}, %{}, [], %{}}

    {shares, scores, fallbacks, detail} =
      Enum.reduce(SkillIndexes.skills(), initial, fn skill, {shares, scores, fallbacks, detail} ->
        top_three =
          profiles
          |> Enum.map(&get_in(&1, [:indexes, skill, :index]))
          |> Enum.filter(&is_number/1)
          |> Enum.sort(:desc)
          |> Enum.take(3)

        players = top_three_players(profiles, skill)

        total = Enum.sum(top_three)

        if length(top_three) < 3 or total == 0 do
          reason =
            if length(top_three) < 3, do: :fewer_than_three_indexes, else: :zero_top_three_sum

          fallback = %{
            input: Atom.to_string(skill),
            method: :neutral_skill_concentration,
            note:
              "D-24 applies the neutral concentration score of 50 for #{skill}: " <>
                concentration_reason(reason, length(top_three))
          }

          {
            Map.put(shares, skill, nil),
            Map.put(scores, skill, @neutral_concentration),
            [fallback | fallbacks],
            Map.put(detail, skill, %{players: players, stand_in: stand_in(reason)})
          }
        else
          share = hd(top_three) / total

          {
            Map.put(shares, skill, share),
            Map.put(scores, skill, concentration_score(share)),
            fallbacks,
            Map.put(detail, skill, %{players: players, stand_in: nil})
          }
        end
      end)

    average = scores |> Map.values() |> then(&(Enum.sum(&1) / length(SkillIndexes.skills())))

    {average, %{top_player_shares: shares, scores: scores}, Enum.reverse(fallbacks), detail}
  end

  # The players whose figures `top_three` holds, in the same order: each
  # profile beside its own index, the unmeasured left out, highest first.
  defp top_three_players(profiles, skill) do
    profiles
    |> Enum.map(&{&1, get_in(&1, [:indexes, skill, :index])})
    |> Enum.filter(fn {_profile, figure} -> is_number(figure) end)
    |> Enum.sort_by(fn {_profile, figure} -> figure end, :desc)
    |> Enum.take(3)
    |> Enum.map(fn {profile, figure} ->
      %{
        player_id: player_id(profile.player),
        name: fetch_any(profile.player, :name),
        figure: figure
      }
    end)
  end

  defp stand_in(:fewer_than_three_indexes), do: "fewer_than_three"
  defp stand_in(:zero_top_three_sum), do: "zero_total"

  # One player's entry in a position-depth or skill-redundancy list: who he
  # is, what his contribution was worked out from, and the given facts.
  defp player_entry(profile, facts) do
    basis = SkillIndexes.contribution_basis(profile.player)

    Map.merge(
      %{
        player_id: player_id(profile.player),
        name: fetch_any(profile.player, :name),
        season_minutes: basis.season_minutes,
        two_way: basis.two_way
      },
      facts
    )
  end

  defp player_id(player), do: fetch_any(player, :id) || fetch_any(player, :player_id)

  defp add_adjacent_units(units, position, factor) do
    Enum.reduce(Map.fetch!(@adjacent, position), units, fn adjacent, acc ->
      Map.update!(acc, adjacent, &(&1 + factor * @adjacent_credit))
    end)
  end

  defp weakest_blend(scores) do
    average = Enum.sum(scores) / length(scores)
    weakest = Enum.min(scores)
    {average * @average_weight + weakest * @weakest_weight, average, weakest}
  end

  defp interpolate(value, low_x, low_y, high_x, high_y) do
    low_y + (value - low_x) / (high_x - low_x) * (high_y - low_y)
  end

  defp fetch_any!(map, key) do
    case fetch_any(map, key) do
      nil -> raise KeyError, key: key, term: map
      value -> value
    end
  end

  defp fetch_any(map, key), do: Map.get(map, key, Map.get(map, Atom.to_string(key)))

  defp player_identifier(player) do
    fetch_any(player, :id) || fetch_any(player, :player_id) || player_label(player)
  end

  defp player_label(player) do
    fetch_any(player, :name) ||
      "Player #{inspect(fetch_any(player, :id) || fetch_any(player, :player_id))}"
  end

  defp concentration_reason(:fewer_than_three_indexes, count),
    do: "only #{count} measured player indexes were available."

  defp concentration_reason(:zero_top_three_sum, _count),
    do: "the top-three index sum was zero."
end
inputs.exElixir

lib/trade_machine/gm_grade_v2/pillars/roster_construction/inputs.ex

See the implementation below.

Download source ↓

SHA-256 d4bbc963c45eb0a61584a37487075d60ea3d5381088cc03fba69ca987c68124c

defmodule TradeMachine.GMGradeV2.Pillars.RosterConstruction.Inputs do
  @moduledoc false

  alias TradeMachine.GMGradeV2.Benchmark
  alias TradeMachine.GMGradeV2.ChallengeSnapshot

  @skill_evidence_keys [
    :player_id,
    :season_minutes,
    :games_played,
    :minutes_per_game,
    :assists,
    :turnovers,
    :usg_pct,
    :fg3_pct,
    :fg3a,
    :ts_pct,
    :fga,
    :fta,
    :ft_pct,
    :epm_def,
    :steals,
    :blocks,
    :rebounds
  ]

  # The scenario-owned membership fields — identity, listed position, and
  # contract/two-way status — exactly the shape `ScenarioState` emits (see its
  # `standard_roster/1` and `two_way_roster/1`). Only these may override the
  # frozen player: a scenario legitimately re-positions or re-signs a player, so
  # position and two-way status must win. Everything else — the write-once
  # statistical/skill evidence in `@skill_evidence_keys` — must come from the
  # snapshot and can never be replaced by a roster field.
  @membership_keys [
    :id,
    :player_id,
    :name,
    :position,
    :salary,
    :is_draft_pick,
    :is_two_way
  ]

  # Both spellings, because roster rows arrive atom-keyed in memory and
  # string-keyed out of Postgres / form params — the same dual-spelling rule
  # `SkillIndexes.contribution_factor/2` follows. `Map.take/2` copies whichever
  # spelling the member actually carries.
  @membership_key_spellings Enum.flat_map(@membership_keys, &[&1, Atom.to_string(&1)])

  @doc """
  Joins scenario roster membership to the snapshot's frozen player evidence.

  `ScenarioState` deliberately emits membership only; stats and skill evidence
  live in the write-once challenge snapshot. Only the allowlisted membership
  fields (identity, position, contract/two-way status) merge over the frozen
  player, so scenario-owned position and two-way status win on duplicate keys
  while frozen skill evidence can never be overwritten — a canonical
  `ScenarioState` row carries no stat line, but an enriched or future caller that
  did would otherwise silently replace write-once evidence (e.g. a member
  `season_minutes: 0` zeroing a frozen `800`) and move Position Coverage, Skill
  Coverage, and Functional Depth.
  """
  @spec hydrate_roster([map()], ChallengeSnapshot.t()) :: [map()]
  def hydrate_roster(roster, %ChallengeSnapshot{} = snapshot) when is_list(roster) do
    players = ChallengeSnapshot.section(snapshot, :players)

    Enum.map(roster, fn member ->
      member
      |> player_id!()
      |> frozen_player(players)
      |> canonicalize_skill_evidence()
      |> Map.merge(Map.take(member, @membership_key_spellings))
    end)
  end

  @doc """
  Returns the constants override frozen with the benchmark.

  Benchmarks created before this provenance field existed use the versioned
  defaults. String keys are retained because `ModelVersion` accepts both JSON
  and in-memory spellings without interning document input.
  """
  @spec model_override(ChallengeSnapshot.t()) :: map()
  def model_override(%ChallengeSnapshot{benchmark: %Benchmark{data: data}}) do
    with meta when is_map(meta) <- fetch_any(data, :meta),
         override when is_map(override) <- fetch_any(meta, :model_override) do
      override
    else
      _ -> %{}
    end
  end

  @doc "Returns an override already attached by the pillar, or the benchmark's frozen value."
  @spec model_override(map(), ChallengeSnapshot.t()) :: map()
  def model_override(scenario_state, %ChallengeSnapshot{} = snapshot)
      when is_map(scenario_state) do
    case Map.get(scenario_state, :model_override) do
      override when is_map(override) -> override
      _ -> model_override(snapshot)
    end
  end

  defp frozen_player(player_id, players) do
    case Map.get(players, player_id) || Map.get(players, to_string(player_id)) do
      player when is_map(player) -> player
      _ -> %{}
    end
  end

  defp player_id!(member) do
    case fetch_any(member, :id) || fetch_any(member, :player_id) do
      nil -> raise KeyError, key: :id, term: member
      player_id -> player_id
    end
  end

  # JSON documents return string keys, while `PlayerImpact.season_minutes/1`
  # and the skill formulas consume the schema's atom fields. Only this fixed
  # vocabulary is canonicalized; arbitrary document input is never atomized.
  defp canonicalize_skill_evidence(player) do
    Enum.reduce(@skill_evidence_keys, player, fn key, canonical ->
      case Map.fetch(canonical, key) do
        {:ok, _value} ->
          canonical

        :error ->
          case Map.fetch(canonical, Atom.to_string(key)) do
            {:ok, value} -> Map.put(canonical, key, value)
            :error -> canonical
          end
      end
    end)
  end

  defp fetch_any(map, key) when is_map(map) do
    case Map.fetch(map, key) do
      {:ok, value} -> value
      :error -> Map.get(map, Atom.to_string(key))
    end
  end

  defp fetch_any(_other, _key), do: nil
end
position_coverage.exElixir

lib/trade_machine/gm_grade_v2/pillars/roster_construction/position_coverage.ex

Scores AVC's Position Coverage metric over the entire final roster.

Each player contributes only at their listed position. The historical player feed's generic "G" display value is canonicalized to "SG" — the same conservative rule used by calibration, which avoids inventing primary-handler credit. Their contribution is the shared TradeMachine.GMGradeV2.SkillIndexes.contribution_factor/2 , so the 800-minute experience curve and the two-way availability multiplier remain centralized. A position reaches full coverage at one contribution unit.

The result's inputs.detail records who makes up each position's units, so a breakdown can show them without working anything out again:

    %{
      experience_minutes: 800,
      positions: %{
        "PG" => [%{player_id: id, name: name, amount: 1.0,
                   season_minutes: 2100, two_way: false}, ...],
        ...all five positions, always present
      }
    }

Each position lists every player counted there, largest amount first (roster order among equal amounts). A position's amounts sum to its inputs.coverage_units figure; a player with no minutes sample has no entry (he is in fallbacks ). season_minutes and two_way are what the amount was worked out from ( SkillIndexes.contribution_basis/1 ), and experience_minutes is the number of minutes that counts as full experience under the same model override, so SkillIndexes.contribution_factor/2 on a player built from an entry gives back its amount. Nothing reads detail to compute a score.

Download source ↓

SHA-256 de62684f53838f238fc1d1d08954df91eaa8bdd8d6c6c7dde2f32bb0ffc59897

defmodule TradeMachine.GMGradeV2.Pillars.RosterConstruction.PositionCoverage do
  @moduledoc """
  Scores AVC's Position Coverage metric over the entire final roster.

  Each player contributes only at their listed position. The historical player
  feed's generic `"G"` display value is canonicalized to `"SG"` — the same
  conservative rule used by calibration, which avoids inventing primary-handler
  credit. Their contribution is the shared
  `TradeMachine.GMGradeV2.SkillIndexes.contribution_factor/2`, so the 800-minute
  experience curve and the two-way availability multiplier remain centralized.
  A position reaches full coverage at one contribution unit.

  The result's `inputs.detail` records who makes up each position's units, so
  a breakdown can show them without working anything out again:

      %{
        experience_minutes: 800,
        positions: %{
          "PG" => [%{player_id: id, name: name, amount: 1.0,
                     season_minutes: 2100, two_way: false}, ...],
          ...all five positions, always present
        }
      }

  Each position lists every player counted there, largest amount first (roster
  order among equal amounts). A position's amounts sum to its
  `inputs.coverage_units` figure; a player with no minutes sample has no entry
  (he is in `fallbacks`). `season_minutes` and `two_way` are what the amount
  was worked out from (`SkillIndexes.contribution_basis/1`), and
  `experience_minutes` is the number of minutes that counts as full experience
  under the same model override, so `SkillIndexes.contribution_factor/2` on a
  player built from an entry gives back its amount. Nothing reads `detail` to
  compute a score.
  """

  alias TradeMachine.GMGradeV2.Benchmark
  alias TradeMachine.GMGradeV2.ChallengeSnapshot
  alias TradeMachine.GMGradeV2.ModelVersion
  alias TradeMachine.GMGradeV2.Pillars.RosterConstruction.Inputs
  alias TradeMachine.GMGradeV2.Result.MetricResult
  alias TradeMachine.GMGradeV2.SkillIndexes

  @positions ~w(PG SG SF PF C)
  @average_weight 0.70
  @weakest_weight 0.30

  @doc "Returns the five positions in AVC's stated order."
  @spec positions() :: [String.t()]
  def positions, do: @positions

  @doc "Normalizes an AVC position (including legacy `G`) or raises."
  @spec normalize_position!(String.t() | atom()) :: String.t()
  def normalize_position!(position) when position in @positions, do: position
  def normalize_position!("G"), do: "SG"

  def normalize_position!(position) when is_atom(position) do
    position
    |> Atom.to_string()
    |> String.upcase()
    |> normalize_position!()
  end

  def normalize_position!(position) do
    raise ArgumentError,
          "position must be one of #{Enum.join(@positions, ", ")}, got: #{inspect(position)}"
  end

  @doc "Returns a full-precision Position Coverage metric result."
  @spec score(map(), ChallengeSnapshot.t()) :: MetricResult.t()
  def score(
        %{roster: roster} = scenario_state,
        %ChallengeSnapshot{benchmark: %Benchmark{} = benchmark} = snapshot
      )
      when is_list(roster) do
    override = Inputs.model_override(scenario_state, snapshot)
    {units, fallbacks, entries} = coverage_units_with_entries(roster, override)

    position_scores =
      Map.new(units, fn {position, value} -> {position, position_score(value)} end)

    scores = Map.values(position_scores)
    average = Enum.sum(scores) / length(@positions)
    weakest = Enum.min(scores)

    %MetricResult{
      key: :position_coverage,
      version: benchmark.version,
      score: average * @average_weight + weakest * @weakest_weight,
      inputs: %{
        coverage_units: units,
        average_position_score: average,
        weakest_position_score: weakest,
        detail: %{
          experience_minutes: ModelVersion.experience_minutes(override),
          positions: entries
        }
      },
      supporting: position_scores,
      weights: %{average: @average_weight, weakest: @weakest_weight},
      fallbacks: fallbacks,
      explanation:
        "Position Coverage gives 70% weight to the five-position average and 30% " <>
          "to the weakest listed position."
    }
  end

  @doc """
  Sums player contribution factors at each listed position.

  Players with unknown season minutes receive no invented coverage credit and
  are reported as fallbacks. The legacy generic-guard value `G` uses the
  documented `SG` canonicalization; other positions outside AVC's
  PG/SG/SF/PF/C vocabulary are rejected rather than silently omitted.
  """
  @spec coverage_units([map()], map()) ::
          {%{String.t() => float()}, [MetricResult.fallback()]}
  def coverage_units(roster, override \\ %{}) when is_list(roster) and is_map(override) do
    {units, fallbacks, _entries} = coverage_units_with_entries(roster, override)
    {units, fallbacks}
  end

  # `coverage_units/2` plus, collected in the same pass, the players behind
  # each position's units (largest amount first). The units are added up
  # exactly as before; the entries are recorded beside them and read by
  # nothing that scores.
  defp coverage_units_with_entries(roster, override) do
    initial = {Map.new(@positions, &{&1, 0.0}), [], Map.new(@positions, &{&1, []})}

    {units, fallbacks, entries} =
      Enum.reduce(roster, initial, fn player, {units, fallbacks, entries} ->
        position = player |> fetch_any!(:position) |> normalize_position!()

        case SkillIndexes.contribution_factor(player, override) do
          factor when is_number(factor) ->
            entry = coverage_entry(player, factor)

            {Map.update!(units, position, &(&1 + factor)), fallbacks,
             Map.update!(entries, position, &[entry | &1])}

          nil ->
            fallback = %{
              input: player_identifier(player),
              method: :missing_contribution_factor,
              note:
                "#{player_label(player)} has no season-minutes sample, so no " <>
                  "#{position} coverage credit was invented."
            }

            {units, [fallback | fallbacks], entries}
        end
      end)

    entries =
      Map.new(entries, fn {position, players} ->
        {position, players |> Enum.reverse() |> Enum.sort_by(& &1.amount, :desc)}
      end)

    {units, Enum.reverse(fallbacks), entries}
  end

  defp coverage_entry(player, amount) do
    basis = SkillIndexes.contribution_basis(player)

    %{
      player_id: fetch_any(player, :id) || fetch_any(player, :player_id),
      name: fetch_any(player, :name),
      amount: amount,
      season_minutes: basis.season_minutes,
      two_way: basis.two_way
    }
  end

  @doc "Converts coverage units to AVC's capped 0–100 individual-position score."
  @spec position_score(number()) :: float()
  def position_score(units) when is_number(units) and units >= 0 do
    100.0 * min(1.0, units)
  end

  defp fetch_any!(map, key) do
    case Map.get(map, key, Map.get(map, Atom.to_string(key))) do
      nil -> raise KeyError, key: key, term: map
      value -> value
    end
  end

  defp fetch_any(map, key), do: Map.get(map, key, Map.get(map, Atom.to_string(key)))

  defp player_identifier(player) do
    fetch_any(player, :id) || fetch_any(player, :player_id) || player_label(player)
  end

  defp player_label(player) do
    fetch_any(player, :name) || "Player #{inspect(player_identifier_without_label(player))}"
  end

  defp player_identifier_without_label(player) do
    fetch_any(player, :id) || fetch_any(player, :player_id) ||
      "at #{fetch_any(player, :position)}"
  end
end
roster_completeness.exElixir

lib/trade_machine/gm_grade_v2/pillars/roster_construction/roster_completeness.ex

Scores AVC's Roster Completeness metric over the final scenario roster.

Standard and two-way roster limits come from TradeMachine.CBA.Rules ; this module does not duplicate CBA constants. Standard contracts receive AVC's piecewise base score, and occupied two-way slots add at most five points.

Download source ↓

SHA-256 77b66dd36c129b2b8e64b79b81f61a6c1a650289db99f99225bb4c482031cc6f

defmodule TradeMachine.GMGradeV2.Pillars.RosterConstruction.RosterCompleteness do
  @moduledoc """
  Scores AVC's Roster Completeness metric over the final scenario roster.

  Standard and two-way roster limits come from `TradeMachine.CBA.Rules`; this
  module does not duplicate CBA constants. Standard contracts receive AVC's
  piecewise base score, and occupied two-way slots add at most five points.
  """

  alias TradeMachine.CBA.Rules
  alias TradeMachine.GMGradeV2.Benchmark
  alias TradeMachine.GMGradeV2.ChallengeSnapshot
  alias TradeMachine.GMGradeV2.Result.MetricResult

  @two_way_bonus_cap 5.0

  @doc "Returns a full-precision Roster Completeness metric result."
  @spec score(map(), ChallengeSnapshot.t()) :: MetricResult.t()
  def score(
        %{roster: roster},
        %ChallengeSnapshot{benchmark: %Benchmark{} = benchmark}
      )
      when is_list(roster) do
    {two_way_players, standard_players} = Enum.split_with(roster, &two_way?/1)
    standard_count = length(standard_players)
    two_way_count = length(two_way_players)
    minimum = Rules.min_standard_roster()
    maximum = Rules.max_standard_roster()
    maximum_two_way = Rules.max_two_way_contracts()
    standard_score = standard_roster_score(standard_count, minimum, maximum)
    bonus = two_way_bonus(two_way_count, maximum_two_way)

    %MetricResult{
      key: :roster_completeness,
      version: benchmark.version,
      score: min(100.0, standard_score + bonus),
      inputs: %{
        standard_count: standard_count,
        two_way_count: two_way_count,
        minimum_standard_roster: minimum,
        maximum_standard_roster: maximum,
        maximum_two_way_contracts: maximum_two_way
      },
      supporting: %{
        standard_roster_score: standard_score,
        two_way_bonus: bonus
      },
      explanation:
        "Roster Completeness scores #{standard_count} standard contracts and " <>
          "#{two_way_count} of #{maximum_two_way} available two-way slots."
    }
  end

  @doc """
  Applies AVC's season-aware piecewise curve to a standard-roster count.

  When the legal range spans more than two players, values between the legal
  minimum (80) and one below the maximum (90) are linearly interpolated.
  """
  @spec standard_roster_score(non_neg_integer(), non_neg_integer(), non_neg_integer()) :: float()
  # credo:disable-for-next-line Credo.Check.Refactor.CyclomaticComplexity
  def standard_roster_score(count, minimum, maximum)
      when is_integer(count) and count >= 0 and is_integer(minimum) and minimum >= 0 and
             is_integer(maximum) and maximum >= minimum do
    cond do
      count >= maximum ->
        100.0

      count == maximum - 1 ->
        90.0

      count >= minimum and maximum - minimum > 2 ->
        80.0 + 10.0 * (count - minimum) / (maximum - minimum - 1)

      count >= minimum ->
        80.0

      count == minimum - 1 ->
        60.0

      count == minimum - 2 ->
        40.0

      count == minimum - 3 ->
        20.0

      true ->
        0.0
    end
  end

  @doc "Calculates the capped five-point two-way roster bonus."
  @spec two_way_bonus(non_neg_integer(), non_neg_integer()) :: float()
  def two_way_bonus(_count, 0), do: 0.0

  def two_way_bonus(count, maximum)
      when is_integer(count) and count >= 0 and is_integer(maximum) and maximum > 0 do
    min(@two_way_bonus_cap, @two_way_bonus_cap * count / maximum)
  end

  defp two_way?(row) when is_map(row) do
    Map.get(row, :is_two_way, Map.get(row, "is_two_way")) == true
  end
end
skill_coverage.exElixir

lib/trade_machine/gm_grade_v2/pillars/roster_construction/skill_coverage.ex

Scores AVC's Skill Coverage metric over the entire final roster.

Each player's five reliability-adjusted indexes come from TradeMachine.GMGradeV2.SkillIndexes . The best providers are combined with AVC's skill-specific ranked weights, then each team raw is converted to a percentile against the frozen 30-team benchmark.

Per D-23, a ranked slot without a measured player index is filled with the reliability-shrunk league median of 50. The slot remains in the formula and its weight is not renormalized.

The result's inputs.detail records whose figure fills each ranked slot, so a breakdown can show them without working anything out again:

    %{
      skills: %{
        rebounding: [
          %{rank: 1, player_id: id, name: name, figure: 76.36, share: 0.50,
            stand_in: false},
          ...one entry per ranked slot, in rank order
        ],
        ...the five skills
      }
    }

share is the slot's weight. A slot nobody filled has player_id: nil , name: nil , figure: 50.0 and stand_in: true . A skill's figures equal inputs.ranked_player_indexes[skill] in order, and figure x share summed equals inputs.team_raw_scores[skill] . Nothing reads detail to compute a score.

Download source ↓

SHA-256 e15e58ec0dd07bc74de3829947c05dd044448fc5c2a13de354dd8f07332b0f2f

defmodule TradeMachine.GMGradeV2.Pillars.RosterConstruction.SkillCoverage do
  @moduledoc """
  Scores AVC's Skill Coverage metric over the entire final roster.

  Each player's five reliability-adjusted indexes come from
  `TradeMachine.GMGradeV2.SkillIndexes`. The best providers are combined with
  AVC's skill-specific ranked weights, then each team raw is converted to a
  percentile against the frozen 30-team benchmark.

  Per D-23, a ranked slot without a measured player index is filled with the
  reliability-shrunk league median of 50. The slot remains in the formula and
  its weight is not renormalized.

  The result's `inputs.detail` records whose figure fills each ranked slot, so
  a breakdown can show them without working anything out again:

      %{
        skills: %{
          rebounding: [
            %{rank: 1, player_id: id, name: name, figure: 76.36, share: 0.50,
              stand_in: false},
            ...one entry per ranked slot, in rank order
          ],
          ...the five skills
        }
      }

  `share` is the slot's weight. A slot nobody filled has `player_id: nil`,
  `name: nil`, `figure: 50.0` and `stand_in: true`. A skill's figures equal
  `inputs.ranked_player_indexes[skill]` in order, and `figure x share` summed
  equals `inputs.team_raw_scores[skill]`. Nothing reads `detail` to compute a
  score.
  """

  alias TradeMachine.GMGradeV2.Benchmark
  alias TradeMachine.GMGradeV2.ChallengeSnapshot
  alias TradeMachine.GMGradeV2.Percentile
  alias TradeMachine.GMGradeV2.Pillars.RosterConstruction.Inputs
  alias TradeMachine.GMGradeV2.Result.MetricResult
  alias TradeMachine.GMGradeV2.SkillIndexes

  @team_skill_weights [
    playmaking: [0.65, 0.35],
    shooting: [0.30, 0.25, 0.20, 0.15, 0.10],
    defense: [0.35, 0.30, 0.20, 0.15],
    rim_protection: [0.70, 0.30],
    rebounding: [0.50, 0.30, 0.20]
  ]
  @empty_slot_index 50.0
  @average_weight 0.70
  @weakest_weight 0.30

  if Keyword.keys(@team_skill_weights) != SkillIndexes.skills() do
    raise "team skill formulas must cover exactly SkillIndexes.skills/0, in order"
  end

  if Enum.any?(@team_skill_weights, fn {_skill, weights} ->
       abs(Enum.sum(weights) - 1.0) > 1.0e-9
     end) do
    raise "each team skill formula's weights must sum to 1.0"
  end

  @doc "The five AVC team skill raw formulas, in scoring order."
  @spec team_skill_weights() :: keyword([float()])
  def team_skill_weights, do: @team_skill_weights

  @doc "Returns a full-precision Skill Coverage metric result."
  @spec score(map(), ChallengeSnapshot.t()) :: MetricResult.t()
  def score(
        %{roster: roster} = scenario_state,
        %ChallengeSnapshot{benchmark: %Benchmark{} = benchmark} = snapshot
      )
      when is_list(roster) do
    skills = Benchmark.section(benchmark, :skills)
    tables = Map.fetch!(skills, "player_percentiles")
    benchmark_arrays = Map.fetch!(skills, "metrics")
    override = Inputs.model_override(scenario_state, snapshot)

    {raw_scores, ranked_indexes, fallbacks, slots} =
      team_raw_breakdown(roster, tables, %{override: override})

    skill_scores =
      Map.new(raw_scores, fn {skill, raw} ->
        array = Map.fetch!(benchmark_arrays, Atom.to_string(skill))
        {skill, Percentile.score(raw, array)}
      end)

    scores = Map.values(skill_scores)
    average = Enum.sum(scores) / length(@team_skill_weights)
    weakest = Enum.min(scores)

    %MetricResult{
      key: :skill_coverage,
      version: benchmark.version,
      score: average * @average_weight + weakest * @weakest_weight,
      inputs: %{
        team_raw_scores: raw_scores,
        ranked_player_indexes: ranked_indexes,
        average_skill_score: average,
        weakest_skill_score: weakest,
        detail: %{skills: slots}
      },
      supporting: skill_scores,
      weights: %{average: @average_weight, weakest: @weakest_weight},
      fallbacks: fallbacks,
      explanation:
        "Skill Coverage gives 70% weight to the five-skill average and 30% " <>
          "to the weakest roster-wide capability."
    }
  end

  @doc """
  Calculates the five pre-percentile team skill raws.

  This is also the benchmark builder's scoring seam, ensuring real-team arrays
  and challenge rosters use the same ranking, weights, and D-23 median fill.
  """
  @spec team_raw_scores([map()], map(), map()) :: %{atom() => float()}
  def team_raw_scores(roster, percentile_tables, opts \\ %{})
      when is_list(roster) and is_map(percentile_tables) and is_map(opts) do
    {raw_scores, _ranked_indexes, _fallbacks} =
      team_raw_details(roster, percentile_tables, opts)

    raw_scores
  end

  @doc false
  @spec team_raw_details([map()], map(), map()) ::
          {%{atom() => float()}, %{atom() => [float()]}, [MetricResult.fallback()]}
  def team_raw_details(roster, percentile_tables, opts \\ %{})
      when is_list(roster) and is_map(percentile_tables) and is_map(opts) do
    {raw_scores, ranked_indexes, fallbacks, _slots} =
      team_raw_breakdown(roster, percentile_tables, opts)

    {raw_scores, ranked_indexes, fallbacks}
  end

  # `team_raw_details/3` plus, collected in the same pass, whose figure fills
  # each ranked slot. The raws are added up exactly as before; the slots are
  # recorded beside them and read by nothing that scores.
  defp team_raw_breakdown(roster, percentile_tables, opts) do
    override = Map.get(opts, :override, %{})

    indexes =
      Enum.map(roster, &SkillIndexes.player_indexes(&1, percentile_tables, %{override: override}))

    {raw_scores, ranked_indexes, fallbacks, slots} =
      Enum.reduce(
        @team_skill_weights,
        {%{}, %{}, [], %{}},
        fn {skill, weights}, {raw_scores, ranked_indexes, fallbacks, slots} ->
          measured =
            indexes
            |> Enum.map(&get_in(&1, [:skills, skill, :index]))
            |> Enum.filter(&is_number/1)
            |> Enum.sort(:desc)
            |> Enum.take(length(weights))

          providers = ranked_providers(roster, indexes, skill, length(weights))

          missing_count = max(0, length(weights) - length(measured))
          ranked = measured ++ List.duplicate(@empty_slot_index, missing_count)

          raw =
            ranked
            |> Enum.zip(weights)
            |> Enum.reduce(0.0, fn {index, weight}, total -> total + index * weight end)

          skill_fallbacks =
            if missing_count == 0 do
              []
            else
              [
                %{
                  input: Atom.to_string(skill),
                  method: :league_median_ranked_slot,
                  note:
                    "#{missing_count} unfilled #{skill} ranked #{slot_label(missing_count)} " <>
                      "used the D-23 reliability-shrunk league median of 50."
                }
              ]
            end

          {
            Map.put(raw_scores, skill, raw),
            Map.put(ranked_indexes, skill, ranked),
            fallbacks ++ skill_fallbacks,
            Map.put(slots, skill, ranked_slots(providers, weights))
          }
        end
      )

    {raw_scores, ranked_indexes, fallbacks, slots}
  end

  # The players whose figures `measured` holds, in the same order: each row
  # beside its own index, the unmeasured left out, highest figure first, as
  # many as the skill has slots.
  defp ranked_providers(roster, indexes, skill, slot_count) do
    roster
    |> Enum.zip(indexes)
    |> Enum.map(fn {row, index} -> {row, get_in(index, [:skills, skill, :index])} end)
    |> Enum.filter(fn {_row, figure} -> is_number(figure) end)
    |> Enum.sort_by(fn {_row, figure} -> figure end, :desc)
    |> Enum.take(slot_count)
  end

  # One entry per ranked slot: the provider who fills it, or the D-23 stand-in.
  defp ranked_slots(providers, weights) do
    weights
    |> Enum.with_index(1)
    |> Enum.map(fn {share, rank} ->
      case Enum.at(providers, rank - 1) do
        {row, figure} ->
          %{
            rank: rank,
            player_id: fetch_any(row, :id) || fetch_any(row, :player_id),
            name: fetch_any(row, :name),
            figure: figure,
            share: share,
            stand_in: false
          }

        nil ->
          %{
            rank: rank,
            player_id: nil,
            name: nil,
            figure: @empty_slot_index,
            share: share,
            stand_in: true
          }
      end
    end)
  end

  defp fetch_any(map, key), do: Map.get(map, key, Map.get(map, Atom.to_string(key)))

  defp slot_label(1), do: "slot"
  defp slot_label(_count), do: "slots"
end

Found an unexpected score? Record the model version, mandate, evidence date, and the smallest scenario that reproduces it.

Next: Contract health →

Teams

More

Community Trade ideas and community discussions Current challenges How challenges are graded Explore the six pillars of a good GM
Browse
Team Contracts Player Contracts FA Market
App
Install app

Open trades and cap sheets straight from your home screen in their own app window.

iPhone or iPad

In Safari, open the Share menu, choose Add to Home Screen, then tap Add. Keep Open as Web App enabled if shown.

Android or desktop

Use Install Armchair GM above when available, or open your browser menu and choose Install app or Add to Home screen.

An internet connection is required for live data, trades, and scenario changes.

What's new About
Account
Sign in Tip jar Support Armchair GM