import random
# Define the double streets
double_streets = {
1: list(range(1, 7)), # [1, 2, 3, 4, 5, 6]
2: list(range(7, 13)), # [7, 8, 9, 10, 11, 12]
3: list(range(13, 19)), # [13, 14, 15, 16, 17, 18]
4: list(range(19, 25)), # [19, 20, 21, 22, 23, 24]
5: list(range(25, 31)), # [25, 26, 27, 28, 29, 30]
6: list(range(31, 37)), # [31, 32, 33, 34, 35, 36]
}
# Configuration variables
sets_width = 12 # Number of numbers to choose in each set
num_rounds = 100000 # Number of rounds (Sets) to simulate
threshold_three_or_less = 4 # Threshold for "four or less"
threshold_four_or_more = 5 # Threshold for "five or more"
# Function to find the double street for a given number, ignoring 0
def find_double_street(num):
if num == 0:
return None
for street_num, street in double_streets.items():
if num in street:
return street_num
return None
# Track the number of double streets results
results = []
zero_count = 0
# Function to generate a more random sample
def generate_random_sample():
sample = set()
while len(sample) < sets_width:
sample.add(random.randint(0, 36))
return list(sample)
# Simulate the rounds
for round_num in range(num_rounds):
count_double_streets = 0
selected_numbers = generate_random_sample() # Generate a more random sample
zero_count += selected_numbers.count(0) # Count how many times 0 appears
hit_streets = set() # Track which double streets were hit
hit_street_numbers = [find_double_street(num) for num in selected_numbers] # Store the double street numbers for each hit
valid_hits = [num for num in hit_street_numbers if num is not None] # Remove None values for 0 in calculations
hit_streets.update(valid_hits) # Add street numbers to the set
count_double_streets = len(hit_streets)
results.append(count_double_streets)
# Calculate statistics, excluding 0 double streets
total_rounds = len(results)
counts = {i: results.count(i) for i in range(1, 7)} # Count occurrences for 1 to 6
percentages = {i: (counts[i] / total_rounds) * 100 for i in range(1, 7)} # Calculate percentage for 1 to 6
# Calculate the maximum streak for each number of double streets
max_streaks = {i: 0 for i in range(1, 7)}
current_streaks = {i: 0 for i in range(1, 7)}
for result in results:
for i in range(1, 7):
if result == i:
current_streaks[i] += 1
if current_streaks[i] > max_streaks[i] and current_streaks[i] > 1: # Ensure streak is more than 1
max_streaks[i] = current_streaks[i]
else:
current_streaks[i] = 0
# Calculate the percentage and max streak for threshold_four_or_more and threshold_three_or_less
four_or_more = sum(results.count(i) for i in range(threshold_four_or_more, 7)) # Count occurrences for 5, 6
three_or_less = sum(results.count(i) for i in range(1, threshold_three_or_less + 1)) # Count occurrences for 1, 2, 3, 4
percentage_four_or_more = (four_or_more / total_rounds) * 100
percentage_three_or_less = (three_or_less / total_rounds) * 100
# Calculate the total max streak for threshold_four_or_more and threshold_three_or_less
max_streak_four_or_more = sum(max_streaks[i] for i in range(threshold_four_or_more, 7))
max_streak_three_or_less = sum(max_streaks[i] for i in range(1, threshold_three_or_less + 1))
# Print the results in a formatted way
print(f"\nStatistics of Double Streets with {num_rounds} sets of {sets_width} numbers ({num_rounds * sets_width} Spins):\n")
for i in range(1, 7):
print(f"{i} DS | {counts[i]:<5} Sets | {percentages[i]:>5.2f}% | Streak: {max_streaks[i]}")
print("\nAdditional Percentages")
print("----------------------")
print(f"Percentage of rounds with {threshold_four_or_more} or more double streets: {percentage_four_or_more:.2f}% | Streak: {max_streak_four_or_more}")
print(f"Percentage of rounds with {threshold_three_or_less} or less double streets: {percentage_three_or_less:.2f}% | Streak: {max_streak_three_or_less}")