SOURCE

console 命令行工具 X clear

                    
>
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>
// 基础工具函数
function getRandom(min, max) {
    return Math.floor(Math.random() * (max - min + 1)) + min;
}

// 智能生成历史数据
function generateSmartNumbers() {
    let red = new Set();
    red.add(getRandom(1,10));
    red.add(getRandom(11,20));
    red.add(getRandom(21,33));
    
    // 强制连号
    const base = [1,11,21][getRandom(0,2)];
    red.add(base);
    red.add(base + 1);

    while (red.size < 6) {
        red.add(getRandom(1,33));
    }
    
    return {
        red: [...red].sort((a,b) => a-b),
        blue: getRandom(1,16)
    };
}

// 历史数据初始化
const historyData = Array.from({length:30}, (_,i) => ({
    issue: `2023${String(i+1).padStart(4,'0')}`,
    ...generateSmartNumbers()
}));

// 核心生成函数(已补全)
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次后)";
    }
}
</script>
</body>
</html>