mcpField
O
opponent-archetype-classifier

opponent-archetype-classifier

github.com/lyndonkl数据与数据库18744 次安装9 周前更新
代码仓库

关于 opponent-archetype-classifier

opponent-archetype-classifier 是用于根据观测特征推断对手策略类型的分类技能,适用于幻想体育、扑克等需要分析对手行为的场景。它通过贝叶斯方法计算完整后验分布,并结合观测权重报告分类置信度及响应提示。

主要功能

  1. 01使用提供的分类体系与特征分布
  2. 02计算各类型的特征似然
  3. 03通过贝叶斯规则生成后验分布
  4. 04结合观测权重计算分类置信度
  5. 05提供特征贡献与应对提示
  6. 06低置信度时标记为无法确定

适用场景

  1. 01根据阵容与操作记录分类幻想体育对手
  2. 02依据下注及牌局特征分析扑克对手
  3. 03用新增观测更新对手类型判断

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/lyndonkl/claude --skill opponent-archetype-classifier

安装后在 Claude Code 中输入/opponent-archetype-classifier确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

resources/
methodology.md
template.md
resources/evaluators/
rubric_opponent_archetype_classifier.json

详细介绍

对手类型分类器

目录

示例

场景:梦幻棒球联赛,第 5 周。将对手“Manager A”归入六种类型之一——balanced、stars_and_scrubs、punt_sv、punt_sb、punt_wins_qs、hitter_heavy。

输入(简略版;完整分类体系见 resources/template.md):

archetype_taxonomy:
  balanced:          {prior: 0.30, feature_distributions: {sp_roster_share: {mean: 0.40, std: 0.06}, closer_count: {mean: 2.0, std: 0.6}, sb_speed_count: {mean: 3.0, std: 1.0}, moves_per_week: {mean: 2.5, std: 1.0}, bid_aggression: {low: 0.5, high: 0.5}}}
  stars_and_scrubs:  {prior: 0.15, ...}
  punt_sv:           {prior: 0.15, feature_distributions: {closer_count: {mean: 0.3, std: 0.4}, ...}}
  punt_sb:           {prior: 0.15, feature_distributions: {sb_speed_count: {mean: 0.8, std: 0.7}, ...}}
  punt_wins_qs:      {prior: 0.10, feature_distributions: {sp_roster_share: {mean: 0.20, std: 0.05}, closer_count: {mean: 3.0, std: 0.8}, moves_per_week: {mean: 4.0, std: 1.2}, ...}}
  hitter_heavy:      {prior: 0.15, feature_distributions: {sp_roster_share: {mean: 0.28, std: 0.05}, ...}}

observed_features:
  sp_roster_share:   0.22    # low -- thin on starters
  closer_count:      3       # heavy RP
  sb_speed_count:    2       # moderate speed
  moves_per_week:    4.2     # high activity
  bid_aggression:    high    # active FAAB bidder

observation_weight: 0.7        # ~4 weeks of data

计算(逐项特征计算对数似然,求和、取指数、乘以先验概率并归一化):

类型log L(features)L * prior归一化后验概率
balanced-14.81.1e-70.04
stars_and_scrubs-12.55.6e-70.21
punt_sv-18.21.8e-90.00
punt_sb-22.62.3e-110.00
punt_wins_qs-10.11.8e-60.68
hitter_heavy-13.24.2e-70.16

输出:

posterior:
  balanced: 0.04
  stars_and_scrubs: 0.21
  punt_sv: 0.00
  punt_sb: 0.00
  punt_wins_qs: 0.68
  hitter_heavy: 0.16

map_archetype: punt_wins_qs

classification_confidence: 47.6     # = max_posterior (0.68) * observation_weight (0.7) * 100

best_response_hints:
  - "Concede K and QS; lock 6 of remaining 8 cats"
  - "Don't stream starting pitchers against them"
  - "They will dominate SV and ratios via all-RP staff; push hitting cats hard"

