Novità

Intelligenza artificiale e lotto 🤖🎱📈📉🎯

=======================================================
🤖 BOT INTELLIGENTE v16 - CLEAR STATS
=======================================================
📂 DATI ESTRAZIONI:
• Database: /kaggle/input/estrazionilotto-aggiornate-al-20-1-2026
• Estrazioni caricate: 7143
-------------------------------------------------------
⚙️ PARAMETRI DI RICERCA:
• Pool Numeri Base: 20
• Lunghezza Gruppo: 18 - 20 (dinamica)
• Ruote Unite: da 1 a 3 (dinamica)
* Ruote analizzate : ['BA','CA','FI','GE','MI','NA','PA','RO','TO','VE']
(tolta NZ perchè accorciava troppo il dataset)
* Sorte di ricerca: 2-3-4 (dinamica)
* Sorte di verifica: 2 (fissa)
* Range verifica: 4 (fissa)
• Range Ritardo: 10 - 300 (dinamico)
-------------------------------------------------------
🏆 OBIETTIVI:
• Minimo Eventi: 800
• Minimo Successo: 99.0%
=======================================================

>>> Inizializzazione...

Best:100.0%(296):

 12629/? [04:27<00:00, 42.73it/s, L=19, R=3, Sg=280, Sr=4, St=]
★ 452 (92.7%) | L:19 R2 Sg34
★ 74 (94.6%) | L:18 R2 Sg54
★ 71 (95.8%) | L:18 R2 Sg54
★ 142 (96.5%) | L:19 R2 Sg280
★ 81 (98.8%) | L:20 R2 Sg280
★ 179 (98.9%) | L:18 R2 Sg300
★ 108 (99.1%) | L:19 R2 Sg300
★ 183 (100.0%) | L:18 R3 Sg300
★ 193 (100.0%) | L:18 R3 Sg270
★ 195 (100.0%) | L:18 R3 Sg280
★ 223 (100.0%) | L:18 R3 Sg285
★ 241 (100.0%) | L:18 R3 Sg280
★ 250 (100.0%) | L:18 R3 Sg260
★ 296 (100.0%) | L:18 R3 Sg260
...

Sta continuando lo scavo... con sola CPU 🤖🤠


Relativo code per kagglisti e pythoniani... (rigorosamente frutto di vibe coding con google ai studio) :)

Codice:
import numpy as np
import pandas as pd
import os
import time
import random
import json
import copy
import math
from itertools import combinations
from numba import njit, prange
from tqdm.notebook import tqdm
from IPython.display import Audio, display, HTML

# ============================================================
# 0. FIX VISUALIZZAZIONE KAGGLE
# ============================================================
display(HTML("<style>div.output_area pre {white-space: pre-wrap;}</style>"))

# ============================================================
# 1. IL TUO GRUPPO BASE (ad esempio i primi 20)
# ============================================================
GRUPPO_BASE_UTENTE = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]

# ============================================================
# 2. OBIETTIVI & LIMITI
# ============================================================
TARGET_CASI_MINIMI = 800
TARGET_PERC_MINIMA = 99.0
TARGET_COLPI_MAX   = 4

MIN_NUMERI_GRUPPO = 18
MAX_NUMERI_GRUPPO = 20  

MIN_SOGLIA = 10
MAX_SOGLIA = 300 
POSSIBILI_SORTI_RICERCA = [2, 3, 4]
MIN_RUOTE_UNITE     = 1     
MAX_RUOTE_UNITE     = 3     

RUOTE_NOMI = ['BA','CA','FI','GE','MI','NA','PA','RO','TO','VE']
PATH_RUOTE = "/kaggle/input/estrazionilotto-aggiornate-al-20-1-2026" 
FILE_CHECKPOINT = "miglior_sistema_v16_clear.json"
SORTE_VERIFICA = 2 

# ============================================================
# UTILITÀ
# ============================================================
def play_sound():
    display(HTML("""
    <script>
    var audio = new Audio('beep-01a.mp3');
    audio.play();
    </script>
    <b style="color:red; font-size:20px;">🔔 OBIETTIVO RAGGIUNTO! 🔔</b>
    """))

