mirror of
https://github.com/Floriansylvain/FDJ-SLAYER.git
synced 2026-08-19 11:43:21 +02:00
refactor: translated comments, constants and functions in EN
This commit is contained in:
+5
-5
@@ -1,8 +1,8 @@
|
|||||||
NOMBRE_TIRAGE = 100
|
NUMBER_OF_DRAWS = 100
|
||||||
NOMBRE_NUMEROS = 5
|
NUMBER_OF_NUMBERS = 5
|
||||||
MAX_NUMERO = 50
|
MAX_NUMBER = 50
|
||||||
NOMBRE_ETOILES = 2
|
NUMBER_OF_STARS = 2
|
||||||
MAX_ETOILE = 12
|
MAX_STAR = 12
|
||||||
OPENMETEO_API_URL = "https://api.open-meteo.com/v1/forecast"
|
OPENMETEO_API_URL = "https://api.open-meteo.com/v1/forecast"
|
||||||
OPENMETEO_HOURLY_PARAMS = [
|
OPENMETEO_HOURLY_PARAMS = [
|
||||||
"temperature_2m", "relative_humidity_2m", "wind_speed_10m",
|
"temperature_2m", "relative_humidity_2m", "wind_speed_10m",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
"""
|
"""
|
||||||
Ce script génère des tirages aléatoires pour l'EuroMillions en utilisant des sources d'entropie variées.
|
This script generates random draws for EuroMillions using various entropy sources.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
@@ -29,7 +29,7 @@ def _fetch_weather_api(params):
|
|||||||
return openmeteo.weather_api(OPENMETEO_API_URL, params=params)
|
return openmeteo.weather_api(OPENMETEO_API_URL, params=params)
|
||||||
|
|
||||||
def _get_weather_data():
|
def _get_weather_data():
|
||||||
"""Fonction interne qui récupère les données météo de l'API"""
|
"""Internal function that retrieves weather data from API"""
|
||||||
params = {
|
params = {
|
||||||
"latitude": random.uniform(-70, 70),
|
"latitude": random.uniform(-70, 70),
|
||||||
"longitude": random.uniform(-180, 180),
|
"longitude": random.uniform(-180, 180),
|
||||||
@@ -47,16 +47,16 @@ def _get_weather_data():
|
|||||||
return hashlib.sha256(weather_str.encode()).hexdigest()
|
return hashlib.sha256(weather_str.encode()).hexdigest()
|
||||||
|
|
||||||
def get_weather_entropy():
|
def get_weather_entropy():
|
||||||
"""Récupère des données météo comme source supplémentaire d'entropie"""
|
"""Retrieves weather data as additional source of entropy"""
|
||||||
try:
|
try:
|
||||||
return _get_weather_data()
|
return _get_weather_data()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Erreur lors de la récupération des données météo: {e}")
|
print(f"Error retrieving weather data: {e}")
|
||||||
fallback = f"weather_fallback_{time.time()}_{random.getrandbits(64)}"
|
fallback = f"weather_fallback_{time.time()}_{random.getrandbits(64)}"
|
||||||
return hashlib.sha256(fallback.encode()).hexdigest()
|
return hashlib.sha256(fallback.encode()).hexdigest()
|
||||||
|
|
||||||
def get_static_entropy_pool():
|
def get_static_entropy_pool():
|
||||||
"""Crée un pool d'entropie de base avec des sources qui ne changent pas rapidement"""
|
"""Creates a base entropy pool with sources that don't change rapidly"""
|
||||||
weather_entropy = get_weather_entropy()
|
weather_entropy = get_weather_entropy()
|
||||||
return [
|
return [
|
||||||
str(os.urandom(32)),
|
str(os.urandom(32)),
|
||||||
@@ -71,7 +71,7 @@ def get_static_entropy_pool():
|
|||||||
]
|
]
|
||||||
|
|
||||||
def get_dynamic_entropy_pool():
|
def get_dynamic_entropy_pool():
|
||||||
"""Récupère des données dynamiques pour ajouter de l'entropie"""
|
"""Retrieves dynamic data to add entropy"""
|
||||||
return [
|
return [
|
||||||
str(time.time()),
|
str(time.time()),
|
||||||
hashlib.sha256(str(time.perf_counter()).encode()).hexdigest(),
|
hashlib.sha256(str(time.perf_counter()).encode()).hexdigest(),
|
||||||
@@ -88,7 +88,7 @@ def get_dynamic_entropy_pool():
|
|||||||
]
|
]
|
||||||
|
|
||||||
def generate_seed(base_pool=None):
|
def generate_seed(base_pool=None):
|
||||||
"""Génère une graine aléatoire en combinant différentes sources d'entropie"""
|
"""Generates a random seed by combining different entropy sources"""
|
||||||
entropy_sources = base_pool.copy() if base_pool else []
|
entropy_sources = base_pool.copy() if base_pool else []
|
||||||
entropy_sources.extend(get_dynamic_entropy_pool())
|
entropy_sources.extend(get_dynamic_entropy_pool())
|
||||||
random.shuffle(entropy_sources)
|
random.shuffle(entropy_sources)
|
||||||
@@ -100,68 +100,68 @@ def generate_seed(base_pool=None):
|
|||||||
final_hash = hashlib.sha256(intermediate_hash).hexdigest()
|
final_hash = hashlib.sha256(intermediate_hash).hexdigest()
|
||||||
return int(final_hash, 16)
|
return int(final_hash, 16)
|
||||||
|
|
||||||
def faire_tirage(base_pool=None):
|
def make_draw(base_pool=None):
|
||||||
"""Génère un tirage avec N numéros et M étoiles en utilisant une graine aléatoire"""
|
"""Generates a draw with N numbers and M stars using a random seed"""
|
||||||
seed = generate_seed(base_pool)
|
seed = generate_seed(base_pool)
|
||||||
random.seed(seed)
|
random.seed(seed)
|
||||||
numeros = random.sample(range(1, MAX_NUMERO + 1), NOMBRE_NUMEROS)
|
numbers = random.sample(range(1, MAX_NUMBER + 1), NUMBER_OF_NUMBERS)
|
||||||
etoiles = random.sample(range(1, MAX_ETOILE + 1), NOMBRE_ETOILES)
|
stars = random.sample(range(1, MAX_STAR + 1), NUMBER_OF_STARS)
|
||||||
return {
|
return {
|
||||||
"graine": seed,
|
"seed": seed,
|
||||||
"numeros": sorted(numeros),
|
"numbers": sorted(numbers),
|
||||||
"etoiles": sorted(etoiles)
|
"stars": sorted(stars)
|
||||||
}
|
}
|
||||||
|
|
||||||
def generate_draws(num_tirages):
|
def generate_draws(num_draws):
|
||||||
"""Génère plusieurs tirages séquentiellement"""
|
"""Generates multiple draws sequentially"""
|
||||||
base_pool = get_static_entropy_pool()
|
base_pool = get_static_entropy_pool()
|
||||||
bar = Bar('Progression', max=num_tirages, suffix='%(percent)d%%')
|
bar = Bar('Progress', max=num_draws, suffix='%(percent)d%%')
|
||||||
|
|
||||||
tirages = []
|
draws = []
|
||||||
for _ in range(num_tirages):
|
for _ in range(num_draws):
|
||||||
tirages.append(faire_tirage(base_pool))
|
draws.append(make_draw(base_pool))
|
||||||
time.sleep(0.01)
|
time.sleep(0.01)
|
||||||
bar.next()
|
bar.next()
|
||||||
|
|
||||||
bar.finish()
|
bar.finish()
|
||||||
return tirages
|
return draws
|
||||||
|
|
||||||
def afficher_tirage(tirage, indice=None, titre="TIRAGE"):
|
def display_draw(draw, index=None, title="DRAW"):
|
||||||
"""Affiche un tirage de façon formatée"""
|
"""Displays a draw in a formatted way"""
|
||||||
print(f"\n===== {titre} =====")
|
print(f"\n===== {title} =====")
|
||||||
if indice is not None:
|
if index is not None:
|
||||||
print(f"Tirage #{indice + 1}")
|
print(f"Draw #{index + 1}")
|
||||||
print(f"Numéros : {tirage['numeros']}")
|
print(f"Numbers: {draw['numbers']}")
|
||||||
print(f"Étoiles : {tirage['etoiles']}")
|
print(f"Stars: {draw['stars']}")
|
||||||
print(f"Graine utilisée : {tirage['graine']}")
|
print(f"Seed used: {draw['seed']}")
|
||||||
|
|
||||||
def afficher_tirages_supplementaires(tirages, tirages_affiches):
|
def display_additional_draws(draws, displayed_draws):
|
||||||
"""Affiche des tirages aléatoires supplémentaires à la demande de l'utilisateur."""
|
"""Displays additional random draws at the user's request."""
|
||||||
while len(tirages_affiches) < len(tirages):
|
while len(displayed_draws) < len(draws):
|
||||||
afficher_autre = input("\nVoulez-vous voir un autre tirage aléatoire? (o/n): ").lower().strip()
|
display_another = input("\nDo you want to see another random draw? (y/n): ").lower().strip()
|
||||||
if afficher_autre not in ['o', 'oui', 'y', 'yes', '']:
|
if display_another not in ['o', 'oui', 'y', 'yes', '']:
|
||||||
break
|
break
|
||||||
|
|
||||||
indices_disponibles = [i for i in range(len(tirages)) if i not in tirages_affiches]
|
available_indices = [i for i in range(len(draws)) if i not in displayed_draws]
|
||||||
if not indices_disponibles:
|
if not available_indices:
|
||||||
print("Tous les tirages ont déjà été affichés!")
|
print("All draws have already been displayed!")
|
||||||
break
|
break
|
||||||
|
|
||||||
indice_nouveau = random.choice(indices_disponibles)
|
new_index = random.choice(available_indices)
|
||||||
nouveau_tirage = tirages[indice_nouveau]
|
new_draw = draws[new_index]
|
||||||
tirages_affiches.add(indice_nouveau)
|
displayed_draws.add(new_index)
|
||||||
|
|
||||||
afficher_tirage(nouveau_tirage, indice_nouveau, "AUTRE TIRAGE ALÉATOIRE")
|
display_draw(new_draw, new_index, "ANOTHER RANDOM DRAW")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
print(f"Génération de {NOMBRE_TIRAGE} tirages différents...")
|
print(f"Generating {NUMBER_OF_DRAWS} different draws...")
|
||||||
tirages = generate_draws(NOMBRE_TIRAGE)
|
draws = generate_draws(NUMBER_OF_DRAWS)
|
||||||
|
|
||||||
base_pool = get_static_entropy_pool()
|
base_pool = get_static_entropy_pool()
|
||||||
random.seed(generate_seed(base_pool))
|
random.seed(generate_seed(base_pool))
|
||||||
tirage_choisi = random.choice(tirages)
|
chosen_draw = random.choice(draws)
|
||||||
tirages_affiches = {tirages.index(tirage_choisi)}
|
displayed_draws = {draws.index(chosen_draw)}
|
||||||
|
|
||||||
afficher_tirage(tirage_choisi, titre="RÉSULTAT FINAL")
|
display_draw(chosen_draw, title="FINAL RESULT")
|
||||||
print("Tirage sélectionné parmi les", NOMBRE_TIRAGE, "générés")
|
print("Draw selected from among the", NUMBER_OF_DRAWS, "generated")
|
||||||
afficher_tirages_supplementaires(tirages, tirages_affiches)
|
display_additional_draws(draws, displayed_draws)
|
||||||
|
|||||||
Reference in New Issue
Block a user