fix: CheckWin守卫wildcard重复计数 + 人类HUD集成对手出牌

Critical: 固定wildcard(紅中)在tiles列表中又被wildcardCount计数
→ tiles中14张(含1張紅中)+wildcardCount(1)=15, 15%3=0≠2→拒绝胡
修复: 守卫减去tiles中已含的wildcard数

UX: 对手出牌直接嵌入人类HUD
→ 例: 对手: AI-南:10张 出:1万3条5筒 | AI-西:13张
This commit is contained in:
xiaoou
2026-07-04 17:46:21 +08:00
parent eb22f6ee28
commit a047877494
2 changed files with 21 additions and 1 deletions

View File

@ -38,6 +38,23 @@ public class HumanMahjongPlayer
if (wcTiles.Count > 0)
Console.WriteLine($" 🀫 宝牌(癞子): {string.Join(" ", wcTiles.Select(MahjongTile.ToString))}");
// Show opponent summary
Console.Write(" 对手: ");
var parts = new List<string>();
foreach (var op in state.PlayerOrder)
{
if (op == Name || !state.AlivePlayers.Contains(op)) continue;
var opHand = state.Hands[op];
var opExposed = "";
if (state.Exposed.TryGetValue(op, out var melds) && melds.Count > 0)
opExposed = $" 已{melds.Count}副";
var opDiscards = "";
if (state.DiscardHistory.TryGetValue(op, out var dh) && dh.Count > 0)
opDiscards = $" 出:{string.Join("", dh.TakeLast(5).Select(MahjongTile.ToString))}";
parts.Add($"{op}:{opHand.Count}张{opExposed}{opDiscards}");
}
Console.WriteLine(string.Join(" | ", parts));
// Show exposed melds
if (state.Exposed.TryGetValue(Name, out var exposed) && exposed.Count > 0)
{

View File

@ -30,7 +30,10 @@ public class MeldsSolver
// Standard mahjong hand: 4 melds (3 tiles each) + 1 pair (2 tiles) = 14 tiles
// With exposed melds, hand has fewer tiles. Valid counts: 2,5,8,11,14
int total = tiles.Count + wildcardCount;
// Fixed wildcards (e.g. 紅中) are IN the tiles list but skipped by BuildCounts.
// Only count non-wildcard tiles for the guard.
int wildcardsInTiles = tiles.Count(MahjongTile.IsWildcard);
int total = tiles.Count - wildcardsInTiles + wildcardCount;
if (total < 2 || total % 3 != 2 || total > 14)
return new MeldsResult { IsWin = false };