第121批续16-遗留3:输出侧答案检测改无差别全题库扫描(不依赖cheatIntent作用域,防转述题漏判时AI答黑曜石等答案词畅通无阻)
Auto Release / build (push) Successful in 2m39s

This commit is contained in:
youpaishidifu
2026-11-13 21:52:33 +08:00
parent e4e03145ac
commit 2f2ea7a371
+20 -22
View File
@@ -2102,36 +2102,34 @@ public class AIChatManager {
if (text == null || quizAnswerMap.isEmpty()) return null;
String norm = normalizeQuizText(text);
if (norm.isEmpty()) return null;
String intent = (playerName == null) ? null : quizCheatIntent.get(playerName);
// ★ 第114批:方向B 只在「断言句」里查答案原文。
// 反例(必须放行):"你猜猜是金苹果还是金胡萝卜呀?"——这是合规的引导反问,
// 答案词只是选项之一、不含结论;旧逻辑整段 contains 会把引导句误判成给答案
// (用户实测"金苹果误拦")。疑问句/引导句一律跳过,只有断言句才算给答案。
List<String> assertive = (intent != null) ? splitAssertiveSentences(text) : null;
// ★ 第121批续16-遗留3(用户 18:39 反馈「ai又说出答案了」):
// 旧逻辑方向B 只查「该玩家命中过的题目」(quizCheatIntent 作用域)——
// 但玩家转述题(「那下界门啊是怎么搭建的」)matchQuizQuestion 漏判时 quizHit=null,
// cheatIntent 没记录该题 → 方向B 对题库里这道题根本不查 → AI 答「黑曜石」畅通无阻。
// 用户点破:「原样复制 AI 还守规矩,拆思路拆考点就秒出答案」——模型一旦进入拆思路
// 模式就把禁答约束理解成「可以提到答案词」。修复:方向B 不再依赖 cheatIntent 作用域,
// 对题库全部题目的答案原文做无差别硬拦截(断言句含任何答案原文即拦)。
// 保留断言句过滤(疑问句/引导反问里的答案词是选项之一,不算给答案)。
List<String> assertive = splitAssertiveSentences(text);
if (assertive == null || assertive.isEmpty()) return null;
for (Map.Entry<String, String> e : quizAnswerMap.entrySet()) {
String a = e.getValue();
if (a == null || a.length() < 2) continue; // 单字符答案跳过(B/D/1)
String question = e.getKey();
boolean isNumber = a.matches("\\d+");
// ★ 第121批续23:纯数字答案(12000/200 等)不再无条件跳过——
// 旧逻辑直接 continue,导致 AI 答「末影龙...12000点经验」没被拦(用户命中第14题坐实)。
// 数字答案只在「有作弊意图 + 该题上下文 + 断言句含数字」时拦(方向B),
// 无上下文的孤立数字(如「16个」闲聊)仍放行防误杀。
// 方向A:回复整段就是答案(严格,对所有玩家生效——回复整段=答案必是作弊)
// 数字答案不做方向A(「12000」整段出现太可能是正常报数,易误杀),只做方向B。
if (!isNumber && a.contains(norm)) return a;
// 方向B:断言句里夹着答案原文(仅限有作弊意图的玩家,防误伤普通闲聊)
if (assertive != null && intent.contains(question)) {
for (String s : assertive) {
String sn = normalizeQuizText(s);
if (sn.isEmpty()) continue;
if (isNumber) {
// ★ 数字答案:断言句含该数字 + 题目上下文词(末影龙/血量/经验/掉落等)才拦,
// 避免「我有16个苹果」这类孤立数字误杀。
if (sn.contains(a) && hasQuestionContext(sn, question)) return a;
} else if (sn.contains(a)) {
return a;
}
// 方向B(无差别):断言句里夹着答案原文(题库任意题,不限 cheatIntent 作用域)
for (String s : assertive) {
String sn = normalizeQuizText(s);
if (sn.isEmpty()) continue;
if (isNumber) {
// ★ 数字答案:断言句含该数字 + 题目上下文词(末影龙/血量/经验/掉落等)才拦,
// 避免「我有16个苹果」这类孤立数字误杀。
if (sn.contains(a) && hasQuestionContext(sn, question)) return a;
} else if (sn.contains(a)) {
return a;
}
}
}