fix: 人类模式主回合听牌显示具体张数和牌名
CheckTing→GetTingTiles: 返回可胡牌列表而非bool
主回合显示: 🀄听 4张(🀫3万 🀫4万 中 白) — 与反应提示一致
This commit is contained in:
@ -86,8 +86,8 @@ public class HumanMahjongPlayer
|
|||||||
var pungOpt = legalActions.FirstOrDefault(a => a.Action == "pung");
|
var pungOpt = legalActions.FirstOrDefault(a => a.Action == "pung");
|
||||||
var kongOpts = legalActions.Where(a => a.Action is "ming_kong" or "an_kong" or "bu_kong").ToList();
|
var kongOpts = legalActions.Where(a => a.Action is "ming_kong" or "an_kong" or "bu_kong").ToList();
|
||||||
|
|
||||||
// Check if we're one tile away from winning (ting)
|
// Check if we're one tile away from winning (ting) — returns list of winning tiles
|
||||||
bool isTing = CheckTing(state);
|
var tingTiles = GetTingTiles(state);
|
||||||
|
|
||||||
Console.Write(" 可选操作: ");
|
Console.Write(" 可选操作: ");
|
||||||
var ops = new List<string>();
|
var ops = new List<string>();
|
||||||
@ -95,7 +95,11 @@ public class HumanMahjongPlayer
|
|||||||
if (pungOpt != null) ops.Add("p(碰)");
|
if (pungOpt != null) ops.Add("p(碰)");
|
||||||
if (kongOpts.Count > 0) ops.Add($"k(杠: {string.Join("/", kongOpts.Select(o => o.Action))})");
|
if (kongOpts.Count > 0) ops.Add($"k(杠: {string.Join("/", kongOpts.Select(o => o.Action))})");
|
||||||
if (winOpt != null) ops.Add("h✨(胡!)");
|
if (winOpt != null) ops.Add("h✨(胡!)");
|
||||||
if (isTing) ops.Add("🀄听牌!");
|
if (tingTiles.Count > 0)
|
||||||
|
{
|
||||||
|
var names = tingTiles.Select(t => MahjongTile.ToString(t, state.Wildcards));
|
||||||
|
ops.Add($"🀄听 {tingTiles.Count}张({string.Join(" ", names)})");
|
||||||
|
}
|
||||||
ops.Add("q(退出)");
|
ops.Add("q(退出)");
|
||||||
Console.WriteLine(string.Join(" ", ops));
|
Console.WriteLine(string.Join(" ", ops));
|
||||||
Console.Write("> ");
|
Console.Write("> ");
|
||||||
@ -115,8 +119,9 @@ public class HumanMahjongPlayer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool CheckTing(MahjongGameState state)
|
private List<int> GetTingTiles(MahjongGameState state)
|
||||||
{
|
{
|
||||||
|
var result = new List<int>();
|
||||||
var hand = state.Hands.GetValueOrDefault(Name, new List<int>());
|
var hand = state.Hands.GetValueOrDefault(Name, new List<int>());
|
||||||
// Combine with exposed melds
|
// Combine with exposed melds
|
||||||
var fullHand = new List<int>(hand);
|
var fullHand = new List<int>(hand);
|
||||||
@ -131,8 +136,8 @@ public class HumanMahjongPlayer
|
|||||||
{
|
{
|
||||||
if (hand.Count(t => t == tile) >= 4) continue;
|
if (hand.Count(t => t == tile) >= 4) continue;
|
||||||
var r = _solver.CheckWin(fullHand, newTile: tile, wildcardCount: wc);
|
var r = _solver.CheckWin(fullHand, newTile: tile, wildcardCount: wc);
|
||||||
if (r != null && r.IsWin) return true;
|
if (r != null && r.IsWin) result.Add(tile);
|
||||||
}
|
}
|
||||||
return false;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user