def salva_checkpoint(stato):
    with open(FILE_CHECKPOINT, "w") as f:
        json.dump(stato, f, indent=4)

def stampa_report_finale(binmat, stato, ev, perc, titolo="REPORT"):
    SEP = "=" * 55 
    SUB = "-" * 55
    
    print("\n" + SEP)
    print(f"  🛑 {titolo}")
    print(SEP)
    print(f"📊 RISULTATO: {ev} Eventi Totali | {perc:.2f}% Positivi")
    print(SUB)
    print("⚙️  CONFIGURAZIONE VINCENTE:")
    print(f"   • Numeri nel Gruppo     : {len(stato['gruppo'])}")
    print(f"   • Ruote Unite           : {stato['num_ruote']}")
    print(f"   • Sorte Ricerca (Trig.) : {stato['sorte_ric']}")
    print(f"   • Soglia Ritardo        : {stato['soglia_ric']}")
    print(SUB)
    print(f"🎱 LUNGHETTA TROVATA ({len(stato['gruppo'])}):")
    print(f"   {stato['gruppo']}")
    print(SEP)
    
    analizza_dettaglio_colpi(binmat, stato)
    mostra_previsioni_attive(binmat, stato)

# ============================================================
# ENGINE
# ============================================================
def carica_bin():
    estr = {}
    min_len = 10**9
    if not os.path.exists(PATH_RUOTE) and not os.path.exists(os.path.join(PATH_RUOTE, "estrazioni-BA.txt")):
        min_len = 2000
        binmat = np.zeros((min_len, len(RUOTE_NOMI), 90), dtype=np.uint8)
        for t in range(min_len):
            for r in range(len(RUOTE_NOMI)):
                nums = np.random.choice(np.arange(90), 5, replace=False)
                for n in nums: binmat[t, r, n] = 1
        return binmat, min_len

    for r in RUOTE_NOMI:
        fname = os.path.join(PATH_RUOTE, f"estrazioni-{r}.txt")
        if os.path.exists(fname):
            rows = []
            with open(fname) as f:
                for l in f:
                    p = l.strip().split(".")
                    if len(p) == 5: rows.append([int(x) for x in p])
            arr = np.array(rows, dtype=np.int16)
            estr[r] = arr
            min_len = min(min_len, len(arr))
    
    for r in RUOTE_NOMI: estr[r] = estr[r][:min_len][::-1]
    binmat = np.zeros((min_len, len(RUOTE_NOMI), 90), dtype=np.uint8)
    for ri, r in enumerate(RUOTE_NOMI):
        for t in range(min_len):
            for n in estr[r][t]:
                binmat[t, ri, n-1] = 1
    return binmat, min_len

@njit(parallel=True)
def scan_core(binmat, combs, ruote_idx_list, sric, sver, thr_ric, thr_ver):
    n_groups = ruote_idx_list.shape[0]
    n_ruote_in_group = ruote_idx_list.shape[1] 
    ncomb = combs.shape[0]
    nt = binmat.shape[0]
    tot_ev = 0
    tot_ok = 0
    
    for g_idx in prange(n_groups):
        for i in range(ncomb):
            rit_ric = 0
            in_ver = False
            rit_ver = 0
            for t in range(nt):
                max_hit = 0
                for r_sub_idx in range(n_ruote_in_group):
                    r_real = ruote_idx_list[g_idx, r_sub_idx]
                    current_hit = 0
                    for k in range(combs.shape[1]):
                        current_hit += binmat[t, r_real, combs[i,k]]
                    if current_hit > max_hit:
                        max_hit = current_hit
                if not in_ver:
                    if max_hit >= sric: rit_ric = 0
                    else: rit_ric += 1
                    if rit_ric >= thr_ric:
                        in_ver = True
                        rit_ver = 0
                else:
                    rit_ver += 1
                    if max_hit >= sver:
                        tot_ev += 1
                        if rit_ver <= thr_ver: tot_ok += 1
                        in_ver = False
                        rit_ric = 0
    return tot_ev, tot_ok

