console
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>双色球手动数据版</title>
<style>
body {padding: 20px; font-family: Arial;}
.result {color: red; font-weight: bold;}
.box {margin: 10px; padding: 10px; border: 1px solid #ccc;}
.debug {color: #666; font-size:0.8em;}
</style>
</head>
<body>
<button onclick="generate()">生成号码</button>
<div id="result"></div>
<div class="debug" id="debug"></div>
<script>
// 手动填写的真实历史数据(最新期在最前面)
const historyData = [
// 格式:{ issue: "期号", red: [红球数组], blue: 蓝球数字 }
{ issue: "2025023", red: [9,12,13,24,25,33], blue: 7 },
{ issue: "2025022", red: [11,17,18,20,28,30], blue: 10 },
{ issue: "2025021", red: [7,8,16,18,25,32], blue: 14 },
{ issue: "2025020", red: [4,11,13,16,26,30], blue: 15 },
{ issue: "2025019", red: [5,13,17,18,22,23], blue: 11 },
{ issue: "2025018", red: [3,9,18,21,28,29], blue: 11 },
{ issue: "2025017", red: [4,12,15,18,28,29], blue: 5 },
{ issue: "2025016", red: [2,3,12,16,20,29], blue: 14 },
{ issue: "2025015", red: [4,11,15,24,25,33], blue: 15 },
{ issue: "2025014", red: [6,7,9,13,21,27], blue: 5 },
{ issue: "2025013", red: [4,14,16,23,24,30], blue: 14 },
{ issue: "2025012", red: [7,11,13,18,27,31], blue: 11 },
{ issue: "2025011", red: [6,13,17,22,24,29], blue: 11 },
{ issue: "2025010", red: [4,6,7,16,17,21], blue: 8 },
{ issue: "2025009", red: [2,4,11,12,23,25], blue: 6 },
{ issue: "2025008", red: [9,14,16,17,25,33], blue: 11 },
{ issue: "2025007", red: [7,8,14,18,21,27], blue: 11 },
{ issue: "2025006", red: [1,7,8,17,20,22], blue: 6 },
{ issue: "2025005", red: [10,16,19,27,28,30], blue: 9 },
{ issue: "2025004", red: [3,7,17,27,29,32], blue: 1 },
{ issue: "2025003", red: [10,19,20,26,28,29], blue: 15 },
{ issue: "2025002", red: [9,12,13,15,22,26], blue: 11 },
{ issue: "2025001", red: [2,3,17,18,22,33], blue: 16 },
{ issue: "2024151", red: [5,10,16,19,29,32], blue: 4 },
{ issue: "2024150", red: [13,14,20,22,26,32], blue: 2 },
{ issue: "2024149", red: [3,9,16,17,18,22], blue: 16 },
{ issue: "2024148", red: [2,6,15,16,21,23], blue: 11 },
{ issue: "2024147", red: [5,11,13,16,21,30], blue: 10 },
{ issue: "2024146", red: [2,4,11,22,27,32], blue: 10 },
{ issue: "2024145", red: [1,3,16,22,23,30], blue: 3 },
{ issue: "2024144", red: [2,9,11,17,20,30], blue: 11 },
{ issue: "2024143", red: [2,5,11,22,30,33], blue: 10 },
{ issue: "2024142", red: [4,6,13,21,22,25], blue: 6 },
{ issue: "2024141", red: [1,2,7,15,24,29], blue: 12 },
{ issue: "2024140", red: [4,7,8,17,22,26], blue: 15 },
{ issue: "2024139", red: [15,16,20,22,23,29], blue: 14 },
{ issue: "2024138", red: [2,7,11,21,27,28], blue: 2 }
];
// 基础工具函数
function getRandom(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
// 核心生成函数
function generateOptimizedNumbers() {
let red = new Set();
// 区域保证
red.add(getRandom(1,10));
red.add(getRandom(11,20));
red.add(getRandom(21,33));
// 主动创建连号
const base = red.values().next().value;
red.add(base + 1);
// 补充号码
while (red.size < 6) {
const num = getRandom(1,33);
if (!red.has(num)) red.add(num);
}
return {
red: [...red].sort((a,b) => a-b),
blue: getRandom(1,16)
};
}
// 验证函数
function hasConsecutive(red) {
for (let i = 1; i < red.length; i++) {
if (red[i] - red[i-1] === 1) return true;
}
return false;
}
function hasOverlap(current, last) {
return current.some(n => last.includes(n));
}
function hasInvalidParity(red) {
const parity = red.map(n => n % 2).join('');
return historyData.some(data =>
data.red.map(n => n % 2).join('') === parity
);
}
function hasInvalidPrimeCombo(red) {
const primes = [2,3,5,7,11,13,17,19,23,29,31];
const primeCount = red.filter(n => primes.includes(n)).length;
return historyData.slice(0,15).some(data =>
data.red.filter(n => primes.includes(n)).length === primeCount
);
}
function validSizeRatio(red) {
const bigCount = red.filter(n => n > 16).length;
const ratios = historyData.slice(0,4).map(d => d.red.filter(n => n >16).length);
return ratios.includes(bigCount);
}
// 主逻辑
function generate() {
let valid = false;
let attempt = 0;
let newNumbers;
const startTime = Date.now();
while (!valid && attempt < 10000) {
attempt++;
newNumbers = generateOptimizedNumbers();
valid = validateNumbers(newNumbers);
}
showDebugInfo(attempt, Date.now()-startTime);
displayResult(valid ? newNumbers : null);
}
function validateNumbers(numbers) {
const red = numbers.red;
const lastRed = historyData[0].red;
if (!hasConsecutive(red)) return addDebug('无连号');
if (!hasOverlap(red, lastRed)) return addDebug('无重复号');
if (hasInvalidParity(red)) return addDebug('奇偶比冲突');
if (hasInvalidPrimeCombo(red)) return addDebug('质数冲突');
if (!validSizeRatio(red)) return addDebug('大小比不符');
return true;
}
// 显示相关
let debugReasons = {};
function addDebug(reason) {
debugReasons[reason] = (debugReasons[reason] || 0) + 1;
return false;
}
function showDebugInfo(attempt, time) {
const debugInfo = Object.entries(debugReasons)
.map(([k,v]) => `${k}: ${v}次`)
.join(' | ');
document.getElementById('debug').innerHTML = `
尝试次数:${attempt}次<br>
耗时:${time}ms<br>
失败原因:${debugInfo || '无'}
`;
debugReasons = {};
}
function displayResult(numbers) {
const div = document.getElementById('result');
if (numbers) {
div.innerHTML = `
<div class="box">
推荐号码:<br>
红球:${numbers.red.join(', ')}<br>
蓝球:${numbers.blue}
</div>
`;
} else {
div.innerHTML = "⚠️ 未找到符合条件的组合(尝试10000次后)";
}
}
// 数据验证(开发时使用)
function validateHistoryData() {
// 检查数据完整性
if (historyData.length < 30) console.error("需要至少30期数据");
// 检查数据有效性
historyData.forEach(data => {
if (data.red.length !== 6) console.error(`${data.issue} 红球数量错误`);
if (data.red.some(n => n<1 || n>33)) console.error(`${data.issue} 包含非法红球`);
if (data.blue <1 || data.blue >16) console.error(`${data.issue} 蓝球号码错误`);
});
}
validateHistoryData(); // 开发时验证数据
</script>
</body>
</html>