feature_contribution_breakdown:
  sp_roster_share:  {map_likelihood: 0.92, alternative_max: 0.15, likelihood_ratio: 6.1}   # low SP share -- strong punt_wins_qs signal
  closer_count:     {map_likelihood: 0.52, alternative_max: 0.46, likelihood_ratio: 1.1}   # 3 closers fits several archetypes
  sb_speed_count:   {map_likelihood: 0.38, alternative_max: 0.41, likelihood_ratio: 0.9}   # not discriminating
  moves_per_week:   {map_likelihood: 0.33, alternative_max: 0.28, likelihood_ratio: 1.2}
  bid_aggression:   {map_likelihood: 0.70, alternative_max: 0.60, likelihood_ratio: 1.2}

assumptions_flagged:
  - "Conditional independence across features assumed -- sp_roster_share and moves_per_week may be correlated (active punt strategy drives both)"
  - "Feature distributions are SME priors, not empirically fit -- refresh after season 1 with posterior data"

关于置信度的说明:后验概率峰值为 0.68,但 observation_weight=0.7(仅有 4 周的数据)会降低置信度,使其降至 47.6。该值高于 40 的阈值,因此报告 MAP;但建议调用方再观察 2-3 周,以提高判断的准确性。

工作流

复制此清单并跟踪进度:

Opponent Archetype Classification Progress:
- [ ] Step 1: Load archetype taxonomy (names, priors, feature distributions)
- [ ] Step 2: Collect observed features for the target opponent
- [ ] Step 3: Compute per-feature likelihood under each archetype
- [ ] Step 4: Combine likelihoods (assume conditional independence; flag it)
- [ ] Step 5: Apply Bayes rule, normalize posterior
- [ ] Step 6: Select MAP archetype; compute confidence
- [ ] Step 7: Check inconclusive threshold; report or defer
- [ ] Step 8: Produce feature-contribution breakdown and best-response hints

步骤 1:加载原型分类体系

调用方提供分类体系。必需字段请参见 resources/template.md。

  • 每个原型都有名称、先验概率,以及各可观测项的特征分布
  • 先验概率之和为 1.0(如不为 1.0,则进行归一化)
  • 每个特征都采用参数分布(均值/标准差的高斯分布)或类别分布(值 -> 概率)
  • 每个原型都有文档记录的 best_response 字符串数组

步骤 2:收集观测特征

观测特征必须与分类体系中的特征名称一致。缺失的特征会被丢弃(不进行插补)并标记。

  • 特征名称与分类体系中的键完全一致
  • 数值特征使用分类体系预期的单位
  • 类别特征使用分类体系中的类别标签
  • 提供 observation_weight(0-1);该值会随样本量增加而提高——参见 methodology.md

步骤 3:计算各特征的似然

针对每个(原型、特征)组合,计算 P(feature_value | archetype)。参见 methodology.md。

  • 高斯特征:L = (1/(std*sqrt(2*pi))) * exp(-0.5 * ((x - mean)/std)^2)
  • 类别特征:L = P_archetype[category],若为 0,则使用拉普拉斯平滑
  • 使用对数空间(log L),避免合并 5 个以上特征时发生下溢

步骤 4:合并似然(条件独立)

第一近似假设:给定原型时,各特征条件独立。这一假设很少完全成立;请标记。

  • 对每个原型,将各特征的对数似然相加
  • 标记相关的特征对(例如,幻想棒球中的 sp_roster_share 和 moves_per_week)
  • 如果两个特征高度相关,可考虑将它们合并或降低其中一个的权重;并记录所作选择

步骤 5:应用贝叶斯法则并进行归一化

posterior_unnorm[a] = exp(sum_log_L[a]) * prior[a]
posterior[a] = posterior_unnorm[a] / sum_a(posterior_unnorm[a])
  • 为确保数值稳定性,在对数空间中计算,然后在取指数前减去最大值
  • 验证 sum(posterior) == 1.0(允许舍入误差)
  • 将后验概率 < 1e-6 的原型记录为“已排除”