def valuta_stato(binmat, stato):
    real_combs = np.array([ [x-1 for x in stato['gruppo']] ], dtype=np.int16)
    
    n_r = stato['num_ruote']
    ruote_combs = list(combinations(range(len(RUOTE_NOMI)), n_r))
    ruote_idx_arr = np.array(ruote_combs, dtype=np.int32)
    if ruote_idx_arr.ndim == 1:
        ruote_idx_arr = ruote_idx_arr.reshape(-1, 1)

    ev, ok = scan_core(
        binmat, real_combs, ruote_idx_arr,
        stato['sorte_ric'], SORTE_VERIFICA,
        stato['soglia_ric'], TARGET_COLPI_MAX
    )
    perc = (ok / ev * 100) if ev > 0 else 0
    return ev, ok, perc

@njit
def scan_dettagliata_single_group(binmat, combs, ruote_idx, sric, sver, thr_ric, thr_ver):
    ncomb = combs.shape[0]
    nt = binmat.shape[0]
    n_ruote = ruote_idx.shape[0]
    colpi_esito = np.zeros(5000, dtype=np.int16) 
    count_ev = 0
    
    for i in range(ncomb):
        rit_ric = 0
        in_ver = False
        rit_ver = 0
        for t in range(nt):
            max_hit = 0
            for r_sub_idx in range(n_ruote):
                r_real = ruote_idx[r_sub_idx]
                current_hit = 0
                for k in range(combs.shape[1]):
                    current_hit += binmat[t, r_real, combs[i,k]]
                if current_hit > max_hit: max_hit = current_hit
            
            if not in_ver:
                if max_hit >= sric: rit_ric = 0
                else: rit_ric += 1
                if rit_ric >= thr_ric:
                    in_ver = True
                    rit_ver = 0
            else:
                rit_ver += 1
                if max_hit >= sver:
                    if count_ev < 5000:
                        colpi_esito[count_ev] = rit_ver
                        count_ev += 1
                    in_ver = False
                    rit_ric = 0
    return count_ev, colpi_esito

# ============================================================
# NUOVA ANALISI DETTAGLIATA (CON SPIEGAZIONE TOTALI)
# ============================================================
def analizza_dettaglio_colpi(binmat, stato):
    SEP = "=" * 55
    SUB = "-" * 40
    print("\n" + SEP)
    print("  🔎 ANALISI BACKTEST (TOP PERFORMANCE)")
    print(SEP)
    
    real_combs = np.array([ [x-1 for x in stato['gruppo']] ], dtype=np.int16)
    n_r = stato['num_ruote']
    ruote_combs_list = list(combinations(range(len(RUOTE_NOMI)), n_r))
    results = []
    
    total_found_events = 0
    total_combinations_with_events = 0
    
    # Calcolo dati
    for rc in tqdm(ruote_combs_list, desc="Analisi", leave=False, ncols=60):
        single_ruote_idx = np.array(rc, dtype=np.int32)
        cnt, colpi_arr = scan_dettagliata_single_group(
            binmat, real_combs, single_ruote_idx,
            stato['sorte_ric'], SORTE_VERIFICA,
            stato['soglia_ric'], TARGET_COLPI_MAX
        )
        
        if cnt > 0:
            total_found_events += cnt
            total_combinations_with_events += 1
            
            valid_colpi = colpi_arr[:cnt]
            ok = np.sum(valid_colpi <= TARGET_COLPI_MAX)
            perc = (ok / cnt) * 100
            
            negativi = valid_colpi[valid_colpi > TARGET_COLPI_MAX]
            dettagli_negativi = []
            if len(negativi) > 0:
                for n in negativi[:5]: 
                    diff = n - TARGET_COLPI_MAX
                    dettagli_negativi.append(f"{n}")
            if len(negativi) > 5: dettagli_negativi.append("..")
            neg_str = ",".join(dettagli_negativi) if dettagli_negativi else "OK"
            
            results.append({
                "Ruote": "-".join([RUOTE_NOMI[x] for x in rc]),
                "Ev": cnt,
                "Perc": perc,
                "Out": neg_str
            })

    df = pd.DataFrame(results)
    
    # Stampa Intelligente
    print(f"Combinazioni Ruote testate : {len(ruote_combs_list)}")
    print(f"Combinazioni con eventi    : {total_combinations_with_events}")
    print(f"Totale Eventi (Somma)      : {total_found_events}")
    print(SUB + "\n")
    
    if df.empty:
        print("Nessun evento trovato.")
        return

    df = df.sort_values(by=["Perc", "Ev"], ascending=False)
    
    # Mostriamo le prime 15
    TOP_N = 15
    displayed_events = 0
    
    for idx, row in df.head(TOP_N).iterrows():
        displayed_events += row['Ev']
        print(f"📌 {row['Ruote']} -> {row['Perc']:.2f}% ({row['Ev']} cs)")
        if row['Perc'] < 100:
            print(f"   ⚠️ Rit: {row['Out']}")
        else:
            print(f"   ✅ OK")
        print(SUB)
        
    remaining = total_found_events - displayed_events
    if remaining > 0:
        print(f"\n... e altre {total_combinations_with_events - TOP_N} combinazioni ruote")
        print(f"    che sommano altri {remaining} eventi.")
        print(f"    (TOTALE GENERALE: {total_found_events})")

