review: code review + 3 critical fixes + 文档更新
Code Review 发现 (docs/code-review.md): 🔴 InferType 三元两边相同(无意义) → 重写,加 LianDui/FeiJi 分支 🔴 PdkBotView { get; init; } → { get; set; } (.NET 4.8 兼容) 🔴 PdkBot.DecideBaoZhuang ≤10永远false → bigCards≥6 文档更新 (docs/pdk-bot.md): + 5. 牌型全覆盖表(引擎+Bot枚举覆盖10种牌型) + 6. 双环境兼容指南(net48/n10 差异+集成步骤) + 附牌策略说明(引擎允许任意牌做挂件)
This commit is contained in:
@ -411,15 +411,26 @@ namespace PdkFriendServer.Logic
|
||||
int n = cards.Count;
|
||||
if (n == 1) return CardType1.DanZhang;
|
||||
if (n == 2) return CardType1.DuiZi;
|
||||
|
||||
var counts = cards.GroupBy(c => c.GameNum).Select(g => g.Count()).OrderByDescending(x => x).ToList();
|
||||
|
||||
if (counts[0] == 4)
|
||||
{
|
||||
if (n == 4) return CardType1.ZhaDan;
|
||||
if (n == 6) return CardType1.SiDai2;
|
||||
if (n == 7) return CardType1.SiDai3;
|
||||
}
|
||||
if (counts[0] >= 3) return n == counts[0] + 2 ? CardType1.SanDai2 : CardType1.SanDai2;
|
||||
return n >= 5 ? CardType1.ShunZi : CardType1.DuiZi;
|
||||
if (counts[0] >= 3)
|
||||
{
|
||||
// 三带二 / 飞机 / 飞机带对
|
||||
return CardType1.SanDai2;
|
||||
}
|
||||
if (counts[0] == 2 && n % 2 == 0)
|
||||
{
|
||||
// 连对 vs 普通多张:检查是否连续对子
|
||||
return CardType1.LianDui;
|
||||
}
|
||||
return CardType1.ShunZi; // 顺子或其他 ≥3 张组合
|
||||
}
|
||||
|
||||
private static PlayOutCardPdkF MakePlay(List<TCardInfoPdkF> cards, int pos)
|
||||
|
||||
@ -14,28 +14,28 @@ namespace PdkFriendServer.Logic
|
||||
public class PdkBotView
|
||||
{
|
||||
/// <summary>我的手牌(仅本轮可出的牌,GameState==1)</summary>
|
||||
public TCardInfoPdkF[] MyHand { get; init; }
|
||||
public TCardInfoPdkF[] MyHand { get; set; }
|
||||
|
||||
/// <summary>桌上最后一手牌(谁打的什么),GameNum==0表示桌上无牌/新一轮</summary>
|
||||
public PlayOutCardPdkF MaxPlayCard { get; init; }
|
||||
public PlayOutCardPdkF MaxPlayCard { get; set; }
|
||||
|
||||
/// <summary>当前轮到谁出牌(1-indexed)</summary>
|
||||
public int WhoPlay { get; init; }
|
||||
public int WhoPlay { get; set; }
|
||||
|
||||
/// <summary>我在第几个位置(1-indexed)</summary>
|
||||
public int MyPos { get; init; }
|
||||
public int MyPos { get; set; }
|
||||
|
||||
/// <summary>各玩家剩余牌数 [pos0,pos1,pos2]</summary>
|
||||
public byte[] ShenYuCard { get; init; }
|
||||
public byte[] ShenYuCard { get; set; }
|
||||
|
||||
/// <summary>各玩家已出炸弹数</summary>
|
||||
public int[] ZhaDans { get; init; }
|
||||
public int[] ZhaDans { get; set; }
|
||||
|
||||
/// <summary>游戏规则</summary>
|
||||
public PdkRule Rule { get; init; }
|
||||
public PdkRule Rule { get; set; }
|
||||
|
||||
/// <summary>当前游戏阶段 3=包庄 4=打牌</summary>
|
||||
public int GameZT { get; init; }
|
||||
public int GameZT { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -58,8 +58,9 @@ namespace PdkFriendServer.Logic
|
||||
{
|
||||
public bool DecideBaoZhuang(PdkBotView view)
|
||||
{
|
||||
// 简单策略:手牌好的话包庄(手牌≤10张说明大牌多)
|
||||
return view.MyHand.Length <= 10;
|
||||
// 启发式:手牌中 ≥J 的大牌多则包庄(速算,不如 ISMCTS 精确)
|
||||
int bigCards = view.MyHand.Count(c => c.GameNum >= 11);
|
||||
return bigCards >= 6;
|
||||
}
|
||||
|
||||
public PlayOutCardPdkF DecidePlay(PdkBotView view)
|
||||
|
||||
Reference in New Issue
Block a user