步骤 6:选择 MAP 原型并计算置信度

map_archetype = argmax(posterior)
classification_confidence = max(posterior) * observation_weight * 100
  • MAP 是最有可能的原型,并非唯一可能的原型
  • 置信度结合后验分布的集中程度与我们对观测结果的信任程度

步骤 7:结论不确定阈值

如果 classification_confidence < 40:

  • 返回 map_archetype: "inconclusive"
  • 仍返回完整后验概率(调用方可能仍会依据排名前 2 的结果采取行动)
  • 建议:“再收集 2-3 周的观测数据,然后再确定分类”

步骤 8:特征贡献明细和最佳响应提示

  • 为每个特征计算似然比:L(feature | MAP) / max_{a != MAP} L(feature | a)
  • 从 MAP 原型记录的字符串数组中提取 best_response_hints
  • 将其与后验概率一并返回,让调用方了解为何选择了该原型

常见模式

模式 1:梦幻体育(棒球、篮球、曲棍球)经理人原型

  • 分类体系:5-8 种原型,例如 balanced、punt_<cat>、stars_and_scrubs、inactive,涵盖类别联赛策略。
  • 特征:按位置划分的阵容构成、交易频率、FAAB 出价积极程度、阵容设置准确度。
  • 条件独立性风险:多个特征会协变(不活跃的经理人会同时减少操作和出价,并且阵容过时)。降低权重或合并。
  • 观测权重:到第 2 周为 0.3,第 5 周为 0.6,第 10 周为 0.85。

模式 2:扑克对手原型

  • 分类体系:tight_aggressive (TAG)、loose_aggressive (LAG)、tight_passive (rock)、loose_passive (calling station)、maniac。
  • 特征:VPIP、PFR、3-bet %、激进因子、持续下注频率、摊牌频率。
  • 条件独立性风险:VPIP 和 PFR 紧密相关;两者都保留,但需注明相关性。
  • 观测权重:随手牌数量迅速上升——100 手牌时为 0.4,500 手牌时为 0.75,2000 手牌以上时为 0.9。

模式 3:DFS 阵容构建原型

  • 分类体系:cash_game_optimizer、GPP_ceiling_chaser、contrarian_pivot、chalk_herding。
  • 特征:平均薪资使用量、堆叠数量、选中率与预测值之比、锦标赛与现金赛的参赛比例。
  • 条件独立性风险:对于 GPP 玩家,堆叠数量与选中率和预测值之比会协变。

模式 4:并购 / 拍卖竞标者原型

  • 分类体系:strategic_premium_bidder、financial_disciplined_bidder、fishing_expedition、structured_earnout_preferer。
  • 特征:每季度公布的出价数量、新闻稿中战略性与财务性表述的占比、支付的溢价倍数、交易结构(现金、股票或盈利对赌)。
  • 观测权重:单笔交易时权重较低;随着竞标历史记录增加而上升。