@njit
def check_active_status(binmat, combs, ruote_idx, sric, sver, thr_ric, thr_ver):
    ncomb = combs.shape[0]
    nt = binmat.shape[0]
    n_ruote = ruote_idx.shape[0]
    is_active = False
    colpi_passati = 0
    for i in range(ncomb):
        rit_ric = 0
        in_ver = False
        rit_ver = 0
        for t in range(nt):
            max_hit = 0
            for r_sub_idx in range(n_ruote):
                r_real = ruote_idx[r_sub_idx]
                current_hit = 0
                for k in range(combs.shape[1]):
                    current_hit += binmat[t, r_real, combs[i,k]]
                if current_hit > max_hit: max_hit = current_hit
            if not in_ver:
                if max_hit >= sric: rit_ric = 0
                else: rit_ric += 1
                if rit_ric >= thr_ric:
                    in_ver = True
                    rit_ver = 0
            else:
                rit_ver += 1
                if max_hit >= sver:
                    in_ver = False
                    rit_ric = 0
        if in_ver:
            if rit_ver <= thr_ver:
                is_active = True
                colpi_passati = rit_ver
                break 
    return is_active, colpi_passati

def mostra_previsioni_attive(binmat, stato):
    SEP = "=" * 55
    SUB = "-" * 40
    print("\n" + SEP)
    print("  🔮 PREVISIONI ATTIVE")
    print(f"  (Trigger: Rit>{stato['soglia_ric']} | Target: {TARGET_COLPI_MAX} clp)")
    print(SEP)
    
    real_combs = np.array([ [x-1 for x in stato['gruppo']] ], dtype=np.int16)
    n_r = stato['num_ruote']
    ruote_combs_list = list(combinations(range(len(RUOTE_NOMI)), n_r))
    found_any = False
    
    for rc in ruote_combs_list:
        single_ruote_idx = np.array(rc, dtype=np.int32)
        active, colpi_passati = check_active_status(
            binmat, real_combs, single_ruote_idx,
            stato['sorte_ric'], SORTE_VERIFICA,
            stato['soglia_ric'], TARGET_COLPI_MAX
        )
        
        if active:
            found_any = True
            colpi_rim = TARGET_COLPI_MAX - colpi_passati
            nomi = "-".join([RUOTE_NOMI[x] for x in rc])
            cnt, colpi_arr = scan_dettagliata_single_group(
                binmat, real_combs, single_ruote_idx,
                stato['sorte_ric'], SORTE_VERIFICA,
                stato['soglia_ric'], TARGET_COLPI_MAX
            )
            valid_colpi = colpi_arr[:cnt]
            perc_loc = 0
            if cnt > 0:
                perc_loc = (np.sum(valid_colpi <= TARGET_COLPI_MAX) / cnt) * 100
            
            icon = "🟢" if perc_loc == 100 else "🟡"
            print(f"{icon} {nomi}")
            print(f"   🔥 ATTIVA DA : {colpi_passati} colpi")
            print(f"   🎲 GIOCA PER : {colpi_rim} colpi")
            print(f"   📊 Storico   : {perc_loc:.1f}% su {cnt} casi")
            print(SUB)
            
    if not found_any:
        print("ℹ️  Nessuna previsione attiva al momento.")

