修改已知问题

master
zhouwei 2026-02-09 18:49:22 +08:00
parent d26f9b6856
commit 2acbd22bad
1 changed files with 63 additions and 3 deletions

View File

@ -1573,6 +1573,13 @@ public class test_smart {
private static List<CardObj> findMatchingResponse(List<CardObj> handCards, int type, int minCard, int len) { private static List<CardObj> findMatchingResponse(List<CardObj> handCards, int type, int minCard, int len) {
System.out.println("[智能响应] 收到出牌请求 - 报告类型:" + getCardTypeName(type) + ", 最小牌:" + getCardName(minCard) + ", 长度:" + 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<CardObj> actualCards = getLastPlayedCards(); List<CardObj> actualCards = getLastPlayedCards();
if (actualCards != null && !actualCards.isEmpty()) { if (actualCards != null && !actualCards.isEmpty()) {
@ -1645,7 +1652,16 @@ public class test_smart {
private static List<CardObj> findConsecutivePairResponse(List<CardObj> handCards, int minCard, int len) { private static List<CardObj> findConsecutivePairResponse(List<CardObj> handCards, int minCard, int len) {
// 修正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)); System.out.println("[连对响应] 寻找" + pairCount + "连对(共" + (pairCount*2) + "张牌),最小起始牌:" + getCardName(minCard));
@ -2168,10 +2184,11 @@ public class test_smart {
/** /**
* - * -
* 4
*/ */
private static int inferCorrectCardType(int len) { 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 == 6) return TYPE_CONSECUTIVE_PAIR; // 3连对
if (len == 8) return TYPE_CONSECUTIVE_PAIR; // 4连对 if (len == 8) return TYPE_CONSECUTIVE_PAIR; // 4连对
if (len == 10) return TYPE_CONSECUTIVE_PAIR; // 5连对 if (len == 10) return TYPE_CONSECUTIVE_PAIR; // 5连对
@ -2182,7 +2199,7 @@ public class test_smart {
case 1: return TYPE_SINGLE; case 1: return TYPE_SINGLE;
case 2: return TYPE_PAIR; case 2: return TYPE_PAIR;
case 3: return TYPE_TRIO; 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 5: return TYPE_TRIO_WITH_TWO;
case 6: return TYPE_CONSECUTIVE_PAIR; case 6: return TYPE_CONSECUTIVE_PAIR;
default: default:
@ -2192,6 +2209,8 @@ public class test_smart {
if (len >= MIN_STRAIGHT_LENGTH) return TYPE_STRAIGHT; if (len >= MIN_STRAIGHT_LENGTH) return TYPE_STRAIGHT;
// 飞机3的倍数且>=6 // 飞机3的倍数且>=6
if (len >= MIN_AIRPLANE_TRIO_COUNT * 5 && len % 5 == 0) return TYPE_AIRPLANE_WITH_CARDS; 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; return TYPE_SINGLE;
} }
} }
@ -2261,6 +2280,47 @@ public class test_smart {
return null; return null;
} }
/** 智能牌型纠错 - 根据常见模式和牌数推断正确牌型 */
private static int correctCardTypeByPattern(int reportedType, int len, int minCard) {
System.out.println("[模式纠错] 分析牌型 - 报告类型:" + getCardTypeName(reportedType) + ", 牌数:" + len + ", 最小牌:" + getCardName(minCard));
// 典型错误情况14张牌被错误报告为炸弹最常见错误
if (reportedType == TYPE_BOMB && len == 4) {
System.out.println("[模式纠错] ⚠️ 检测到4张牌被报告为炸弹极可能是连对错误识别");
System.out.println("[模式纠错] 建议:将类型从炸弹纠正为连对");
return TYPE_CONSECUTIVE_PAIR; // 强制纠正为连对
}
// 典型错误情况2TYPE_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核心 */ /** 智能分析实际牌型 - 真正的AI核心 */
private static int analyzeActualCardType(List<CardObj> cards) { private static int analyzeActualCardType(List<CardObj> cards) {
if (cards == null || cards.isEmpty()) return TYPE_SINGLE; if (cards == null || cards.isEmpty()) return TYPE_SINGLE;