约束

  1. 条件独立几乎从来都不完全成立。 始终对此发出提示。如果两个特征高度相关(|r| > 0.6),请将它们合并为一个综合特征,或将其中一个的权重降低 50%。否则,同一个底层信号会让置信度较高的原型被重复计分。

  2. 数据稀少时,先验很重要。 均匀先验是一种选择,并非中立的默认值。如果已知总体分布,请使用领域信息设定先验(例如,在一场有 12 支队伍的梦幻体育联赛中,inactive 的实际基准率约为 1–2 名经理,而不是 1/12)。

  3. 数值稳定性:在对数空间中计算。 将 5 个以上的小似然相乘会导致 float64 下溢至 0。请对数似然求和,在取指数前减去最大的对数后验,然后进行归一化。

  4. 对类别变量进行拉普拉斯平滑。 如果某个原型的分布中 P(category=X) = 0,而观测值为 X,那么该原型的后验就会变为 0,并因单个数据点而被永久排除。请应用加 epsilon 平滑(通常 epsilon = 0.01)。

  5. 无法得出结论是一项有效特征,而非失败。 低置信度分类是有价值的信息——它告诉调用方,在做出决定前应收集更多数据。如果置信度低于 40,不要强行给出 MAP。

  6. 最佳应对提示来自分类体系,而非分类器。 该技能不应自行编造策略,而应检索分类体系作者为相应原型记录的内容。如果分类体系中的 best_response 为空,请返回空数组,并说明分类体系需要补充完善。

  7. 后验是一个分布,而非点估计。 下游 Agent 使用输出时,理想情况下应使用完整后验(并据此做出期望值决策),而不是将其简化为 MAP。请同时提供两者。

  8. 随着新观测到来,按顺序更新。 本周的后验将成为下周的先验。递归公式请参阅 methodology.md。

  9. 特征贡献明细有助于防止过拟合。 如果某个特征的似然比 > 10,说明该特征单独驱动了分类——在信任结果之前,请确认该特征的测量正确无误。

  10. 有了经验数据后,更新特征分布。 初始分布是 SME 先验。在为 N 名对手添加标签并观测后,请使用经验数据拟合分布,并替换 SME 先验。

快速参考

关键公式:

Gaussian likelihood:
  L(x | a) = (1 / (std_a * sqrt(2*pi))) * exp(-0.5 * ((x - mean_a) / std_a)^2)

Categorical likelihood (with Laplace smoothing, epsilon = 0.01):
  L(x = c | a) = (count_a[c] + epsilon) / (sum_c' count_a[c'] + epsilon * num_categories)

Joint likelihood (conditional independence assumption):
  L(features | a) = prod_f L(feature_f | a)

Log-space joint likelihood:
  log L(features | a) = sum_f log L(feature_f | a)

Bayes posterior:
  posterior(a) proportional to L(features | a) * prior(a)
  posterior(a) = posterior_unnorm(a) / sum_a' posterior_unnorm(a')

MAP selection:
  map_archetype = argmax_a posterior(a)

Classification confidence:
  confidence = max_a posterior(a) * observation_weight * 100
  if confidence < 40:
      map_archetype = "inconclusive"

Sequential update (week t):
  prior_t(a) = posterior_{t-1}(a)
  posterior_t(a) proportional to L(new_features_t | a) * prior_t(a)

Feature contribution (likelihood ratio):
  LR(feature_f) = L(feature_f | MAP) / max_{a != MAP} L(feature_f | a)

置信度区间:

置信度解释操作
0-39无法得出结论收集更多数据
40-59MAP 较弱将 MAP 视为暂定结果;对后续决策保持谨慎
60-79MAP 较可靠根据 MAP 采取行动,但也要考虑排名前两位的结果
80-100对 MAP 有把握确定采用 MAP

关键资源:

所需输入:

  • archetype_taxonomy:原型名称 -> {prior, feature_distributions, best_response} 的字典
  • observed_features:特征名称 -> 观测值的字典
  • observation_weight:0-1,表示对观测值相较于先验的信任程度
  • archetype_prior(可选):原型名称 -> 先验概率的字典;默认为分类体系中的先验概率(或均匀分布)

生成的输出:

  • posterior:字典<原型,概率>,总和为 1
  • map_archetype:字符串,最可能的原型(或 "inconclusive")
  • classification_confidence:0-100
  • best_response_hints:字符串数组,取自 MAP 原型记录的最佳应对策略
  • feature_contribution_breakdown:字典<特征,{map_likelihood, alternative_max, likelihood_ratio}>
  • assumptions_flagged:字符串数组,例如相关特征、已应用平滑、先验被强制设为均匀分布

评论

支持 Markdown