# ============================================================
# MAIN
# ============================================================
def main_autonomous():
    binmat, num_estr = carica_bin()
    SEP = "=" * 55
    print("\n" + SEP)
    print("  🤖 BOT INTELLIGENTE v16 - CLEAR STATS")
    print(SEP)
    print("📂 DATI ESTRAZIONI:")
    print(f"   • Database: {PATH_RUOTE}")
    print(f"   • Estrazioni caricate: {num_estr}")
    print("-" * 55)
    print("⚙️  PARAMETRI DI RICERCA:")
    print(f"   • Pool Numeri Base: {len(GRUPPO_BASE_UTENTE)}")
    print(f"   • Lunghezza Gruppo: {MIN_NUMERI_GRUPPO} - {MAX_NUMERI_GRUPPO} (dinamica)")
    print(f"   • Ruote Unite: {MIN_RUOTE_UNITE} - {MAX_RUOTE_UNITE}")
    print(f"   • Range Ritardo: {MIN_SOGLIA} - {MAX_SOGLIA}")
    print("-" * 55)
    print("🏆 OBIETTIVI:")
    print(f"   • Minimo Eventi: {TARGET_CASI_MINIMI}")
    print(f"   • Minimo Successo: {TARGET_PERC_MINIMA}%")
    print(SEP + "\n")
    
    print(" >>> Inizializzazione...")
    start_size = random.randint(MIN_NUMERI_GRUPPO, MAX_NUMERI_GRUPPO)
    current_stato = {
        'gruppo': sorted(random.sample(GRUPPO_BASE_UTENTE, start_size)),
        'soglia_ric': 40,
        'sorte_ric': 2,
        'num_ruote': 2 
    }
    
    cur_ev, cur_ok, cur_perc = valuta_stato(binmat, current_stato)
    best_stato = copy.deepcopy(current_stato)
    best_ev, best_ok, best_perc = cur_ev, cur_ok, cur_perc
    
    T = 800.0
    alpha = 0.99
    
    def get_score(e, p):
        if e < 50: return 0
        return (p * 100) + (math.log(e)*20)

    cur_score = get_score(cur_ev, cur_perc)
    best_score = cur_score
    pbar = tqdm(desc="Start", unit="it", ncols=75)
    stagnation_zero = 0

    try:
        while True:
            if best_ev >= TARGET_CASI_MINIMI and best_perc >= TARGET_PERC_MINIMA:
                pbar.close()
                play_sound()
                stampa_report_finale(binmat, best_stato, best_ev, best_perc, "OBIETTIVO RAGGIUNTO")
                input("Invio per uscire...")
                return

            pbar.update(1)
            
            if best_ev == 0:
                stagnation_zero += 1
                if stagnation_zero > 50:
                    current_stato['soglia_ric'] = random.randint(30, 80)
                    current_stato['num_ruote'] = 2
                    stagnation_zero = 0
            
            new_stato = copy.deepcopy(current_stato)
            dice = random.random()
            
            if dice < 0.25: 
                r2 = random.random()
                if r2 < 0.33:
                    new_stato['soglia_ric'] += random.choice([-10, 5, 10, 20])
                    new_stato['soglia_ric'] = max(MIN_SOGLIA, min(MAX_SOGLIA, new_stato['soglia_ric']))
                elif r2 < 0.66:
                    new_stato['num_ruote'] += random.choice([-1, 1])
                    new_stato['num_ruote'] = max(MIN_RUOTE_UNITE, min(MAX_RUOTE_UNITE, new_stato['num_ruote']))
                else:
                    new_stato['sorte_ric'] = random.choice(POSSIBILI_SORTI_RICERCA)
                    if new_stato['sorte_ric'] == 2: new_stato['soglia_ric'] = 120
                    if new_stato['sorte_ric'] == 3: new_stato['soglia_ric'] = 200
                    if new_stato['sorte_ric'] == 4: new_stato['soglia_ric'] = 280
            
            elif dice < 0.45:
                curr_len = len(new_stato['gruppo'])
                action = 0 
                if curr_len < MAX_NUMERI_GRUPPO and curr_len > MIN_NUMERI_GRUPPO:
                    action = random.choice([-1, 1])
                elif curr_len == MIN_NUMERI_GRUPPO:
                    action = 1 
                elif curr_len == MAX_NUMERI_GRUPPO:
                    action = -1 
                
                if action == 1:
                    pool = [x for x in GRUPPO_BASE_UTENTE if x not in new_stato['gruppo']]
                    if pool:
                        new_stato['gruppo'].append(random.choice(pool))
                        new_stato['gruppo'].sort()
                elif action == -1:
                    new_stato['gruppo'].pop(random.randint(0, len(new_stato['gruppo'])-1))
            
            else:
                n_chg = 1
                if cur_ev < TARGET_CASI_MINIMI / 2: n_chg = 2
                for _ in range(n_chg):
                    if len(new_stato['gruppo']) > 0:
                        new_stato['gruppo'].pop(random.randint(0, len(new_stato['gruppo'])-1))
                
                pool_disponibile = [n for n in GRUPPO_BASE_UTENTE if n not in new_stato['gruppo']]
                while len(new_stato['gruppo']) < len(current_stato['gruppo']): 
                    if not pool_disponibile: break 
                    r = random.choice(pool_disponibile)
                    new_stato['gruppo'].append(r)
                    pool_disponibile.remove(r)
                new_stato['gruppo'].sort()

            ev, ok, perc = valuta_stato(binmat, new_stato)
            new_score = get_score(ev, perc)
            delta = new_score - cur_score
            
            accepted = False
            msg_status = ""
            
            if delta > 0:
                accepted = True
            else:
                prob = math.exp(delta / T) if T > 0 else 0
                if random.random() < prob: accepted = True
            
            if accepted:
                current_stato = new_stato
                cur_ev, cur_ok, cur_perc = ev, ok, perc
                cur_score = new_score
                
                if new_score > best_score:
                    best_stato = copy.deepcopy(new_stato)
                    best_ev, best_ok, best_perc = ev, ok, perc
                    best_score = new_score
                    salva_checkpoint(best_stato)
                    msg_status = "★"
                    tqdm.write(f"★ {ev} ({perc:.1f}%) | L:{len(new_stato['gruppo'])} R{new_stato['num_ruote']} Sg{new_stato['soglia_ric']}")

            pbar.set_description(f"Best:{best_perc:.1f}%({best_ev})")
            pbar.set_postfix({
                'L': len(current_stato['gruppo']),
                'R': current_stato['num_ruote'], 
                'Sg': current_stato['soglia_ric'],
                'Sr': current_stato['sorte_ric'],
                'St': msg_status
            })

            T = T * alpha
            if T < 1.0:
                T = 500.0 
                current_stato = copy.deepcopy(best_stato)
                cur_score = best_score
                
    except KeyboardInterrupt:
        pbar.close()
        stampa_report_finale(binmat, best_stato, best_ev, best_perc, "STOP MANUALE")

if __name__ == "__main__":
    main_autonomous()
 
Ultima modifica:

Ultima estrazione Lotto

  • Estrazione del lotto
    martedì 20 gennaio 2026
    Bari
    78
    48
    43
    19
    39
    Cagliari
    16
    77
    87
    56
    45
    Firenze
    70
    38
    74
    13
    82
    Genova
    29
    51
    24
    17
    90
    Milano
    44
    08
    52
    31
    70
    Napoli
    73
    89
    16
    72
    62
    Palermo
    86
    59
    10
    84
    30
    Roma
    51
    49
    35
    29
    43
    Torino
    23
    12
    74
    82
    69
    Venezia
    73
    64
    37
    41
    72
    Nazionale
    04
    35
    65
    02
    23
    Estrazione Simbolotto
    Bari
    41
    22
    05
    13
    01
Indietro
Alto