SOURCE

console 命令行工具 X clear

                    
>
console
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <style>
        body { padding: 20px; font-family: -apple-system; max-width: 500px; margin: 0 auto; }
        #result { margin-top: 20px; padding: 15px; background: #f5f5f5; border-radius: 8px; }
        button { 
            padding: 12px 30px;
            background: #007AFF;
            color: white;
            border: none;
            border-radius: 8px;
            font-size: 17px;
            cursor: pointer;
            transition: opacity 0.3s;
        }
        button:active { opacity: 0.7; }
        .status { color: #666; margin-top: 10px; }
        .error { color: #FF3B30; }
    </style>
</head>
<body>
    <button onclick="generate()">点击生成智能双色球号码</button>
    <div id="result"></div>

<script>
// 配置参数
const GENERATOR = {
    redRange: [1, 33],
    primeNumbers: new Set([2,3,5,7,11,13,17,19,23,29,31]),
    maxAttempts: 2000
};

// 新增核心生成函数
function generateSmartNumbers(previousNumbers = []) {
    const reds = new Set();
    
    // 包含1-2个上期号码
    if (previousNumbers.length >= 1 && Math.random() < 0.8) {
        const repeatCount = Math.random() < 0.6 ? 1 : 2;
        const repeats = pickRandom(previousNumbers, repeatCount);
        repeats.forEach(n => reds.add(n));
    }
    
    // 智能生成剩余号码
    while(reds.size < 6) {
        const num = weightedRandomNumber();
        reds.add(num);
        
        // 60%概率生成连号
        if (reds.size < 5 && Math.random() < 0.6) {
            reds.add(num + 1);
        }
    }
    
    return Array.from(reds).sort((a, b) => a - b);
}

// 加权随机数生成器
function weightedRandomNumber() {
    const distribution = [
        {min:1, max:11, weight:0.2},   // 小数区
        {min:12, max:22, weight:0.3},  // 中数区
        {min:23, max:33, weight:0.5}   // 大数区
    ];
    
    const rand = Math.random();
    let acc = 0;
    
    for (const range of distribution) {
        if (rand < (acc += range.weight)) {
            return Math.floor(Math.random() * (range.max - range.min + 1)) + range.min;
        }
    }
    return Math.floor(Math.random() * 33) + 1;
}

// 通用工具函数
function pickRandom(arr, count) {
    const copy = [...arr];
    const result = [];
    while(result.length < count && copy.length > 0) {
        const index = Math.floor(Math.random() * copy.length);
        result.push(copy.splice(index, 1)[0]);
    }
    return result;
}

// 历史模拟器(修复版)
class HistorySimulator {
    constructor() {
        this.history = this.generateHistoryData();
    }

    generateHistoryData() {
        return Array.from({length: 100}, (_, i) => ({
            red: generateSmartNumbers(),
            issue: `2024${String(i+1).padStart(3, '0')}`
        }));
    }
}

// 主逻辑流程
async function generate() {
    showLoading();
    
    try {
        const simulator = new HistorySimulator();
        const analyzer = new DataAnalyzer(simulator.history);
        const numbers = await generateValidNumbers(analyzer);
        showResult(numbers);
    } catch (error) {
        showError(`生成失败: ${error.message}`);
    }
}

// 数据分析器
class DataAnalyzer {
    constructor(history) {
        this.history = history;
        this.buildCache();
    }

    buildCache() {
        this.recent30 = this.history.slice(0,30).map(d => d.red.join(','));
        this.previous = this.history[0]?.red || [];
    }
}

// 验证流程
function validateNumbers(numbers, analyzer) {
    if (numbers.length !== 6 || new Set(numbers).size !== 6) return false;
    if (analyzer.recent30.includes(numbers.join(','))) return false;
    if (!hasConsecutive(numbers)) return false;
    const repeatCount = numbers.filter(n => analyzer.previous.includes(n)).length;
    return repeatCount >= 1 && repeatCount <= 2;
}

function hasConsecutive(numbers) {
    const sorted = [...numbers].sort((a, b) => a - b);
    for (let i = 1; i < sorted.length; i++) {
        if (sorted[i] - sorted[i-1] === 1) return true;
    }
    return false;
}

// 生成流程
function generateValidNumbers(analyzer) {
    return new Promise(resolve => {
        let attempts = 0;
        
        const generateLoop = () => {
            if (++attempts > GENERATOR.maxAttempts) {
                resolve(generateFallbackNumbers());
                return;
            }
            
            const candidate = generateSmartNumbers(analyzer.previous);
            if (validateNumbers(candidate, analyzer)) {
                resolve(candidate);
            } else {
                requestAnimationFrame(generateLoop);
            }
        };
        
        generateLoop();
    });
}

function generateFallbackNumbers() {
    const nums = new Set();
    while(nums.size < 6) {
        nums.add(Math.floor(Math.random() * 33) + 1);
    }
    return [...nums].sort((a, b) => a - b);
}

// 界面交互
function showLoading() {
    document.getElementById('result').innerHTML = '<div class="status">正在生成中...</div>';
}

function showResult(numbers) {
    document.getElementById('result').innerHTML = `
        <div style="color: #E60012; font-weight: bold; font-size: 1.2em;">
            推荐号码:${numbers.join(', ')}
        </div>
        <div style="margin-top:10px;color:#666;font-size:0.9em;">
            ${new Date().toLocaleString()} 生成
        </div>
    `;
}

function showError(msg) {
    document.getElementById('result').innerHTML = `<div class="error">⚠️ ${msg}</div>`;
}
</script>
</body>
</html>