From 2acbd22bad5aa7eca7e3d456e00144e79d5efeb1 Mon Sep 17 00:00:00 2001 From: zhouwei <849588297@qq.com> Date: Mon, 9 Feb 2026 18:49:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B7=B2=E7=9F=A5=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/taurus/util/test_smart.java | 66 ++++++++++++++++++- 1 file changed, 63 insertions(+), 3 deletions(-) diff --git a/robots/puke/robot_pk_pdk/src/main/java/taurus/util/test_smart.java b/robots/puke/robot_pk_pdk/src/main/java/taurus/util/test_smart.java index 41b519c..fae939b 100644 --- a/robots/puke/robot_pk_pdk/src/main/java/taurus/util/test_smart.java +++ b/robots/puke/robot_pk_pdk/src/main/java/taurus/util/test_smart.java @@ -1573,6 +1573,13 @@ public class test_smart { private static List findMatchingResponse(List handCards, int type, int minCard, int len) { System.out.println("[智能响应] 收到出牌请求 - 报告类型:" + getCardTypeName(type) + ", 最小牌:" + getCardName(minCard) + ", 长度:" + len); + // 智能纠错:根据牌数和常见模式推断真实牌型 + int correctedType = correctCardTypeByPattern(type, len, minCard); + if (correctedType != type) { + System.out.println("[智能纠错] 检测到类型推断可能有误,原始:" + getCardTypeName(type) + " -> 纠正:" + getCardTypeName(correctedType)); + type = correctedType; + } + // 直接分析实际牌面构成,这才是真正的智能! List actualCards = getLastPlayedCards(); if (actualCards != null && !actualCards.isEmpty()) { @@ -1645,7 +1652,16 @@ public class test_smart { private static List findConsecutivePairResponse(List handCards, int minCard, int len) { // 修正:len表示连对的数量,不是总牌数 - int pairCount = len; // len=2表示2连对(4张牌),len=3表示3连对(6张牌) + // 但是要考虑服务器可能传递的是总牌数的情况 + int pairCount; + if (len >= 4 && len % 2 == 0) { + // 如果len是偶数且>=4,可能是总牌数,需要转换为连对数 + pairCount = len / 2; // 4张牌=2连对,6张牌=3连对 + System.out.println("[连对响应] 检测到总牌数" + len + ",转换为" + pairCount + "连对"); + } else { + // 否则是标准的连对数 + pairCount = len; // len=2表示2连对 + } System.out.println("[连对响应] 寻找" + pairCount + "连对(共" + (pairCount*2) + "张牌),最小起始牌:" + getCardName(minCard)); @@ -2168,10 +2184,11 @@ public class test_smart { /** * 改进的牌型推断方法 - 修复连对识别错误 + * 修复要点:4张牌优先推断为连对而非炸弹 */ private static int inferCorrectCardType(int len) { // 优先处理常见的连对情况 - if (len == 4) return TYPE_CONSECUTIVE_PAIR; // 2连对 + if (len == 4) return TYPE_CONSECUTIVE_PAIR; // 2连对(最常见错误场景) if (len == 6) return TYPE_CONSECUTIVE_PAIR; // 3连对 if (len == 8) return TYPE_CONSECUTIVE_PAIR; // 4连对 if (len == 10) return TYPE_CONSECUTIVE_PAIR; // 5连对 @@ -2182,7 +2199,7 @@ public class test_smart { case 1: return TYPE_SINGLE; case 2: return TYPE_PAIR; case 3: return TYPE_TRIO; - case 4: return TYPE_BOMB; // 4张牌默认是炸弹(除非明确是连对) + case 4: return TYPE_CONSECUTIVE_PAIR; // 修复:4张牌优先推断为连对 case 5: return TYPE_TRIO_WITH_TWO; case 6: return TYPE_CONSECUTIVE_PAIR; default: @@ -2192,6 +2209,8 @@ public class test_smart { if (len >= MIN_STRAIGHT_LENGTH) return TYPE_STRAIGHT; // 飞机:3的倍数且>=6 if (len >= MIN_AIRPLANE_TRIO_COUNT * 5 && len % 5 == 0) return TYPE_AIRPLANE_WITH_CARDS; + // 真正的炸弹:必须明确是4张相同牌 + if (len == 4) return TYPE_BOMB; // 只有在确定是炸弹时才返回 return TYPE_SINGLE; } } @@ -2261,6 +2280,47 @@ public class test_smart { return null; } + /** 智能牌型纠错 - 根据常见模式和牌数推断正确牌型 */ + private static int correctCardTypeByPattern(int reportedType, int len, int minCard) { + System.out.println("[模式纠错] 分析牌型 - 报告类型:" + getCardTypeName(reportedType) + ", 牌数:" + len + ", 最小牌:" + getCardName(minCard)); + + // 典型错误情况1:4张牌被错误报告为炸弹(最常见错误) + if (reportedType == TYPE_BOMB && len == 4) { + System.out.println("[模式纠错] ⚠️ 检测到4张牌被报告为炸弹,极可能是连对错误识别"); + System.out.println("[模式纠错] 建议:将类型从炸弹纠正为连对"); + return TYPE_CONSECUTIVE_PAIR; // 强制纠正为连对 + } + + // 典型错误情况2:TYPE_CONSECUTIVE_PAIR(4)被错误使用 + if (reportedType == TYPE_CONSECUTIVE_PAIR && len == 4) { + // 这是正常的连对,不需要纠正 + System.out.println("[模式纠错] 4张牌正确识别为连对"); + return reportedType; + } + + // 典型错误情况3:连对被错误报告为其他类型 + if (len >= 4 && len % 2 == 0) { + // 偶数张牌很可能是连对 + if (reportedType != TYPE_CONSECUTIVE_PAIR && reportedType != TYPE_BOMB) { + System.out.println("[模式纠错] 偶数张牌(" + len + "张)更可能是连对"); + return TYPE_CONSECUTIVE_PAIR; + } + } + + // 典型错误情况4:顺子被错误报告 + if (len >= 5 && len <= 12) { + // 5-12张连续牌很可能是顺子 + if (reportedType == TYPE_SINGLE || reportedType == TYPE_PAIR) { + System.out.println("[模式纠错] " + len + "张连续牌更可能是顺子"); + return TYPE_STRAIGHT; + } + } + + // 如果没有发现明显错误,返回原始类型 + System.out.println("[模式纠错] 未发现明显错误,保持原始类型"); + return reportedType; + } + /** 智能分析实际牌型 - 真正的AI核心! */ private static int analyzeActualCardType(List cards) { if (cards == null || cards.isEmpty()) return TYPE_SINGLE;