fix: --check输出区分能力注册 vs 规则覆盖, 不再误导

ValidateRuleCompliance 新增3项检查:
- 鸡胡缺失警告 (fan_types 应配鸡胡兜底)
- base_fan=0 番型警告 (标记番型需更高番型覆盖)
- 番型识别率统计 (DSL中有多少引擎能识别)

输出变更:
- 'DSL适配率' → '能力注册' (准确描述含义)
- 新增 '规则合规检查通过' (warnings=0时显示)
- --check末尾加警告: 能力注册≠完整规则覆盖
This commit is contained in:
xiaoou
2026-07-04 22:13:53 +08:00
parent a338dac139
commit 359e02886f
2 changed files with 22 additions and 4 deletions

View File

@ -40,15 +40,19 @@ try
rules = loader.Load(dslPath);
var (r, m, pct) = caps.ComputeCoverage(rules.Requires);
string status = pct == 100 ? "✅" : "⚠";
Console.WriteLine($"{status} DSL 适配率: {m}/{r} ({pct}%) — {rules.Game.Name}");
Console.WriteLine($"{status} 能力注册: {m}/{r} ({pct}%) — {rules.Game.Name}");
// Rule-level compliance check (finer granularity than capability check)
var warnings = caps.ValidateRuleCompliance(rules);
if (warnings.Count > 0)
{
Console.WriteLine($" ⚠ {warnings.Count} 条规则引擎无法完全执行:");
Console.WriteLine($" ⚠ {warnings.Count} 条规则警告:");
foreach (var w in warnings)
Console.WriteLine($"{w}");
Console.WriteLine($"{w}");
}
else
{
Console.WriteLine($" ✅ 规则合规检查通过");
}
if (pct < 100)
@ -67,7 +71,7 @@ catch (Exception ex)
if (checkOnly)
{
Console.WriteLine($"✅ 仅验证模式 — 未运行牌局");
Console.WriteLine($"\n✅ 仅验证模式 — 未运行牌局\n 注意: 能力注册≠完整规则覆盖, 需逐条验证玩法规则");
return 0;
}

View File

@ -113,6 +113,20 @@ public class CapabilityRegistry
if (rules.Scoring.Mode != "fan_table")
warnings.Add($"scoring.mode={rules.Scoring.Mode} 引擎仅支持fan_table→忽略");
// 鸡胡 兜底番型: DSL应配置以避免FanValue=0
if (!rules.FanTypes.Any(f => f.Name == "鸡胡"))
warnings.Add("fan_types 缺少鸡胡兜底番型→建议添加 { name: 鸡胡, base_fan: 1 }");
// 番型值检查: base_fan=0 的标记番型需有更高番型覆盖
var zeroFans = rules.FanTypes.Where(f => f.BaseFan <= 0).ToList();
if (zeroFans.Count > 0)
warnings.Add($"有 {zeroFans.Count} 个番型 base_fan=0 ({string.Join(", ", zeroFans.Select(f => f.Name))})→仅当被更高番型排除时有用");
// 番型识别率: DSL 中多少番型引擎能识别
int recognized = rules.FanTypes.Count(f => enginePatterns.Contains(f.Name));
if (recognized < rules.FanTypes.Count)
warnings.Add($"番型识别率: {recognized}/{rules.FanTypes.Count}→{rules.FanTypes.Count - recognized} 个番型得分为0");
return warnings;
}
}