diff --git a/PdkFriendServer/Logic/SOIsmctsBot.cs b/PdkFriendServer/Logic/SOIsmctsBot.cs index fa6c4a62..ac443bd1 100644 --- a/PdkFriendServer/Logic/SOIsmctsBot.cs +++ b/PdkFriendServer/Logic/SOIsmctsBot.cs @@ -190,7 +190,9 @@ namespace PdkFriendServer.Logic return FastSim(o1g, o2g, mg, current, myGameNum, CardType1.DanZhang, myPos - 1, 0); } - // 快速模拟核心:全部用 byte[]。支持单张+对子。 + // 快速模拟核心:清牌效率优先。 + // 领牌:优先出多牌组合(3张>2张>1张),用最小的 rank 保留大牌 + // 跟牌:出最小的能压制的牌,保留大牌 private bool FastSim(List h1, List h2, List my, int current, byte maxGameNum, CardType1 maxType, int maxPlayer, int depth) { @@ -201,44 +203,63 @@ namespace PdkFriendServer.Logic var cur = current == 0 ? h1 : current == 1 ? h2 : my; bool isNewRound = maxPlayer == current || maxGameNum == 0; + bool isMe = (current == 2); if (isNewRound) { if (cur.Count == 0) return false; - // 找对子(贪心:出最大的对子) - var groups = cur.GroupBy(g => g).Where(g => g.Count() >= 2).OrderByDescending(g => g.Key).ToList(); - if (groups.Count > 0) + + // 清牌效率排序: 三张 > 对子 > 单张。始终用最小的 rank + var groups = cur.GroupBy(g => g).OrderBy(g => g.Key).ToList(); + + // 三张(清 3 张) + var triples = groups.Where(g => g.Count() >= 3).ToList(); + if (triples.Count > 0) { - var pair = groups[0]; - var toRemove = pair.Take(2).ToList(); + var t = triples[0]; + var toRemove = t.Take(3).ToList(); foreach (var g in toRemove) cur.Remove(g); - return FastSim(h1, h2, my, (current + 1) % 3, pair.Key, CardType1.DuiZi, current, depth + 1); + return FastSim(h1, h2, my, (current + 1) % 3, t.Key, CardType1.SanZhang, current, depth + 1); } - // 单张 - var sorted = cur.OrderByDescending(g => g).ToList(); - byte play = sorted[0]; + + // 对子(清 2 张) + var pairs = groups.Where(g => g.Count() >= 2).ToList(); + if (pairs.Count > 0) + { + var p = pairs[0]; + var toRemove = p.Take(2).ToList(); + foreach (var g in toRemove) cur.Remove(g); + return FastSim(h1, h2, my, (current + 1) % 3, p.Key, CardType1.DuiZi, current, depth + 1); + } + + // 单张:出最小的 + byte play = groups[0].Key; cur.Remove(play); return FastSim(h1, h2, my, (current + 1) % 3, play, CardType1.DanZhang, current, depth + 1); } else { - // 跟牌:找能压制的同类型牌 - var bigger = cur.Where(g => g > maxGameNum).OrderBy(g => g).ToList(); - if (maxType == CardType1.DuiZi) + // 跟牌:有牌能压 → 出最小的压制牌 + if (maxType == CardType1.DuiZi || maxType == CardType1.SanZhang) { - // 对子:找 ≥2 张且大于 maxGameNum - var pairGroups = cur.GroupBy(g => g).Where(g => g.Count() >= 2 && g.Key > maxGameNum).OrderBy(g => g.Key).ToList(); - if (pairGroups.Count > 0) + int need = maxType == CardType1.SanZhang ? 3 : 2; + var groups = cur.GroupBy(g => g) + .Where(g => g.Count() >= need && g.Key > maxGameNum) + .OrderBy(g => g.Key).ToList(); + if (groups.Count > 0) { - var pair = pairGroups[0]; - var toRemove = pair.Take(2).ToList(); - foreach (var g in toRemove) cur.Remove(g); - return FastSim(h1, h2, my, (current + 1) % 3, pair.Key, CardType1.DuiZi, current, depth + 1); + var g = groups[0]; + var toRemove = g.Take(need).ToList(); + foreach (var x in toRemove) cur.Remove(x); + return FastSim(h1, h2, my, (current + 1) % 3, g.Key, maxType, current, depth + 1); } } + + // 单张跟牌:出最小的可压牌 + var bigger = cur.Where(g => g > maxGameNum).OrderBy(g => g).ToList(); if (bigger.Count > 0) { - byte play = bigger[0]; + byte play = bigger[0]; // 最小压制 cur.Remove(play); return FastSim(h1, h2, my, (current + 1) % 3, play, CardType1.DanZhang, current, depth + 1); } diff --git a/exe/PdkFriendServer/PdkFriendServer.dll b/exe/PdkFriendServer/PdkFriendServer.dll index 8f1718ea..c5e54891 100644 Binary files a/exe/PdkFriendServer/PdkFriendServer.dll and b/exe/PdkFriendServer/PdkFriendServer.dll differ diff --git a/exe/PdkFriendServer/PdkFriendServer.pdb b/exe/PdkFriendServer/PdkFriendServer.pdb index e6d85e6c..77616822 100644 Binary files a/exe/PdkFriendServer/PdkFriendServer.pdb and b/exe/PdkFriendServer/PdkFriendServer.pdb differ diff --git a/exe/hjha-console/PdkFriendServer.dll b/exe/hjha-console/PdkFriendServer.dll index 8f1718ea..c5e54891 100644 Binary files a/exe/hjha-console/PdkFriendServer.dll and b/exe/hjha-console/PdkFriendServer.dll differ diff --git a/exe/hjha-console/PdkFriendServer.pdb b/exe/hjha-console/PdkFriendServer.pdb index e6d85e6c..77616822 100644 Binary files a/exe/hjha-console/PdkFriendServer.pdb and b/exe/hjha-console/PdkFriendServer.pdb differ diff --git a/exe/hjha-console/hjha-console.dll b/exe/hjha-console/hjha-console.dll index 26b40fb5..bc5eaa0d 100644 Binary files a/exe/hjha-console/hjha-console.dll and b/exe/hjha-console/hjha-console.dll differ diff --git a/exe/hjha-console/hjha-console.pdb b/exe/hjha-console/hjha-console.pdb index e9fafcf9..bf0b43e9 100644 Binary files a/exe/hjha-console/hjha-console.pdb and b/exe/hjha-console/hjha-console.pdb differ